CRLF macro
This commit is contained in:
@@ -43,12 +43,12 @@ void Webserv::_send_response(Client *client, ServerConfig &server)
|
||||
|
||||
void Webserv::_append_base_headers(Client *client)
|
||||
{
|
||||
client->response.append("Server: Webserv/0.1\r\n");
|
||||
client->response.append("Server: Webserv/0.1" CRLF);
|
||||
|
||||
if (client->get_headers("Connection") == "close")
|
||||
client->response.append("Connection: close\r\n");
|
||||
client->response.append("Connection: close" CRLF);
|
||||
else
|
||||
client->response.append("Connection: keep-alive\r\n");
|
||||
client->response.append("Connection: keep-alive" CRLF);
|
||||
}
|
||||
|
||||
void Webserv::_construct_response(Client *client, ServerConfig &server)
|
||||
@@ -94,7 +94,7 @@ void Webserv::_process_method(Client *client, ServerConfig &server, LocationConf
|
||||
client->status = 405;
|
||||
client->response.append("Allow: ");
|
||||
client->response.append(::http_methods_to_str(allow_methods));
|
||||
client->response.append("\r\n");
|
||||
client->response.append(CRLF);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ void Webserv::_insert_status_line(Client *client)
|
||||
|
||||
status_line.append("HTTP/1.1 ");
|
||||
status_line.append(_http_status[client->status]);
|
||||
status_line.append("\r\n");
|
||||
status_line.append(CRLF);
|
||||
client->response.insert(0, status_line);
|
||||
}
|
||||
|
||||
@@ -195,14 +195,14 @@ void Webserv::_append_body(Client *client, const char *body, size_t body_size)
|
||||
http://nginx.org/en/docs/http/ngx_http_core_module.html#types
|
||||
Need to look "conf/mime.types" of nginx. Maybe make a map<> based on that.
|
||||
*/
|
||||
client->response.append("Content-Type: text/html; charset=UTF-8\r\n");
|
||||
client->response.append("Content-Type: text/html; charset=UTF-8" CRLF);
|
||||
|
||||
client->response.append("Content-Length: ");
|
||||
std::string tmp = ::itos(body_size);
|
||||
client->response.append(tmp);
|
||||
client->response.append("\r\n");
|
||||
client->response.append(CRLF);
|
||||
|
||||
client->response.append("\r\n");
|
||||
client->response.append(CRLF);
|
||||
client->response.append(body);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user