Troubleshooting of curl errors: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
mNo edit summary
Line 5: Line 5:
: [[Image:Owl icon.jpg]] How to debug the cUrl command: (1) Enable the [https://ec.haxx.se/usingcurl/verbose verbose] option e.g. "... run the command with the {{kbd | key=<nowiki>-v</nowiki>}} / {{kbd | key=<nowiki>--verbose</nowiki>}} option to get more information." or (2) Enable the [https://ec.haxx.se/usingcurl/verbose/trace trace options] e.g. {{kbd | key=<nowiki>--trace-ascii [filename]</nowiki>}} Note: trace options will be override by verbose option if enable both options.
: [[Image:Owl icon.jpg]] How to debug the cUrl command: (1) Enable the [https://ec.haxx.se/usingcurl/verbose verbose] option e.g. "... run the command with the {{kbd | key=<nowiki>-v</nowiki>}} / {{kbd | key=<nowiki>--verbose</nowiki>}} option to get more information." or (2) Enable the [https://ec.haxx.se/usingcurl/verbose/trace trace options] e.g. {{kbd | key=<nowiki>--trace-ascii [filename]</nowiki>}} Note: trace options will be override by verbose option if enable both options.


== How to resolve cURL Binary Output Warning ==
When executing a cURL command, you might encounter this warning message:
<pre>
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
</pre>
To resolve this warning, append the {{kbd | key=<nowiki>--output</nowiki>}} flag to your cURL command:
* To save the output to a file: {{kbd | key=<nowiki>--output filename.ext</nowiki>}}
* To force output to terminal: {{kbd | key=<nowiki>--output -</nowiki>}}
Example:
<pre>
curl https://example.com/binary-file --output output.file
</pre>


== How to resolve Command Execution: Works in DOS/Terminal but Not in PHP ==
== How to resolve Command Execution: Works in DOS/Terminal but Not in PHP ==
Line 42: Line 25:
<pre>
<pre>
curl "https://www.example.com/path/to/resource/" -H "authority: www.example.com" -H "accept: text/html" --data-raw "PARAMS" > output.html
curl "https://www.example.com/path/to/resource/" -H "authority: www.example.com" -H "accept: text/html" --data-raw "PARAMS" > output.html
</pre>
== How to resolve cURL Binary Output Warning ==
When executing a cURL command, you might encounter this warning message:
<pre>
Warning: Binary output can mess up your terminal. Use "--output -" to tell
Warning: curl to output it to your terminal anyway, or consider "--output
Warning: <FILE>" to save to a file.
</pre>
To resolve this warning, append the {{kbd | key=<nowiki>--output</nowiki>}} flag to your cURL command:
* To save the output to a file: {{kbd | key=<nowiki>--output filename.ext</nowiki>}}
* To force output to terminal: {{kbd | key=<nowiki>--output -</nowiki>}}
Example:
<pre>
curl https://example.com/binary-file --output output.file
</pre>
</pre>


Navigation menu