PHP Classes

HTTP Client + Proxy

Recommend this page to a friend!

      PHP HTTP protocol client  >  All threads  >  HTTP Client + Proxy  >  (Un) Subscribe thread alerts  
Subject:HTTP Client + Proxy
Summary:Website retireved without images
Messages:6
Author:David Halliday
Date:2007-02-08 08:31:17
Update:2007-02-10 05:10:44
 

  1. HTTP Client + Proxy   Reply   Report abuse  
Picture of David Halliday David Halliday - 2007-02-08 08:31:17
Hi
I have been trying to implement the HTTP client to use it as a bridge (or a proxy) to overcome illegitimate censorship.

The "test_http_image_request.php" works fine when a full url of an image is given. However, if a url of the page is entered , all the images + thumbnails on that page are not retrieved.

Any help in implementing the class would be apprciated, if only a gentle helping hand, Regards, David

  2. Re: HTTP Client + Proxy   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-02-08 23:26:15 - In reply to message 1 from David Halliday
I am not sure what you are doing, but to retrieve the images in a page, you need to compute the complete URL of the images as the class has only performs one request at a time and it needs the complete URL of the resource you want to access.

  3. Re: HTTP Client + Proxy   Reply   Report abuse  
Picture of David Halliday David Halliday - 2007-02-09 05:30:01 - In reply to message 2 from Manuel Lemos
Thank you for your reply. I'll try to explain it briefly:-

What I want to do is to have a file similar to "test_http.php" where the URL is that of the website to be retrieved. The file + http class are placed on a server in the UK (I am currently abroad and can't access many acceptable websites. By calling the file "test-http.php" , the webpage is retrieved - but retrieved fully with its links, thumbnails, javascripts, css, etc working + displayed normally as if I called them from the UK server.

I have tried to amend "test_http_image_request.php" - just added the line:-

$body = str_replace ('<img src="', '<img src="http://host_name/', $body);

just above the line:

echo $body;

That didn't work!

Is it possible to have a file similar to "test_http_image_request.php", for example: "http_page_request.php" ?

Thanks


  4. Re: HTTP Client + Proxy   Reply   Report abuse  
Picture of David Halliday David Halliday - 2007-02-09 06:03:47 - In reply to message 2 from Manuel Lemos
Thank you for the reply. I'll try to explain it briefly.

I want to write a script similar to the one in "test_http.php" and place both the file + the HTTP class on a server in the UK (I am currently abroad where I can't access websites that are otherwise perfectly acceptable). Then when the file is called, the website is retrieved - retrieved completely with its links, thumbnails, css, javascripts working + the page is displayed normally as if I call it from the UK.

The file "test_http.php" displays REQUEST + RESPONSE headers only. So I have tried to add a line of script to the file "test_http_image_request.php" just above : echo $body; , the line is as follows:

$body = str_replace ('<img src="', '<img src="http://host_name_here/', $body);

It didn't work. I was wondering if there is a file similar to "test_http_image_request.php", for example "http_PAGE_request.php" ?

Any help, suggestion or even pointing me in the right direction would be greatly appreciated. Regards, David

  5. Re: HTTP Client + Proxy   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2007-02-10 01:39:16 - In reply to message 4 from David Halliday
Your solution is a bit confusing. I think you need to build a script from scratch to do what you want, instead of using the existing examples.

The code to retrieve and display common Web pages is basically very similar to test_http_image_request.php . The only difference is that when you get a Web page, you need to process the HTML to alter the links, images, CSS URLs to make the request also go through your proxy script.

  6. Re: HTTP Client + Proxy   Reply   Report abuse  
Picture of David Halliday David Halliday - 2007-02-10 05:10:44 - In reply to message 5 from Manuel Lemos
Thank you for the answer. A great help to know that.
Best regards,

David