Skip to content

Commit

Permalink
Merge pull request #5284: rgw: Properly respond to the Connection hea…
Browse files Browse the repository at this point in the history
…der with Civetweb

Reviewed-by:
  • Loading branch information
ldachary committed Jul 29, 2015
2 parents 6d7fbff + 2357b6c commit 458b75a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/rgw/rgw_civetweb.cc
Expand Up @@ -28,7 +28,7 @@ int RGWMongoose::write_data(const char *buf, int len)
}

RGWMongoose::RGWMongoose(mg_connection *_conn, int _port) : conn(_conn), port(_port), header_done(false), sent_header(false), has_content_length(false),
explicit_keepalive(false)
explicit_keepalive(false), explicit_conn_close(false)
{
}

Expand Down Expand Up @@ -93,6 +93,7 @@ void RGWMongoose::init_env(CephContext *cct)

if (strcasecmp(header->name, "connection") == 0) {
explicit_keepalive = (strcasecmp(header->value, "keep-alive") == 0);
explicit_conn_close = (strcasecmp(header->value, "close") == 0);
}

int len = strlen(header->name) + 5; /* HTTP_ prepended */
Expand Down Expand Up @@ -162,6 +163,8 @@ int RGWMongoose::complete_header()

if (explicit_keepalive)
header_data.append("Connection: Keep-Alive\r\n");
else if (explicit_conn_close)
header_data.append("Connection: close\r\n");

header_data.append("\r\n");

Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_civetweb.h
Expand Up @@ -23,6 +23,7 @@ class RGWMongoose : public RGWClientIO
bool sent_header;
bool has_content_length;
bool explicit_keepalive;
bool explicit_conn_close;

public:
void init_env(CephContext *cct);
Expand Down

0 comments on commit 458b75a

Please sign in to comment.