2017-11-28 17 views
0

curlppライブラリを使用してPUTリクエストを送信するにはどうすればよいですか?私はhttp POST(以下の例)やGETリクエストを送信する方法を見つけましたが、PUTリクエストには何も見つかりませんでした。CurlppとPUTリクエスト

curlpp::Cleanup cleaner; 
curlpp::Easy request; 

request.setOpt(new curlpp::options::Url(url)); 
curlpp::types::WriteFunctionFunctor functor(WriteMemoryCallback); 
curlpp::options::WriteFunction *test = new curlpp::options::WriteFunction(functor); 
request.setOpt(test); 

std::list<std::string> header; 
header.push_back("Content-Type: application/json"); 

request.setOpt(new curlpp::options::HttpHeader(header)); 
request.setOpt(new curlpp::options::PostFields(message)); 
request.perform(); 

答えて

1

私は正確に同じ質問を持っていたし、libcurlのを使用してそれを行うための方法を探していたときにSend string in PUT request with libcurlを参照して、解決策を見つけました。あなたは

request.setOpt(new curlpp::options::CustomRequest{"PUT"}); 

その他の必要なオプションを使用してPUTメソッドを指定する必要が

は、POSTメソッドへのと同じです。

関連する問題