I used a translator because I couldn't speak English. So the way you talk will be weird. Please understand.
- I read the link from the large mail and created a program to download files from the mail server using libcurl. But some url can't be downloaded. When I looked it up on Google, it was a problem that occurs when some characters are included in url, and as a solution, I found an answer to try wrapping it around " (quotation marks) when entering the curl command. In fact, when I wrapped the url in quotes and entered the command, the download proceeded normally.
My question here is to tell me how to see the effect of wrapping url in quotes in the command curl when setting (CURLOPT_URL, url) in libcurl. For your information, I'm using go-curl (libcurl wrapped in Golang).
- When downloading a file using the above program, there is a problem that the file name is not displayed properly when downloading the file name in Korean.
Even if I request to download the file by setting it as below, the file name is still not displayed properly. Is there any other way? easy.Setopt(curl.OPT_HTTPHEADER, []string{"Accept-Charset: utf-8"})
CodePudding user response:
There is no need to wrap something with quotes when using libcurl. The reason you have to use quotes with curl is because of shell expansion. This only applies to using curl from the command line; it does not apply to libcurl.
For example, when I use curl from the command-line, I have to use quotes around the parameter to the -H
option:
$ curl -H "Accept-Charset: utf-8" http://localhost:8080/
This is needed in order to prevent the shell from splitting Accept-Charset: utf-8
into two separate arguments. However, this is not necessary with libcurl.
When downloading a file using the above program, there is a problem that the file name is not displayed properly when downloading the file name in Korean.
Curl will get the filename from the URL or from the Content-Disposition header, depending on how curl is invoked. You may want to inspect the headers and URL to see where the correct filename is (is it in the URL? is it in the HTTP headers?) and figure out what encoding it uses.