: parser(parser), is_ssl(is_ssl),
local_endpoint(local_endpoint),
remote_endpoint(remote_endpoint),
- txbuf(*this)
+ txbuf(*this),
+ keepalive(parser.keep_alive()),
+ expect100continue(parser.get()[beast::http::field::expect] == "100-continue")
{
}
size_t ClientIO::send_status(int status, const char* status_name)
{
+ if (expect100continue && !sent100continue) {
+ // a client expecting 100-continue is not required to wait for the
+ // '100 Continue' response before sending the request body. if we
+ // complete the request before sending 100 Continue (for example, due
+ // to an authorization error), we don't know whether any following
+ // bytes on this connection correspond to this request's body or the
+ // next request's header. so we must disable keepalive and require the
+ // client to use a new tcp connection for any subsequent requests
+ keepalive = false;
+ }
+
static constexpr size_t STATUS_BUF_SIZE = 128;
char statusbuf[STATUS_BUF_SIZE];
sent += txbuf.sputn(timestr, strlen(timestr));
}
- if (parser.keep_alive()) {
+ if (keep_alive()) {
constexpr char CONN_KEEP_ALIVE[] = "Connection: Keep-Alive\r\n";
sent += txbuf.sputn(CONN_KEEP_ALIVE, sizeof(CONN_KEEP_ALIVE) - 1);
} else {
RGWEnv env;
rgw::io::StaticOutputBufferer<> txbuf;
+
+ bool keepalive = false;
+ bool expect100continue = false;
bool sent100continue = false;
public:
return env;
}
- bool sent_100_continue() const { return sent100continue; }
+ bool keep_alive() const { return keepalive; }
};
} // namespace asio
return;
}
- bool expect_continue = (message[http::field::expect] == "100-continue");
-
{
auto lock = pause_mutex.async_lock_shared(yield[ec]);
if (ec == boost::asio::error::operation_aborted) {
return;
}
- if (real_client.sent_100_continue()) {
- expect_continue = false;
+ if (!real_client.keep_alive()) {
+ return;
}
}
- if (!parser.keep_alive()) {
- return;
- }
-
// if we failed before reading the entire message, discard any remaining
// bytes before reading the next
- while (!expect_continue && !parser.is_done()) {
+ while (!parser.is_done()) {
static std::array<char, 1024*1024> discard_buffer;
auto& body = parser.get().body();