I’m fetching a URL but that’s filtered in some countries. I was looking for a way to configure cURL to use client proxy.
I mean proxy that has been set in browser or connection.
Any other solution is appreciated that could solve the problem and determine if website is filtered or not.
For libcurl, use CURLOPT_PROXY:
http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTPROXY
For the curl command line tool, use option –proxy host:port.
Both the library and the command line tool respect the environment variables http_proxy, ftp_proxy, all_proxy, so that’s another option.
Edit:
If you want to use the client’s proxy on the server – this won’t work reliably.
First, you would need to determine client’s proxy settings via javascript – which might work.
Second, you would need to use that proxy to make a request on the server – this will certainly not work reliably, as the client’s proxy might be in a local network (not accessible from outside), require authentication etc.
An option would be to make a client request via JavaScript (AJAX) and verify the result – which is a somewhat questionable approach, as you are making requests from your client’s computers to possibly blocked (illegal?) sites. Better don’t do that.