Using Copy as cURL from Chrome on a Windows Command Prompt

So, Google Chrome is a great โ€œcopy as cURLโ€ option in the Network section of Chrome DevTools. Works great on the command line for Linux, but not on windows. This seems to have something to do with single quotes as I get the error

http protocol is not supported

In other words, its reading a single quote. Is there an easy way to make this formatable for Windows? I tried replacing all single quotes with double quotes, but then nothing happens at all.

Command: curl ' http://www.test.com/login/ ' -H 'Cookie: PHPSESSID = 7dvb25maaaaaa9d7bbbbc3f6' -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, e.g. 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

thanks

+4
source share
3 answers

It works as expected if you use Cygwin

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

To create a script in cygwin:

Open cygwin terminal

  • type nano file.sh
  • paste (shift + insert) the cattle that you copied earlier, then press the control button + O, then enter
  • type chmod + x file.sh
  • type bash file.sh to run the package.
+1
source

Are you sure this is Chrome?

Since Chrome, at least on v35, uses double quotes for it. Copy as a function of cURL.

Firefox, on the other hand, uses "single quotes."

If you are searching / replacing single quotes for double quotes in the whole team, they should work as expected.

eg. you need:

curl "http://www.test.com/login/" etc.

0
source

Spend some time shooting. What Chrome gave me does not work in the Windows command line shell. However, if I did "Copy as cURL" on my Mac and used this exact command on Windows, it really worked.

0
source

Source: https://habr.com/ru/post/1497366/


All Articles