PHP Classes

HTTP with proxy - how to recognize proxy has failed

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  HTTP with proxy - how to recognize...  >  (Un) Subscribe thread alerts  
Subject:HTTP with proxy - how to recognize...
Summary:HTTP with proxy - how to recognize proxy has failed
Messages:6
Author:Eryk
Date:2012-10-15 23:10:07
Update:2012-10-24 10:21:44
 

  1. HTTP with proxy - how to recognize...   Reply   Report abuse  
Picture of Eryk Eryk - 2012-10-15 23:10:07
I would like to connect to website X via proxy server. If connection error occures how to determine is it proxy problem (proxy server failed), or is it website X problem (website server failed)?

P.S. Great class :)

  2. Re: HTTP with proxy - how to recognize...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2012-10-16 01:34:08 - In reply to message 1 from Eryk
The class does not make any distinction between proxy errors and remote site errors. Sometimes it is even not possible to distinguish.

But why do you need to know?

  3. Re: HTTP with proxy - how to recognize...   Reply   Report abuse  
Picture of Eryk Eryk - 2012-10-16 10:46:59 - In reply to message 2 from Manuel Lemos
Hi, thanks for quick answer :)

I use several proxy servers to connect do website X. If connection has failed I would like to know what happened - if it was proxy problem, than I could change proxy to another one, and try to connect again with website X using diffrent proxy server.

I have done some tests, and...

1) When proxy is working fine, and website X has failed:
- variable 'results' is not empty, and proxy reply contains (maybe not always) string '<title>500 Unable to connect</title>'
- variable 'connection_close' = 1
- variable 'force_close' = 1

2) When proxy has failed:
- variable 'results' is empty
- 'reply_headers' is empty
- 'response_status' is empty
- 'connection_close' = 0
- 'force_close' = 0

So... there are some diffrents, but I don't know if I could rely on them :)

  4. Re: HTTP with proxy - how to recognize...   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2012-10-19 08:29:47 - In reply to message 3 from Eryk
Well, the best I can do is to set a separate variable if an error occurs when accessing a proxy. Just let me know if that would solve your problem.

  5. Re: HTTP with proxy - how to recognize...   Reply   Report abuse  
Picture of Eryk Eryk - 2012-10-24 10:21:44 - In reply to message 4 from Manuel Lemos
Yes, It will solve my problem :)

  6. Re: HTTP with proxy - how to recognize...   Reply   Report abuse  
Picture of allenmao allenmao - 2015-11-20 05:29:28 - In reply to message 4 from Manuel Lemos
check the following variable:

$client->response_status;