Consider the following program (it's a real program with real parameters,
nothing hidden, so you can really just try it out because the target server
is public):

{$mode objfpc}{$H+}

uses
  fphttpclient;

var
  HTTP: TFPHTTPClient;
begin
  HTTP := TFPHTTPClient.Create(nil);
  
  WriteLn('Response 1:');
  WriteLn(
    HTTP.FormPost(
      'http://api.jne.co.id:8889/tracing/sirclo/price',
     
'username=SIRCLO&api_key=4fd0e22535c32eb9e5496c311190760d&from=BOO10000&thru=AMI10000&weight=1'
    )
  );
  
  WriteLn('Response 2:');
  WriteLn(
    HTTP.FormPost(
      'http://api.jne.co.id:8889/tracing/sirclo/price',
     
'username=SIRCLO&api_key=4fd0e22535c32eb9e5496c311190760d&from=BDO10000&thru=AMI10000&weight=1'
    )
  );

  WriteLn('Response 3:');
  WriteLn(
    HTTP.FormPost(
      'http://api.jne.co.id:8889/tracing/sirclo/origin/key/BANDUNG',
      'username=SIRCLO&api_key=4fd0e22535c32eb9e5496c311190760d'
    )
  );
  
  HTTP.Free;
end.

In above program, Response 3 will stuck in infinite loop. Similarly, if we
move Response 3 up as the first request and then copy-paste-d:

{$mode objfpc}{$H+}

uses
  fphttpclient;

var
  HTTP: TFPHTTPClient;
begin
  HTTP := TFPHTTPClient.Create(nil);
  
  WriteLn('Response 1:');
  WriteLn(
    HTTP.FormPost(
      'http://api.jne.co.id:8889/tracing/sirclo/origin/key/BANDUNG',
      'username=SIRCLO&api_key=4fd0e22535c32eb9e5496c311190760d'
    )
  );
  
  WriteLn('Response 2:');
  WriteLn(
    HTTP.FormPost(
      'http://api.jne.co.id:8889/tracing/sirclo/origin/key/BOGOR',
      'username=SIRCLO&api_key=4fd0e22535c32eb9e5496c311190760d'
    )
  );
  
  WriteLn('Response 3:');
  WriteLn(
    HTTP.FormPost(
      'http://api.jne.co.id:8889/tracing/sirclo/price',
     
'username=SIRCLO&api_key=4fd0e22535c32eb9e5496c311190760d&from=BOO10000&thru=AMI10000&weight=1'
    )
  );

  HTTP.Free;
end.

the new Response 3 will result in empty string. As can be seen, the request
starts failing (either stuck or empty string) when the URL is changed.
Change in FormData is OK as demonstrated above.



--
View this message in context: 
http://free-pascal-general.1045716.n5.nabble.com/Cannot-reuse-TFPHTTPClient-object-for-2-different-POST-requests-tp5720779.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to