跟進重定向時如何取得具有正確名稱的檔案? 其中答案說,
您可以透過
curl
、 使用、
curl -JLO ...
然而,我發現它並不適合所有情況,就像對該答案的評論一樣。此curl -JLO 'http://www.vim.org/scripts/download_script.php?src_id=9750'
方法適用於其他網址,但不適用於其他網址,儘管wget --content-disposition
效果很好。失敗日誌附在下面。
有解決方法/修復嗎?
$ curl -vJLO https://jmeter-plugins.org/get/
. . .
< HTTP/1.1 302
< Server: nginx/1.4.6 (Ubuntu)
< Date: Fri, 24 Jun 2022 20:24:57 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Powered-By: PHP/5.5.9-1ubuntu4.25
< Location: https://search.maven.org/remotecontent?filepath=kg/apc/jmeter-plugins-manager/1.7/jmeter-plugins-manager-1.7.jar
<
* Ignoring the response-body
. . .
* Issue another request to this URL: 'https://search.maven.org/remotecontent?filepath=kg/apc/jmeter-plugins-manager/1.7/jmeter-plugins-manager-1.7.jar'
. . .
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
} [5 bytes data]
* Using Stream ID: 1 (easy handle 0x7ffff39685c0)
} [5 bytes data]
> GET /remotecontent?filepath=kg/apc/jmeter-plugins-manager/1.7/jmeter-plugins-manager-1.7.jar HTTP/2
> Host: search.maven.org
> user-agent: curl/7.74.0
> accept: */*
. . .
> GET /maven2/kg/apc/jmeter-plugins-manager/1.7/jmeter-plugins-manager-1.7.jar HTTP/2
. . .
< content-type: application/java-archive
< last-modified: Mon, 20 Dec 2021 12:21:32 GMT
< x-checksum-md5: 5d625388a0fa18cc915dff7951dd1210
< x-checksum-sha1: 4fe37f9a091c35651177071f4bd442be85cbce0c
< via: 1.1 varnish, 1.1 varnish
< accept-ranges: bytes
< date: Fri, 24 Jun 2022 20:24:57 GMT
< age: 2093091
< x-served-by: cache-iad-kcgs7200079-IAD, cache-yyz4546-YYZ
< x-cache: HIT, HIT
< x-cache-hits: 1, 1
< x-timer: S1656102298.881078,VS0,VE2
< content-length: 906099
<
{ [1034 bytes data]
Warning: Remote filename has no length!
* Failure writing output to destination
} [5 bytes data]
* stopped the pause stream!
0 884k 0 1034 0 0 1659 0 0:09:06 --:--:-- 0:09:06 1659
* Connection #2 to host repo1.maven.org left intact
curl: (23) Failure writing output to destination