From 5ae6962233fdeb436b7b248da98f505e72177104 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Wed, 28 Nov 2018 16:24:08 +0100 Subject: [PATCH] Added support for GET variable passing in HTTP::Parser::BuildRequest() --- 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 c472a8d3..7299e90c 100644 --- a/lib/http_parser.cpp +++ b/lib/http_parser.cpp @@ -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::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";