Recent

Author Topic: [SOLVED] Error in most basic TFPHTTPClient usage  (Read 28144 times)

d.ioannidis

  • Full Member
  • ***
  • Posts: 221
    • Nephelae
Re: [solved] Re: Error in most basic TFPHTTPClient usage
« Reply #15 on: July 08, 2016, 02:16:31 am »
So it seems reasonable to expect fcl-web to pass a default agent header.

( Quoting  Remy Lebeau )

"The User-Agent header is optional in RFC 2616. It SHOULD be used by clients, but it is not REQUIRED to be used. All of the major third-party browsers/clients use it, but custom apps/APIs/bots/etc might not. There are webservers that alter responses, or even reject requests (which is annoying), based on the User-Agent provided (or lack of one)."

PLz, fill a feature request ... ( IMO it's not a bug ).

regards,

guest58172

  • Guest
Re: [solved] Re: Error in most basic TFPHTTPClient usage
« Reply #16 on: July 08, 2016, 02:23:28 am »
Thx much for reading the doc for me.

It's an API. Shouldn't at least had a quick look how to use it ?  ;) :D

( Couldn't believe that fphttpclient failed in such basic operation .... )

I've made the typical error that people do with tech docs and manuals. They read only the section that they interested by and miss a lot of things...

guest58172

  • Guest
Re: [solved] Re: Error in most basic TFPHTTPClient usage
« Reply #17 on: July 08, 2016, 06:53:29 pm »
( Couldn't believe that fphttpclient failed in such basic operation .... )

Yes, BBasile should probably file a bug report. Looking at Synapse, it appears it use "Mozilla/4.0 (compatible; Synapse)" as default agent. And Indy appears to use "Mozilla/3.0 (compatible; Indy Library)". So it seems reasonable to expect fcl-web to pass a default agent header.

I assume Apple's NSMutableURLRequest class does that, perhaps identifying itself as Safari, since I didn't need to set any headers for it to work correctly.

-Phil

http://bugs.freepascal.org/view.php?id=30359

Already closed.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: [solved] Re: Error in most basic TFPHTTPClient usage
« Reply #18 on: July 08, 2016, 07:15:33 pm »
http://bugs.freepascal.org/view.php?id=30359

Already closed.

Hmm, my source for Synapse does this in THTTPSend.Create:

  FUserAgent := 'Mozilla/4.0 (compatible; Synapse)';

Hence why I said that Synapse "appears" to set the user agent.

Not sure if I understand Michael's comment.

-Phil

ChrisR

  • Full Member
  • ***
  • Posts: 247
Re: [SOLVED] Error in most basic TFPHTTPClient usage
« Reply #19 on: December 20, 2017, 02:35:14 pm »
I realize this is an old thread. However, the function below takes extends the example from Dimitrios Chr. Ioannidis to report the latest github release

Code: Pascal  [Select][+][-]
  1. function latestGitRelease(url: string): string;
  2. //Returns string for latest release (error will return empty string)
  3. //example
  4. // latestGitRelease('https://api.github.com/repos/rordenlab/dcm2niix/releases/latest');
  5. //will return
  6. // "v1.0.20171204"
  7. const
  8.      key = '"tag_name":"';
  9. var
  10.   s, e: integer;
  11.   cli: TFPHTTPClient;
  12. begin
  13.   result := '';
  14.   cli := TFPHTTPClient.Create(nil);
  15.   cli.AddHeader('User-Agent','Mozilla/5.0 (compatible; fpweb)');
  16.   try
  17.     try
  18.       result := Cli.Get(url);
  19.     except
  20.       result := '';
  21.     end;
  22.   finally
  23.     cli.free
  24.   end;
  25.   if length(result) < 1 then exit;
  26.   s := posex(key, result);
  27.   if s < 1 then begin
  28.      result := '';
  29.      exit;
  30.   end;
  31.   s := s+length(key);
  32.   e:= posex('"', result, s);
  33.   if e < 1 then begin
  34.      result := '';
  35.      exit;
  36.   end;
  37.   result := copy(result, s, e-s);
  38. end;  
 

guest58172

  • Guest
Re: [SOLVED] Error in most basic TFPHTTPClient usage
« Reply #20 on: January 26, 2018, 12:17:46 pm »
I used fcl-web since 2016. Recently i changed my main OS and realized that fcl-web is not compatible with most recent OpenSSL versions.

I try to look at other libraries that can contain an HTTPS client and the situation looks bad. All of them seem old and wont be be compatible with the default OpenSSL i'll get from the distribution package manager (FC27 for instance).

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: [SOLVED] Error in most basic TFPHTTPClient usage
« Reply #21 on: January 26, 2018, 12:33:47 pm »
I used fcl-web since 2016. Recently i changed my main OS and realized that fcl-web is not compatible with most recent OpenSSL versions.

I try to look at other libraries that can contain an HTTPS client and the situation looks bad. All of them seem old and wont be be compatible with the default OpenSSL i'll get from the distribution package manager (FC27 for instance).
Manjaro (and perhaps Arch, too) has 1.0.2.n-1 and 1.1.0.g-1 installable in parallel. Yes, 1.1 protocol has some incompatibilities with 1.0 protocol.

guest58172

  • Guest
Re: [SOLVED] Error in most basic TFPHTTPClient usage
« Reply #22 on: January 26, 2018, 01:00:03 pm »
I think you participated to the issue where i reported the bug. I couldn't say it there but well, i say it here. That sux a lot. Being able to do HTTPS request is quite important nowadays.

 

TinyPortal © 2005-2018