C++のlibcurlが奇妙な記号に与えられたURLを変更していることに気付きました。ここでは、コードです:C++のlibcurl:URLを奇妙な記号に変換する
私は、コンソールに何を得るのですcurl_global_init(CURL_GLOBAL_ALL);
curl_handle = curl_easy_init();
cout << "http://subdomain.mydomain.com/folder/check.php?key=" + key << endl;
curl_easy_setopt(curl_handle, CURLOPT_URL, "http://subdomain.mydomain.com/folder/check.php?key=" + addon_key);
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, &writeCallback);
curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl_handle);
:
http://subdomain.mydomain.com/folder/check.php?key=tasdasm34234k23l423m4234mn23n4jk23bjk4b23nasdasdasdasdsdsd
* Rebuilt URL to: � ��g/
* IDN support not present, can't parse Unicode domains
* getaddrinfo(3) failed for � ��g:80
* Couldn't resolve host '� ��g'
* Closing connection 0
私はWindowsで私のプロジェクトをビルドする際にこのコードは完全に正常に動作しますが、私は、Linuxでそれを構築する場合、この問題が発生しました。このコードで "http://subdomain.mydomain.com/folder/check.php"にアクセスしようとすると動作しますが、キーを追加するとすぐにlibcurlがURL全体を変更します。
ありがとうございます。
'addon_key'とは何ですか?そのタイプは何ですか?あなたは、ライブラリがC++オブジェクト( 'std :: string'など)について何も知らないC関数を持つCライブラリであることを知っていますか? –
これはstd :: string型です。 – Alex
あなたの文字列のように見えますが、ヌルターミネーターがありません – deW1