คำขอ Curlpp และ PUT

จะส่งคำขอ PUT โดยใช้ไลบรารี curlpp ได้อย่างไร ฉันพบวิธีส่ง http POST (ตัวอย่างด้านล่าง) หรือคำขอ GET แต่ไม่มีอะไรสำหรับคำขอ 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(); 

person parzival    schedule 28.11.2017    source แหล่งที่มา


คำตอบ (1)


ฉันมีคำถามเดียวกันทุกประการและพบวิธีแก้ไขเมื่อค้นหาวิธีใช้ libcurl ดู ส่งสตริงในคำขอ PUT ด้วย libcurl

คุณต้องระบุวิธี PUT ด้วย

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

ตัวเลือกที่จำเป็นอื่นๆ จะเหมือนกับวิธี POST

person Artalizian    schedule 10.01.2018