Troubleshooting of curl errors: Difference between revisions
Jump to navigation
Jump to search
+ How to resolve the downloaded file was empty
(How to rseolve cURL returns binary data instead of html or json) |
(+ How to resolve the downloaded file was empty) |
||
| Line 56: | Line 56: | ||
* [https://stackoverflow.com/questions/28283822/curl-returns-binary-data-instead-of-html php - cURL returns binary data instead of html - Stack Overflow] | * [https://stackoverflow.com/questions/28283822/curl-returns-binary-data-instead-of-html php - cURL returns binary data instead of html - Stack Overflow] | ||
* [https://errerrors.blogspot.com/2020/06/resolve-curl-returns-binary-data-instead-of-html-or-json.html 解決 cUrl 下載的網頁或 JSON 看起來像是亂碼的問題] | * [https://errerrors.blogspot.com/2020/06/resolve-curl-returns-binary-data-instead-of-html-or-json.html 解決 cUrl 下載的網頁或 JSON 看起來像是亂碼的問題] | ||
== How to resolve the downloaded file was empty == | |||
Error condition | |||
* When I executed the Curl command {{kbd | key=<nowiki>curl -O https://path/to/plain_text.txt</nowiki>}}, but the downloaded file was empty. | |||
Solution | |||
* After I enabled [https://ec.haxx.se/usingcurl/usingcurl-verbose verbose] option, I found the HTTP status code {{kbd | key=HTTP/1.1 302 Moved Temporarily}}. I added the location ([https://curl.haxx.se/docs/manpage.html#-L -L]) parameter to resolve the downloaded file was empty: {{kbd | key=<nowiki>curl -L -O https://path/to/plain_text.txt</nowiki>}}, | |||
<pre> | |||
The truncated result after executed the command: curl -v -O https://path/to/plain_text.txt | |||
< HTTP/1.1 302 Moved Temporarily | |||
< Server: nginx | |||
< Date: Tue, 25 Aug 2020 03:45:13 GMT | |||
< Content-Type: text/html | |||
< Transfer-Encoding: chunked | |||
< Connection: keep-alive | |||
< Keep-Alive: timeout=60 | |||
< Location: /path/to/plain_text.txt | |||
</pre> | |||
== References == | == References == | ||