From 84db1484054fdf0f5cf88db7dc4e4fb8ed2f906f Mon Sep 17 00:00:00 2001 From: Thulinma Date: Sun, 26 Aug 2012 21:19:48 +0200 Subject: [PATCH] Fix HTTP::Parser to no longer send empty headers. --- lib/http_parser.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/http_parser.cpp b/lib/http_parser.cpp index 9e8291a5..4bc1210f 100644 --- a/lib/http_parser.cpp +++ b/lib/http_parser.cpp @@ -30,7 +30,9 @@ std::string HTTP::Parser::BuildRequest(){ if (protocol.size() < 5 || protocol.substr(0, 4) != "HTTP"){protocol = "HTTP/1.0";} std::string tmp = method+" "+url+" "+protocol+"\n"; for (it=headers.begin(); it != headers.end(); it++){ - tmp += (*it).first + ": " + (*it).second + "\n"; + if ((*it).first != "" && (*it).second != ""){ + tmp += (*it).first + ": " + (*it).second + "\n"; + } } tmp += "\n" + body; return tmp; @@ -48,7 +50,9 @@ std::string HTTP::Parser::BuildResponse(std::string code, std::string message){ if (protocol.size() < 5 || protocol.substr(0, 4) != "HTTP"){protocol = "HTTP/1.0";} std::string tmp = protocol+" "+code+" "+message+"\n"; for (it=headers.begin(); it != headers.end(); it++){ - tmp += (*it).first + ": " + (*it).second + "\n"; + if ((*it).first != "" && (*it).second != ""){ + tmp += (*it).first + ": " + (*it).second + "\n"; + } } tmp += "\n"; tmp += body;