Merge pull request #6403 from Icinga/fix/http-request-crlf

Conform to RFC for CRLF in HTTP requests
This commit is contained in:
Michael Friedrich 2018-06-21 17:08:16 +02:00 committed by GitHub
commit a4784d1b17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -194,7 +194,7 @@ void HttpRequest::AddHeader(const String& key, const String& value)
void HttpRequest::FinishHeaders()
{
if (m_State == HttpRequestStart) {
String rqline = RequestMethod + " " + RequestUrl->Format(true) + " HTTP/1." + (ProtocolVersion == HttpVersion10 ? "0" : "1") + "\n";
String rqline = RequestMethod + " " + RequestUrl->Format(true) + " HTTP/1." + (ProtocolVersion == HttpVersion10 ? "0" : "1") + "\r\n";
m_Stream->Write(rqline.CStr(), rqline.GetLength());
m_State = HttpRequestHeaders;
}
@ -211,11 +211,11 @@ void HttpRequest::FinishHeaders()
ObjectLock olock(Headers);
for (const Dictionary::Pair& kv : Headers)
{
String header = kv.first + ": " + kv.second + "\n";
String header = kv.first + ": " + kv.second + "\r\n";
m_Stream->Write(header.CStr(), header.GetLength());
}
m_Stream->Write("\n", 1);
m_Stream->Write("\r\n", 2);
m_State = HttpRequestBody;
}