Le 10/06/2013 21:49, Alejandro Gonzalo a écrit :
Using fpc's cddb unit I was able to form the freedb query string from the CD in my drive (for "The Great Bluesmen" it was : 2b10b215 21 150 12557 26267 48645 60997 77047 91730 103462 117580 129470 145975 160670 185985 199220 213447 228725 250610 270005 283037 292752 309990 4276). Using the instructions at
http://staffwww.dcs.shef.ac.uk/people/D.Abbott/Library/freedb.howto1.06.txt
I tried using the Get method of Indy's TIdHTTP component to go retrieve the album info, but I just get error messages (usually 500 Command syntax error: incorrect number of arguments). Could some kind person please give me a successful example of using TIdHttp.get (or the equivalent in Synapse) with freedb.org? Are there Properties I need to set?
Thank you.
A. G.


I've read in the howto that the GET is not supported and POST bust be used instead. After having quickly read the text it seems that the request is adressed to a form using fields descriptors. This meand that the header must be filled in as the URL requests it. Y guess you shoud use something like
var
  data: TIdMultiPartFormDataStream;
  ResponseStream: TStringStream;
  Reponse: String;
  IdIntercept: TIdConnectionIntercept;   // might not be needed

begin
  ... some initialization code

IdIntercept := TIdConnectionIntercept.Create(nil); // might not be needed
  data := TIdMultiPartFormDataStream.Create;
  with TIdHTTP.Create(nil) do try
     // use a timeout to get control back if URL does not answer
      ConnectTimeout := 20000;

     // might not be needed but usefull to trace what happens
      IdIntercept.OnConnect := @HttpInterceptConnect;
      IdIntercept.OnDisconnect := @HttpInterceptDisconnect;
IdIntercept.OnReceive := @HttpInterceptReceive; // <--- this one could be important to use
      IdIntercept.OnSend := @HttpInterceptSend;

// you maight use these event if you want to inform the use on how things are going on
      OnStatus := IdHTTPSStatus;
      OnWork := IdHTTPSWork;
      OnWorkBegin := IdHTTPSWorkBegin;
      OnWorkEnd := IdHTTPSWorkEnd;

      Request.ContentLength := -1;
      Request.ContentRangeEnd := 0;
      Request.ContentRangeStart := 0;
      Request.Accept := 'text/html, */*';
      Request.BasicAuthentication := False;
      Request.UserAgent := 'Some identification(compatible; Indy Library)';
      Request.Username := 'some_uer_if_needed';
      Request.Password := 'user_password?';
      HTTPOptions := [hoForceEncodeParams];
      Request.ContentType := 'application/x-www-form-urlencoded';
      data.AddFormField('no_client', AClient);

      ... as many fields as needed

      Request.ContentLength := data.size;
      ResponseStream.Position := 0;
      Request.ContentLength := data.size;
      Post(HTTPPostServer, data, ResponseStream);
      ResponseStream.Position := 0;
      Reponse := ResponseStream.DataString;

  finally
    Free;
    data.Free;
    IdIntercept .Free
  end

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to