curl-and-php
http proxy works, socks proxy doesn't... help! :)
Date: Thu, 25 Mar 2004 11:26:03 -0800
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dear all,
System: Win2k
PHP: 5.0.0b4
Curl: libcurl/7.10.8 OpenSSL/0.9.7c
Having great trouble using PHP5/Curl to pull requests through SOCKS proxy.
Requests pulled through HTTP proxy work fine. The error returned consistantly
is "Empty reply from server". I am running a local proxy service 'spoonproxy',
on a Win2k dev machine.
A failed request (SOCKS proxy over port 1080) looks something like this
(with a print_r of the $ch curl handle).
- --------------------------------
START EXAMPLE: FAILED REQUEST
* About to connect() to localhost:1080
* Connected to server (127.0.0.1) port 1080
> GET http://localhost/ HTTP/1.1
[...]
* Empty reply from server
* Connection #0 left intact
Error number: 52
Error message: Empty reply from server
Result: 0 bytes
Array
(
[url] => http://localhost/
[http_code] => 0
[header_size] => 0
[request_size] => 187
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.356
[namelookup_time] => 0.188
[connect_time] => 0.222
[pretransfer_time] => 0.349
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0.356
[redirect_time] => 0
)
* Closing connection #0
END EXAMPLE
- --------------------------------
A successful attempt looks something like this (HTTP proxy over port
8080 - everything exactly the same, just using port 8080 instead of 1080).
- --------------------------------
START EXAMPLE: SUCCESSFUL REQUEST
* About to connect() to localhost:8080
* Connected to server (127.0.0.1) port 8080
> GET http://localhost/ HTTP/1.1
[...]
* Connection #0 left intact
Error number: 0
Error message:
Result: 208 bytes
<h1>Apache/1.3.29 (Win32)</h1>
Hello World!
Array
(
[url] => http://localhost/
[content_type] => text/html
[http_code] => 200
[header_size] => 167
[request_size] => 187
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.69
[namelookup_time] => 0.161
[connect_time] => 0.194
[pretransfer_time] => 0.322
[size_upload] => 0
[size_download] => 208
[speed_download] => 301.44927536232
[speed_upload] => 0
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 0.602
[redirect_time] => 0
)
* Closing connection #0
END EXAMPLE
- --------------------------------
The code I am using for this demo is:
<?php
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, "http://localhost/");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt ($ch, CURLOPT_PROXY, "localhost:1080");
$result = curl_exec($ch);
echo "Error number: ".curl_errno($ch)."\n";
echo "Error message: ".curl_error($ch)."\n";
echo "Result: ".strlen($result)." bytes\n";
echo $result;
print_r(curl_getinfo($ch));
?>
Where the CURLOPT_PROXY is being toggled between 1080 (SOCKS) and 8080
(HTTP).
Any ideas on what I am doing wrong?
Thanks!
Andy
-----BEGIN PGP SIGNATURE-----
Note: This signature can be verified at https://www.hushtools.com/verify
Version: Hush 2.3
wkYEARECAAYFAkBjMsgACgkQYnnulhUXRRponwCff51TUtGay2ry/FT2l4eoyB+BMm8A
n0D8WLZchpGtiMZ2/fQPPumQpT/M
=NXC2
-----END PGP SIGNATURE-----
Concerned about your privacy? Follow this link to get
FREE encrypted email: https://www.hushmail.com/?l=2
Free, ultra-private instant messaging with Hush Messenger
https://www.hushmail.com/services.php?subloc=messenger&l=434
Promote security and make money with the Hushmail Affiliate Program:
https://www.hushmail.com/about.php?subloc=affiliate&l=427
Received on 2004-03-25