How can I use curl to simulate a request from Firefox over a proxy?
Solution 1
I've done this through Firebug.
Once you've installed firebug, follow this steps:
- Right-click a webpage inside firefox and choose this option:
- Select
Net
tab
Refresh the page
Right-click the URL request you want to simulate
Choose
copy as cURL
- The URL request that you want to simulate is now in your clipboard.
Solution 2
You have to specify a proxy otherwise thing would not work, do like:
-
curl -x 127.0.0.1:8888 "httpS://www.example.com/"
— Be sure that you are trying to connect throught HTTPS, otherwise simple get will be sent. -
curl -p -x 127.0.0.1:8888 "http://www.example.com/"
— That thing will work even with ordinary HTTP resources.
Was hard to find any already existing topics on that subject except for this, so maybe I'm answering an already answered question.
merlin2011
I am a student. A perpetual student. For the convenience of those who Google and copy & paste resulting URL, feel free to try my plugins for Firefox and Chrome. I have recently released my primary project Arachne, a lightning-fast cooperative threading library. Please give it a whirl and create an issue if you see any problems. I have also written a few simple tools, such as one for tmux automation, an improved version of the venerable Unix column, and a tool for adding color to text in the terminal based on user-specified patterns.
Updated on June 05, 2022Comments
-
merlin2011 almost 2 years
In particular, I am attempting to replicate the behavior of firefox when I set it to use a proxy for https traffic.
From my tests, it appears that Firefox sends a CONNECT request to the proxy, while the following curl command directly sends GET to the proxy.
curl --proxy-basic mydomain.com:8001 https://www.google.com
How can I make curl behave like firefox for testing purposes with respect to the proxy for HTTPS connections?
EDIT1: The issue is not with the User-Agent, because I am not trying to fool the proxy into thinking I am firefox, only to help the proxy function the way it would with Firefox.
-
merlin2011 about 11 yearsI don't think it is just the USERAGENT problem. I am more concerned about lack of
CONNECT
. -
merlin2011 about 11 years@DanielStenberg, the proxy is not seeing the CONNECT though, with the command I gave in the question.
-
Daniel Stenberg about 11 yearsthe command in the question doesn't specify any proxy... see --proxy for that