8

I opened https://raw.githubusercontent.com/andreafrancia/trash-cli/master/README.rst in Firefox, and copy the following curl command from Tools->Web Developer->Network:

curl 'https://raw.githubusercontent.com/andreafrancia/trash-cli/master/README.rst' -H 'Host: raw.githubusercontent.com' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-GB,en;q=0.5' --compressed -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'If-None-Match: "6931c3b4d0e94743bb93a36ed8e8c3f5add12f9a"' -H 'Cache-Control: max-age=0' 

When I run it in lxterminal, it doesn't download anything, even if I add -O to it. I was wondering why it doesn't download, and how I can make it download the file?

Thanks.

  • 2
    You should be aware that the curl command you get from Firefox might contain session cookies and that it can be used to impersonate you. Anyway, this one is safe because the github cookies are decoupled from the assets server. – Jules Lamur May 22 '18 at 19:42
  • Thanks. I was wondering what " impersonate" and "the github cookies are decoupled from the assets server" mean. – Tim May 22 '18 at 19:47
  • 1
    I meant that if you send a curl command to someone, they could use your session (eg. github account) as if they were you. – Jules Lamur May 22 '18 at 19:50
  • what do you suggest to do instead? – Tim May 22 '18 at 19:52
  • 2
    To not send the content of commands to anyone (or to redact cookies from commands). – Jules Lamur May 22 '18 at 19:54
26

When debugging curl issues, the -v option is often helpful. In this particular instance, you’re running afoul of the If-None-Match header, which tells the server that you already have the file matching “6931c3b4d0e94743bb93a36ed8e8c3f5add12f9a” and that you’re not interested in retrieving it again if it hasn’t changed. -v shows you this by indicating that the server responds with a 304 header:

< HTTP/1.1 304 Not Modified

To download your file, drop the header:

curl 'https://raw.githubusercontent.com/andreafrancia/trash-cli/master/README.rst' -H 'Host: raw.githubusercontent.com' -H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' -H 'Accept-Language: en-GB,en;q=0.5' --compressed -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'Cache-Control: max-age=0'

In this particular instance you’ll get the same result with

curl 'https://raw.githubusercontent.com/andreafrancia/trash-cli/master/README.rst'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.