Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

I trying to use cpp-netlib(0.11.1) as HTTP client I need to send binary data (zlib data) to my server. I write the follow function

bool HttpPost(string a_ServerURL, string a_URLPramters, vector<char> a_pBufferToSend, string& a_Response)
{
    bool bRet = true;

    typedef http::basic_client< http::tags::http_default_8bit_tcp_resolve, 1, 1> httpClient;
    boost::network::uri::uri l_URL(a_ServerURL + a_URLPramters);
    httpClient l_Client;
    httpClient::request l_Request;
    httpClient::response l_Response;
    char* l_PostData = &a_pBufferToSend[0];
    size_t l_PostDataSize = a_pBufferToSend.size();


    string l_Data = string(l_PostData, a_pBufferToSend.size());

    l_Request.uri(l_URL);
    l_Request.add_header(make_pair("Connection", "close"));
    l_Request.add_header(make_pair("Content-Type", "application/x-www-form-urlencoded"));
    l_Request.add_header(make_pair("Content - Length", std::to_string(a_pBufferToSend.size())));

    l_Request.body(l_Data);

    l_Response = l_Client.post(l_Request);
    a_Response = l_Response.body();





    return bRet;
} 

The server result said the the zlib buffer is corrupted How I can send binary data using cpp-netlib? Thanks in advance

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.