Fix HTTP::Parser to no longer send empty headers.
This commit is contained in:
parent
516c8bf091
commit
84db148405
1 changed files with 6 additions and 2 deletions
|
@ -30,8 +30,10 @@ 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++){
|
||||
if ((*it).first != "" && (*it).second != ""){
|
||||
tmp += (*it).first + ": " + (*it).second + "\n";
|
||||
}
|
||||
}
|
||||
tmp += "\n" + body;
|
||||
return tmp;
|
||||
}
|
||||
|
@ -48,8 +50,10 @@ 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++){
|
||||
if ((*it).first != "" && (*it).second != ""){
|
||||
tmp += (*it).first + ": " + (*it).second + "\n";
|
||||
}
|
||||
}
|
||||
tmp += "\n";
|
||||
tmp += body;
|
||||
return tmp;
|
||||
|
|
Loading…
Add table
Reference in a new issue