Recent

Author Topic: Downloading from the Internet  (Read 3795 times)

stansbkg

  • New Member
  • *
  • Posts: 28
Downloading from the Internet
« on: March 15, 2018, 07:05:41 pm »
I have been using elements of Synapse to access web pages. Since about March 1, it has been failing. Attached is a test program that works with google.com and bing.com, but not with yahoo.com. I do not understand.

Xor-el

  • Sr. Member
  • ****
  • Posts: 404
Re: Downloading from the Internet
« Reply #1 on: March 15, 2018, 07:26:20 pm »
in my case, google and yahoo fails, only bing passes.
this is expected since it seems that "TFPCustomHTTPClient.SimpleGet" does not support "https".

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Downloading from the Internet
« Reply #2 on: March 15, 2018, 08:22:01 pm »
Did you put the (correct) openssl dlls in your project directory?
Otherwise you don't have https support.

stansbkg

  • New Member
  • *
  • Posts: 28
Re: Downloading from the Internet
« Reply #3 on: March 16, 2018, 02:57:27 pm »
The program was functioning for serveral months, but has failed on all attempts for the past two weeks. I did nothing to the supporting material. It has behaved the same on two different machines.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: Downloading from the Internet
« Reply #4 on: March 16, 2018, 03:13:32 pm »
Are you sure that the webservices that you are using are still existing? In the Internet, you never can be sure that what works today will still work tomorrow, and most of all, in case of free services.

I once had written a little application to download and display historic share prices from free Yahoo and Google financial services (https://sourceforge.net/p/wp-laz/code/HEAD/tree/FinancialChart), and from one day to the other first Yahoo and then a few months later Google stopped this free service.

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Downloading from the Internet
« Reply #5 on: March 16, 2018, 03:17:03 pm »
Always remember to mention WHAT error-messages you get !!!

First of all, for SimpleGet you don't even need the "with TFPHttpClient.Create(Nil) do".
SimpleGet already creates a TFPHttpClient for itself.

Second, httpsend is not needed. TFPHttpClient is NOT from Synapse.

Third, SimpleGet just does a HTTPMethod('GET',AURL,Stream,[200]);
It only accepts a 200 response. But yahoo gives an 301 back. (Google probably too)

So if you want Redirection you need:
Code: Pascal  [Select][+][-]
  1. AllowRedirect := true;
  2. Page := Get('http://www.yahoo.com');

So the code would be:
Code: Pascal  [Select][+][-]
  1.         with TFPHttpClient.Create(Nil) do
  2.         begin
  3.           AllowRedirect := true;
  4. //        Page := Get('http://www.google.com');
  5. //        Page := Get('http://www.bing.com');
  6.           Page := Get('http://www.yahoo.com');
  7.         end;
(In this case you do need the with TFPHttpClient.Create because you need to set the AllowRedirect for it)
« Last Edit: March 16, 2018, 03:22:55 pm by rvk »

stansbkg

  • New Member
  • *
  • Posts: 28
Re: Downloading from the Internet
« Reply #6 on: March 16, 2018, 06:25:22 pm »
Problem solved:  I changed the URL for the site I was accessing from http:...  to https:... 
I had not noticed that both Google Chrome and Internet Explorer antomatically make that change. The site I was accessing must have made the change about the first of March. Before then, my program had worked fine for several months. Since then, it had always failed.
Thanks.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • Burdjia
Re: Downloading from the Internet
« Reply #7 on: March 19, 2018, 06:02:21 pm »
The browsers "change" it because the web server is sending you a 301 or 307 state with the new URL.  Your program should deal with HTTP states to work properly.  ;D
Are you interested in game programming? Join the Pascal Game Development community!
Also visit the Game Development Portal

 

TinyPortal © 2005-2018