Chrome Feature: Copy as cURL
As an example, let’s consider a request to my site http://lornajane.net. I turn on the developer tools in Chrome, make the request, and check the “Network” tab. There I see requests for the page itself and also each of the assets. Right-click on any of the entries there, and you’ll see the option to copy the request as curl:
When you paste the contents of your clipboard onto the command line, you’ll see something like this:
curl 'http://lornajane.net/' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: www.lornajane.net' -H 'Accept-Language: en-GB,en-US;q=0.8,en;q=0.6' -H 'User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1535.3 Safari/537.36' --compressed
This shows all of the headers, switches and data that were sent when Chrome made this request, and now I’ve got it in this format I can of course edit any part of it that I please! I find it really useful when a particular request or endpoint is causing a problem just to be able to grab the single request and be able to replicate it on the command line very easily. I hope it helps you too – I’m sure the other browsers have equivalent tools so if you use an alternative way of doing the same thing, could you please add a comment and share it please? Thanks :)
Pingback: Chrome Feature: Copy as cURL | Advanced PHP | S...
I noticed this in firebug/firefox a few weeks ago too. Wasn’t aware that Chrome already had it!
Thanks, great tip. I will use it all the time too now.
Thanks for the helpful tip.
…. wow… that is awesome! I had no idea that was possible! Thanks a bunch, this’ll be really helpful! :-)
Thanks :)
thanks
Awesome tips. Thanks for sharing that with us.
Pingback: IT Nursery