Fix http_request parse url and throw string

dev
marcelb 1 year ago
parent 394e4aa923
commit f6bb632af2
  1. 2
      src/api.cpp
  2. 2
      src/http.cpp

@ -27,7 +27,7 @@ api::api(defapi* _def, const string _method, const string _path, const map<strin
body = _body;
if (!validate()) {
throw "[ERROR] The API is not correct ";
throw string("[ERROR] The API is not correct ");
}
}

@ -21,7 +21,7 @@ http_request::http_request(const string _raw) {
void http_request::parse() {
method = raw.substr(0, raw.find(" "));
url = raw.substr(raw.find("/"), raw.find("HTTP/")-raw.find("/"));
url = raw.substr(raw.find("/"), raw.find("HTTP/")-raw.find("/")-1);
string _headers = raw.substr(raw.find("\r\n")+2, raw.find("\r\n\r\n")-raw.find("\r\n"));
while (!_headers.empty()) {

Loading…
Cancel
Save