Skip to content

Commit

Permalink
Added support for GET variable passing in HTTP::Parser::BuildRequest()
Browse files Browse the repository at this point in the history
  • Loading branch information
Thulinma committed Nov 28, 2018
1 parent 952fd95 commit 5ae6962
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/http_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,14 @@ void HTTP::Parser::setCORSHeaders(){
/// To be precise, method, url, protocol, headers and body are used.
/// \return A string containing a valid HTTP 1.0 or 1.1 request, ready for sending.
std::string &HTTP::Parser::BuildRequest(){
/// \todo Include GET/POST variable parsing?
/// \todo Include POST variable handling for vars?
std::map<std::string, std::string>::iterator it;
if (protocol.size() < 5 || protocol[4] != '/'){protocol = "HTTP/1.0";}
builder = method + " " + url + " " + protocol + "\r\n";
if (method == "GET" && vars.size() && url.find('?') == std::string::npos){
builder = method + " " + url + allVars() + " " + protocol + "\r\n";
}else{
builder = method + " " + url + " " + protocol + "\r\n";
}
for (it = headers.begin(); it != headers.end(); it++){
if ((*it).first != "" && (*it).second != ""){
builder += (*it).first + ": " + (*it).second + "\r\n";
Expand Down

0 comments on commit 5ae6962

Please sign in to comment.