microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
8.02k stars 1.65k forks source link

Disable chunking or switch to HTTP 1.0 #175

Open DvoryankinEvgeny opened 8 years ago

DvoryankinEvgeny commented 8 years ago

Hello. I need to send some data to remote server which can't recieve chunked data. Can I switch cpprest http cleint to HTTP 1.0 or disable chunking when posting data? Data sending looks close to this:

concurrency::streams::file_stream<unsigned char>::open_istream(xmlPath).then(
    [&](pplx::task<concurrency::streams::basic_istream<unsigned char>> previousTask) {
        auto stream = previousTask.get(); 

        web::http::http_request req(web::http::methods::POST);
        req.set_body(stream, L"text/xml");

        web::http::client::http_client client(uri);
        client.request(req).then([&](web::http::http_response response) {})
    })

Thank you.

jhandley commented 7 years ago

Use the http_request::set_body overload that takes a content_length. Chunking is in your case because the length of the request body is unknown.