嘟嘟社区

关于 Curl Post后下载的问题


浏览器点击下载按钮后,会有个另存为提示,抓包发现带有content-disposition,确认后才开始下载,而使用Curl Post无法直接返回下载文件,问题出在哪呢?

curl -X POST https://www.xxx.jp/download_webp/middle_webp/2/ -H ‘Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8’ -H "Content-Type: application/x-www-form-urlencoded"  -H ‘Referer: https://www.xxx.jp/’ -H ‘User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0) Gecko/20100101 Firefox/6.0’ -o photo0000-0002.webp -d ‘{"filename":"photo0000-0002"}’

抓包:

HTTP/2 200 OK
server: nginx
date: Wed, 04 May 2022 16:12:10 GMT
content-type: image/webp
content-disposition: attachment; filename="photo0000-0002.webp"
X-Firefox-Spdy: h2

POST /download_webp/middle_webp/2/ HTTP/2
Host: www.xxx.jp
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://www.xxx.jp/detail/sea/2/
Content-Type: application/x-www-form-urlencoded
Content-Length: 23
Origin: https://www.xxx.jp
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: same-origin
Sec-Fetch-User: ?1
TE: trailers