diff --git a/src/client.cpp b/src/client.cpp index 3ce3733..e6187ac 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -80,9 +80,10 @@ void Client::PrepareToNewRequest() http_version = http_version_unsupported; answer_generated = false; output_buffer_sent = 0; - close_connection = false; http_method_str.clear(); output_buffer.clear(); url.clear(); + + // don't set flag close_connection to false here } diff --git a/src/headers_parser.cpp b/src/headers_parser.cpp index 2ee1005..a51631f 100644 --- a/src/headers_parser.cpp +++ b/src/headers_parser.cpp @@ -63,9 +63,20 @@ bool HeadersParser::IsHeadersEnding(const char * ptr) bool HeadersParser::ParseFirstHeader(Client & client) { - return ParseFirstHeaderMethodName(client) && - ParseFirstHeaderURL(client) && - ParseFirstHeaderHTTPVersion(client); + bool first_ok = ParseFirstHeaderMethodName(client) && + ParseFirstHeaderURL(client) && + ParseFirstHeaderHTTPVersion(client); + + SkipWhite(client); + + if( header_index + 1 < client.input_buffer.size() && + client.input_buffer[header_index] == '\r' && + client.input_buffer[header_index+1] == '\n' ) + { + header_index += 2; + } + + return first_ok; } @@ -181,31 +192,6 @@ bool HeadersParser::ParseFirstHeaderHTTPVersion(Client & client) int d1 = client.input_buffer[header_index + 5] - '0'; int d2 = client.input_buffer[header_index + 7] - '0'; - int ddd1 = client.input_buffer[header_index + 5] - '0'; - int ddd2 = client.input_buffer[header_index + 7] - '0'; - - if( d1 == 1 ) - { - client.http_version = http_version_1_0; - - } - - if( d2 == 1 ) - { - client.http_version = http_version_1_1; - } - - if( ddd1 == 1 ) - { - client.http_version = http_version_1_0; - - } - - if( ddd2 == 1 ) - { - client.http_version = http_version_1_1; - } - if( d1 == 1 ) { if( d2 == 0 ) diff --git a/src/server.cpp b/src/server.cpp index f313427..f2872af 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -193,6 +193,7 @@ int client_socket; Client c; c.socket = client_socket; + c.close_connection = false; client_tab.push_back(c); client_tab.back().PrepareToNewRequest();