Copy network call as cURL in chrome
Some times we try to see how some sites make call to servers to fetch data & we want to simulate to it from other clients e.g. cURL, other http request clients.
So here is little help for developers to copy any network request executed through chrome.
To do this just open developer console of chrome (Menu->More Tools->Developer Tools)
& goto to Network Tab
I am loading freeios8.com , you can see all resources are fetched from server and you can see each network call in network tab as shown below.
After loading website you can select & right click on any network call , It will provide you copying current network call in various formats. e.g. I am selecting here Copy as cURL option, refer below screen shot.
When you copy this call It will be available in clipboard.
You can paste it on command prompt/terminal & get same response as browser from respective servers.
Below is sample copied content with 'Copy as cURL' option.
curl 'http://freeios8.com/' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Connection: keep-alive' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Referer: https://www.google.co.in/' -H 'Accept-Language: en-US,en;q=0.8,hi;q=0.6,da;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36' --compressed
Note : To execute curl command make sure you have curl utility already installed on your system.