I'm trying to send a HTTP request to a server via boost asio. I have the following request that I have created in c++:
static const std::string TEMPLATE_HEADER =
"POST " + HTTP_PATH + " HTTP/1.1\r\n"
"Content-Type: application/json\r\n"
"Host: " + HOST_TAG + "\r\n"
"{ " + TEMPLATE_BODY + " }\r\n\r\n";
The actual request that i am sending on is this:
POST /eikon/authsession/machines/ HTTP/1.1 Content-Type: application/json Host: amers1.am.cp.icp2.mpp.ime.reuters.com:80 { "machineID" : "EP-03A482F1B88A","password" : "PasswordReset","takeESOControl" : "false","deviceID" : "123" }
This works when using Postman (a Google Chrome extension), but this doesn't seem to work using boost asio. I do the following (the above HTTP Request is strTemp.
// Write the request to the buffer
size_t request_length = strTemp.length();
boost::asio::write(s, boost::asio::buffer(strTemp, request_length));
char reply[max_length];
// When a reply is received ending in the correct tag we are looking for, store it in the response buffer
boost::asio::streambuf response;
boost::asio::read_until(s, response, Constants::BRACE_TAG);
Where the BRACE_TAG variable = "}" (as the response returned ends with a curly brace.
I get an exception come back that says "Exception: read_until: End of file".
Anyone have an idea what's happening?
Thanks.