From 6a13b12a9bc79961dda05acd35f99e9dc9c3b04d Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Mon, 21 Jul 2014 17:22:13 +0200 Subject: [PATCH] Write all HTTP headers to the socket in one go. We don't have support for TCP_CORK, which would let the kernel handle this, so this resulted in lots of very small packets being sent over the network. Besides the performance issues, this confused aliceadsl.fr HTTP server and prevented logging in to their website. Fixes #10556. --- src/kits/network/libnetapi/HttpRequest.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/kits/network/libnetapi/HttpRequest.cpp b/src/kits/network/libnetapi/HttpRequest.cpp index 151f1577de..8aec11cd1b 100644 --- a/src/kits/network/libnetapi/HttpRequest.cpp +++ b/src/kits/network/libnetapi/HttpRequest.cpp @@ -914,14 +914,19 @@ BHttpRequest::_SendHeaders() } // Write output headers to output stream + BString headerData; + for (int32 headerIndex = 0; headerIndex < fOutputHeaders.CountHeaders(); headerIndex++) { const char* header = fOutputHeaders.HeaderAt(headerIndex).Header(); - fSocket->Write(header, strlen(header)); - fSocket->Write("\r\n", 2); + + headerData << header; + headerData << "\r\n"; _EmitDebug(B_URL_PROTOCOL_DEBUG_HEADER_OUT, "%s", header); } + + fSocket->Write(headerData.String(), headerData.Length()); }