c++ - Boost asio read_until exception end of file? -
i'm trying send http request server via boost asio. have following request 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 sending on 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), doesn't seem work using boost asio. following (the above http request strtemp.
// write request buffer size_t request_length = strtemp.length(); boost::asio::write(s, boost::asio::buffer(strtemp, request_length)); char reply[max_length]; // when reply received ending in correct tag looking for, store in response buffer boost::asio::streambuf response; boost::asio::read_until(s, response, constants::brace_tag);
where brace_tag variable = "}" (as response returned ends curly brace.
i exception come says "exception: read_until: end of file".
anyone have idea what's happening?
thanks.
between headers , body there should double newline:
"host: " + host_tag + "\r\n\r\n"
you might required send content-length header (what's "content-length" field in http header?). postman might add you
Comments
Post a Comment