@@ -354,19 +354,19 @@ namespace web { namespace http
354
354
}
355
355
request_stream << " :" << port << CRLF;
356
356
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 ;
359
359
360
360
// Check user specified transfer-encoding.
361
361
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" )
363
363
{
364
364
ctx->m_needChunked = true ;
365
365
}
366
366
367
367
bool has_body;
368
368
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 ))
370
370
{
371
371
// Have request body if content length header field is non-zero.
372
372
has_body = (0 != ctx->m_known_size );
@@ -378,12 +378,14 @@ namespace web { namespace http
378
378
{
379
379
has_body = true ;
380
380
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);
382
383
}
383
384
else
384
385
{
385
386
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);
387
389
}
388
390
}
389
391
@@ -392,10 +394,10 @@ namespace web { namespace http
392
394
return ;
393
395
}
394
396
395
- request_stream << flatten_http_headers (headers);
397
+ request_stream << flatten_http_headers (ctx->m_request .headers ());
398
+ request_stream << extra_headers;
396
399
// 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;
399
401
400
402
ctx->set_timer (static_cast <int >(client_config ().timeout ().count ()));
401
403
0 commit comments