Skip to content

Commit

Permalink
rgw: fix issue with keep-alive and no content length in civetweb.
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Zarzynski <[email protected]>
  • Loading branch information
rzarzynski committed Aug 23, 2015
1 parent 6a82ad5 commit bd2346b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/civetweb
7 changes: 7 additions & 0 deletions src/rgw/rgw_civetweb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ int RGWMongoose::write_data(const char *buf, int len)
RGWMongoose::RGWMongoose(mg_connection *_conn, int _port)
: conn(_conn),
port(_port),
has_content_length(false),
explicit_keepalive(false),
explicit_conn_close(false)
{
Expand Down Expand Up @@ -124,6 +125,10 @@ int RGWMongoose::send_100_continue()

int RGWMongoose::complete_header()
{
if (!has_content_length) {
mg_enforce_close(conn);
}

string str;
if (explicit_keepalive) {
str = "Connection: Keep-Alive\r\n";
Expand All @@ -138,6 +143,8 @@ int RGWMongoose::complete_header()

int RGWMongoose::send_content_length(uint64_t len)
{
has_content_length = true;

char buf[21];
snprintf(buf, sizeof(buf), "%" PRIu64, len);
return print("Content-Length: %s\r\n", buf);
Expand Down
1 change: 1 addition & 0 deletions src/rgw/rgw_civetweb.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class RGWMongoose : public RGWClientIO

int port;

bool has_content_length;
bool explicit_keepalive;
bool explicit_conn_close;

Expand Down

0 comments on commit bd2346b

Please sign in to comment.