Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using 'Copy as cURL' from Chrome in windows command line

So, Google Chrome as this great 'copy as cURL' option under 'Network' of the Chrome DevTools. Works great in command lines for linux but not in windows. Apparently it has something to do with the single quotes as the error I get is

protocol 'http not supported

In other words its reading that single quote. Is there a simple way to make this formatable for windows? I tried replacing all the single quotes with double quotes but then nothing happens at all.

The command is:

curl 'http://www.test.com/login/' -H 'Cookie: PHPSESSID=7dvb25maaaaaa9d7bbbbbc3f6' -H 'Origin: http://www.test.com' -H 'Accept-Encoding: gzip,deflate,sdch' -H 'Host: www.test.com' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Cache-Control: max-age=0' -H 'Referer: http://www.test.com/login/' -H 'Connection: keep-alive' --data 'loc=&login=user%40test.com&password=password&submit1=Sign+In' --compressed 
like image 611
user2029890 Avatar asked Nov 12 '22 23:11

user2029890


1 Answers

It works as expected if you use Cygwin

Personally, I use the mintty terminal from cygwin which works great compared to the command prompt that comes with windows.

To create a script in cygwin:

Open cygwin terminal

  • type nano file.sh
  • paste (shift+insert) the curl you copied earlier, then press control+O then enter
  • type chmod +x file.sh
  • type bash file.sh to run the batch.
like image 154
davvs Avatar answered Nov 15 '22 05:11

davvs