Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use curl to simulate a request from Firefox over a proxy?

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.

like image 688
merlin2011 Avatar asked Oct 16 '25 15:10

merlin2011


2 Answers

I've done this through Firebug.

Once you've installed firebug, follow this steps:

  1. Right-click a webpage inside firefox and choose this option:

enter image description here

  1. Select Net tab

enter image description here

  1. Refresh the page

  2. Right-click the URL request you want to simulate

  3. Choose copy as cURL

enter image description here

  1. The URL request that you want to simulate is now in your clipboard.
like image 59
e19293001 Avatar answered Oct 18 '25 07:10

e19293001


You have to specify a proxy otherwise thing would not work, do like:

  1. 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.
  2. 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.

like image 24
cassandrad Avatar answered Oct 18 '25 07:10

cassandrad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!