From 394e4aa923fbc2734b74148c0c6c1c0aeddcf157 Mon Sep 17 00:00:00 2001 From: marcelb Date: Fri, 26 May 2023 18:25:58 +0200 Subject: [PATCH] Added exceptions --- src/api.cpp | 4 +--- src/http.cpp | 12 ++---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/api.cpp b/src/api.cpp index e8cbb48..3d6d90e 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -10,7 +10,6 @@ void defapi::necessary(const string _path, const vector _keys) { val_matrix[_path].insert( val_matrix[_path].end(), _keys.begin(), _keys.end()); } -// radi api::api(defapi* _def, const string _method, const string _path, const map _params, const string _body) { def = _def; method = _method; @@ -28,11 +27,10 @@ api::api(defapi* _def, const string _method, const string _path, const mapmethod; url = _api->url; @@ -17,13 +14,11 @@ http_request::http_request(const api *_api) { mold(); } -// radi http_request::http_request(const string _raw) { raw = _raw; parse(); } -// radi void http_request::parse() { method = raw.substr(0, raw.find(" ")); url = raw.substr(raw.find("/"), raw.find("HTTP/")-raw.find("/")); @@ -38,7 +33,6 @@ void http_request::parse() { headers.insert(make_pair(key, value)); } - // ne radi za specijalan slučaj kada nema zaglavlja if ((size_t)raw.find("\r\n\r\n") == (size_t)raw.find("\r\n")) body = raw.substr(raw.find("\r\n\r\n")+4, raw.length()-raw.find("\r\n\r\n")); @@ -60,7 +54,6 @@ void http_request::putheaders(const map _headers) { /** * http zahtjev formiranje raw */ -// radi void http_request::mold() { @@ -88,12 +81,12 @@ void http_response::get(const string _raw) { } /** - * Nakon + * */ void http_response::mold() { - raw = "HTTP/1.1 200 OK\r\n"; + raw = "HTTP/1.1 200 OK\r\n"; // implementirati status if (!headers.empty()) { raw += '?'; for (auto i : headers) { @@ -104,7 +97,6 @@ void http_response::mold() { raw += "\r\n" + body; } -// radi void http_response::parse() {