Using PHP cURL with an HTTP Debugging Proxy

Posted by Kane on Stack Overflow See other posts from Stack Overflow or by Kane
Published on 2009-10-31T19:37:13Z Indexed on 2010/06/06 3:02 UTC
Read the original article Hit count: 466

Filed under:
|
|
|
|

I'm using the app "Fiddler" to debug a GET attempt to a website via PHP cURL. In order to see the cURL traffic I had to specify that the cURL connection use the Fiddler proxy (see code below).

$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, '127.0.0.1:8888'); 

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header');  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_REFERER, "http://domain.com");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
curl_setopt($ch, CURLOPT_URL, "http://domain.com");

$response = curl_exec($ch);

But the problem is that in Fiddler I can only see this:

Request (domain.com is just an alias):

  CONNECT domain.com:80 HTTP/1.1

Response:

  HTTP/1.1 200 Blind-Connection Established

If I manually load the website in a browser Fiddler gives me WAY more information. I can see the cookies, the header information, and what I'm receiving via the GET.

Any ideas why Fiddler can't see more useful information from PHP cURL?

Edit: I tried turning on the "Enable HTTPS Decryption" option inside Tools / Fiddler Options / HTTPS (which I'm not sure why I'd need to use as I didn't tell cURL to use HTTPS).

Unfortunately, by changing this setting I now get a Response of:

HTTP/1.1 502 Connection failed

Edit: If it helps, the app "Charles" shows me WAY more information than Fiddler, but I really want to figure out Fiddler since I like it better.

© Stack Overflow or respective owner

Related posts about php

Related posts about http