开发者

Using PHP cURL with an HTTP Debugging Proxy

开发者 https://www.devze.com 2022-12-10 02:53 出处:网络
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).

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.


"Blind-Connection Established" suggests that you haven't turned on the "Enable HTTPS Decryption" option inside Tools / Fiddler Options / HTTPS.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号