I was deubgging some http requests and found that I can grab request headers in this type of format:
GET /download?123456:75b3c682a7c4db4cea19641b33bec446/document.docx HTTP/1.1
Host: www.site.com
User-Agent: Mozilla/5.0 Gecko/2010 Firefox/5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0开发者_运维技巧.7
Referer: http://www.site.com/dc/517870b8cc7
Cookie: lang=us; reg=1787081http%3A%2F%2Fwww.site.com%2Fdc%2F517870b8cc7
Is it possible or is there an easy way to reconstruct that request using wget or curl (or another CLI tool?)
From reading the wget manual page I know I can set several of these things individually, but is there an easier way to send a request with all these variables from the command line?
Yes, you just need to combine all the headers using --header
wget --header="User-Agent: Mozilla/5.0 Gecko/2010 Firefox/5" \
--header="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
--header="Accept-Language: en-us,en;q=0.5" \
--header="Accept-Encoding: gzip, deflate"
--header="Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" \
--header="Cookie: lang=us; reg=1787081http%3A%2F%2Fwww.site.com%2Fdc%2F517870b8cc7" \
--referer=http://www.site.com/dc/517870b8cc7
http://www.site.com/download?123456:75b3c682a7c4db4cea19641b33bec446/document.docx
If you are trying to do some illegal download,
it might fail,
is depends on how hosting URL being programmed
Here is curl
version:
curl http://www.example.com/download?123456:75b3c682a7c4db4cea19641b33bec446/document.docx \
-H "User-Agent: Mozilla/5.0 Gecko/2010 Firefox/5" \
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
-H "Accept-Language: en-us,en;q=0.5" \
-H "Accept-Encoding: gzip, deflate"
-H "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7" \
-H "Cookie: lang=us; reg=1787081http%3A%2F%2Fwww.site.com%2Fdc%2F517870b8cc7" \
-H "Referer: http://www.example.com/dc/517870b8cc7"
In Chrome developer tools, you can use Copy as cURL to catch request as curl
.
精彩评论