14,959
edits
| Line 50: | Line 50: | ||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); | ||
</pre> | </pre> | ||
== How to resolve cUrl error (3) bad range in URL position xx == | |||
'''Problem''' | |||
When using curl to download URLs containing special characters (like `[]`), you may encounter this error: | |||
<pre> | |||
curl: (3) bad range in URL position 33 | |||
</pre> | |||
'''Solution''' | |||
Convert special characters to URL-encoded format: | |||
<pre> | |||
# Incorrect example | |||
curl "https://example.com/api?param[0]=value" | |||
# Correct example | |||
curl "https://example.com/api?param%5B0%5D=value" | |||
</pre> | |||
Common URL encoding references: | |||
* `[` becomes `%5B` | |||
* `]` becomes `%5D` | |||
* Space becomes `%20` | |||
'''Explanation''' | |||
* URL specifications require certain special characters to be encoded for use | |||
* Characters like `[]` have special meanings in URLs and can cause parsing errors if used directly | |||
* URL encoding ensures these special characters can be correctly transmitted and parsed | |||
If you're unsure whether encoding is needed, you can use an online URL encoder tool for conversion e.g. [https://www.urlencoder.org/ URL Encode and Decode - Online]. | |||
== How to resolve cUrl error (#5): Unsupported proxy syntax == | == How to resolve cUrl error (#5): Unsupported proxy syntax == | ||