parsing headers is allright now
+ adding error codes in readme and in comments in client
This commit is contained in:
@@ -99,17 +99,21 @@ void Client::parse_request(std::vector<ServerConfig> &servers)
|
||||
// use getter for headers because it works case insensitive
|
||||
_parse_port_hostname(this->get_rq_headers("Host"));
|
||||
|
||||
/* dont clear raw_request, we need it for future reparsing of body
|
||||
see call of parse_request() in _read_request() */
|
||||
// dont clear raw_request, we need it for future reparsing of body
|
||||
// see call of parse_request() in _read_request()
|
||||
// raw_request.clear();
|
||||
}
|
||||
|
||||
void Client::parse_request_body()
|
||||
{
|
||||
// TODO: check error and adjust status
|
||||
_request.body = ::parse_http_body(raw_request);
|
||||
size_t pos;
|
||||
|
||||
pos = raw_request.find(CRLF CRLF);
|
||||
pos += std::string(CRLF CRLF).size();
|
||||
_request.body = message.substr(pos);
|
||||
|
||||
if (_request.body.size() > assigned_server->client_body_limit)
|
||||
status = 413;
|
||||
status = 413; // HTTP Client Errors
|
||||
}
|
||||
|
||||
bool Client::fill_script_path(std::string script)
|
||||
@@ -279,12 +283,12 @@ void Client::_check_request_errors()
|
||||
//////////////////////
|
||||
// Request line checks
|
||||
if (_request.method == UNKNOWN)
|
||||
status = 501;
|
||||
status = 501; // HTTP Client Errors
|
||||
else if (_request.version.compare(0, sizeof("HTTP/1") - 1, "HTTP/1") != 0)
|
||||
status = 505;
|
||||
status = 505; // HTTP Client Errors
|
||||
else if (!(assigned_location->allow_methods & _request.method))
|
||||
{
|
||||
status = 405;
|
||||
status = 405; // HTTP Client Errors
|
||||
response.append("Allow: ");
|
||||
response.append(::http_methods_to_str(assigned_location->allow_methods));
|
||||
response.append(CRLF);
|
||||
@@ -305,7 +309,7 @@ void Client::_check_request_errors()
|
||||
// Headers checks
|
||||
if (!this->get_rq_headers("Content-Length").empty()
|
||||
&& ::atoi(this->get_rq_headers("Content-Length").c_str()) > (int)assigned_server->client_body_limit)
|
||||
status = 413;
|
||||
status = 413; // HTTP Client Errors
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user