I have a question about performing a HTTP POST request with a JSON body. I use the following code which works like a charm:
Code: Select all
Net::HTTPRequest request(Net::HTTPRequest::HTTP_POST, path, Net::HTTPMessage::HTTP_1_1);
session.sendRequest(request) << jsonBody.str();
I have 2 questions:
First, is it possible to send a POST request with a JSON body without specifying the content length header ? I tried appending 0x0d 0x0a to the end of the body to indicate termination but it didn't work... (I realize it's not a POCO specific question but a more general HTTP question)
Second, if it's not possible to avoid specifying the content-length header, is the above code correct? It seems a bit awkward to me.