Opened 6 years ago
Last modified 6 years ago
#12875 new Bugs
ip::tcp::iostream flush() doesn't clear the buffer. Neither does clear();
Reported by: | Owned by: | chris_kohlhoff | |
---|---|---|---|
Milestone: | To Be Determined | Component: | asio |
Version: | Boost 1.63.0 | Severity: | Problem |
Keywords: | tcp iostream flush clear | Cc: |
Description
Code something like the below shows the issue:
std::string postData = "This is my post data.";
ip::tcp::iostream stream;
stream.expires_from_now(boost::posix_time::seconds(10));
stream.connect("192.168.1.128", "http");
stream << "POST /myRestfulPath HTTP/1.1\r\n";
stream << "Content-Type: application/x-www-form-urlencoded\r\n";
stream << "Host: 192.168.1.128:8080\r\n";
stream << "Content-Length: " << postData.size() << "\r\n";
stream << "Connection: Close\r\n\r\n";
stream.flush();
stream << postData.c_str();
stream.flush();
Using Wireshark, the headers show up with the first flush, but also show up from the second, with the postData appended.
I understand that I do not need the first flush in this example. However, the server requires an "Expect: 100-Continue" so therefore I need to send before the postData, and then receive the "Continue", and then send the postData. (Not shown.)
stream.clear() doesn't clear what flush left behind, either.
Change History (2)
comment:1 by , 6 years ago
Component: | None → interprocess |
---|---|
Owner: | set to |
comment:2 by , 6 years ago
Component: | interprocess → asio |
---|---|
Owner: | changed from | to
Seems like an Asio problem to be. Re-assigning.