Skip to content

Commit 0aed1db

Browse files
author
Valtteri Heikkila
committed
Replaced request headers copy with local-built header strings in linux_client::send_request().
1 parent 1611feb commit 0aed1db

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Release/src/http/client/http_linux.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -354,19 +354,19 @@ namespace web { namespace http
354354
}
355355
request_stream << ":" << port << CRLF;
356356

357-
// Copy headers to keep the original request state intact.
358-
auto headers(ctx->m_request.headers());
357+
// Extra request headers are constructed here.
358+
utility::string_t extra_headers;
359359

360360
// Check user specified transfer-encoding.
361361
std::string transferencoding;
362-
if (headers.match(header_names::transfer_encoding, transferencoding) && transferencoding == "chunked")
362+
if (ctx->m_request.headers().match(header_names::transfer_encoding, transferencoding) && transferencoding == "chunked")
363363
{
364364
ctx->m_needChunked = true;
365365
}
366366

367367
bool has_body;
368368

369-
if (headers.match(header_names::content_length, ctx->m_known_size))
369+
if (ctx->m_request.headers().match(header_names::content_length, ctx->m_known_size))
370370
{
371371
// Have request body if content length header field is non-zero.
372372
has_body = (0 != ctx->m_known_size);
@@ -378,12 +378,14 @@ namespace web { namespace http
378378
{
379379
has_body = true;
380380
ctx->m_needChunked = true;
381-
headers[header_names::transfer_encoding] = U("chunked");
381+
extra_headers.append(header_names::transfer_encoding);
382+
extra_headers.append(":chunked" + CRLF);
382383
}
383384
else
384385
{
385386
has_body = false;
386-
headers[header_names::content_length] = U("0");
387+
extra_headers.append(header_names::content_length);
388+
extra_headers.append(":0" + CRLF);
387389
}
388390
}
389391

@@ -392,10 +394,10 @@ namespace web { namespace http
392394
return;
393395
}
394396

395-
request_stream << flatten_http_headers(headers);
397+
request_stream << flatten_http_headers(ctx->m_request.headers());
398+
request_stream << extra_headers;
396399
// Enforce HTTP connection keep alive (even for the old HTTP/1.0 protocol).
397-
request_stream << "Connection: Keep-Alive" << CRLF;
398-
request_stream << CRLF;
400+
request_stream << "Connection: Keep-Alive" << CRLF << CRLF;
399401

400402
ctx->set_timer(static_cast<int>(client_config().timeout().count()));
401403

0 commit comments

Comments
 (0)