diff --git a/lib/http.hpp b/lib/http.hpp index 3503234..b18a939 100644 --- a/lib/http.hpp +++ b/lib/http.hpp @@ -15,7 +15,6 @@ class api; class http_request { public: string protocol; - string protocol; string method; string url; map headers; diff --git a/src/http.cpp b/src/http.cpp index a6c8933..73e5ac2 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -86,8 +86,7 @@ http_response::http_response(const http_response_code _status, const string _bod status = to_string(_status) + " " + http_response_code_txt(_status); if (!_body.empty()) { body = _body; - // kad merge s header-response branch možeš omogućit ovu liniju - // this->header("Content-Length", to_string(body.length())); + this->header("Content-Length", to_string(body.length())); } protocol = get_protocol(_protocol); mold(); diff --git a/test/test.cpp b/test/test.cpp index 4cb283b..1b127c8 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -8,23 +8,17 @@ int main() { try { -<<<<<<< HEAD - api uf(GET, "delete", {make_pair("id", "4")}, "bay"); + api uf(GET, "/delete", {make_pair("id", "4")}, "bay"); http_request myreq(&uf); - myreq.putheader("Content-type", "text/plain"); -======= - // api uf(&myApi, GET, "/delete", {make_pair("id", "4")}, "bay"); - // http_request myreq(&uf); - // myreq.header("Content-type", "text/plain"); ->>>>>>> http-status-code + myreq.header("Content-type", "text/plain"); - // cout << myreq.raw << endl; + cout << myreq.raw << endl; - // cout << myreq.protocol << endl; - // // cout << myreq.status << endl; - // for(auto i : myreq.headers) - // cout << i.first << " " << i.second << endl; - // cout << myreq.body << endl; + cout << myreq.protocol << endl; + // cout << myreq.status << endl; + for(auto i : myreq.headers) + cout << i.first << " " << i.second << endl; + cout << myreq.body << endl; http_response myres2(OK, "nnotauth", "1.0" ); @@ -33,7 +27,9 @@ int main() { cout << myres2.headers["Content-Length"] << endl; cout << myres2.body << endl; - + } catch (const string err) { + cout << err << endl; + } // http myHttp(&myApi, "GET /fghfhf HTTP/1.1\r\nBaba"); diff --git a/test/test.o b/test/test.o index 29cc6bf..1ccfd78 100755 Binary files a/test/test.o and b/test/test.o differ