Add header for http_response.. try 2

namespace
mbandic 1 year ago
parent 32c80d7bb6
commit 759fbff303
  1. 4
      lib/http.hpp
  2. 13
      src/http.cpp

@ -51,8 +51,8 @@ class http_response {
void get(const string _raw);
//bool validate();
// void putheader(const string _key, const string _value);
// void putheaders(const map<string, string> _headers);
void header(const string _key, const string _value);
void header(const map<string, string> _headers);
void mold(); // za slanje
void parse(); // čitaj http

@ -85,15 +85,20 @@ void http_response::get(const string _raw) {
parse();
}
/**
*
*/
void http_response::header(const string _key, const string _value) {
headers[_key] = _value;
mold();
}
void http_response::header(const map<string, string> _headers) {
headers = _headers;
mold();
}
void http_response::mold() {
raw = "HTTP/1.1 200 OK\r\n"; // implementirati status
if (!headers.empty()) {
raw += '?';
for (auto i : headers) {
raw += i.first + ": " + i.second + "\r\n";
}

Loading…
Cancel
Save