Index: net/server/http_server.cc |
diff --git a/net/server/http_server.cc b/net/server/http_server.cc |
index 08d0706c3c73a870c4badbd54938355440087575..10ed7e81e5ac29b8f686bbd80e2a7c5a7a4bcb7a 100644 |
--- a/net/server/http_server.cc |
+++ b/net/server/http_server.cc |
@@ -230,8 +230,11 @@ int HttpServer::HandleReadResult(HttpConnection* connection, int rv) { |
HttpServerRequestInfo request; |
size_t pos = 0; |
- if (!ParseHeaders(read_buf->StartOfBuffer(), read_buf->GetSize(), |
- &request, &pos)) { |
+ if (!ParseHeaders(connection->id(), read_buf->StartOfBuffer(), |
+ read_buf->GetSize(), &request, &pos)) { |
+ // Check if a parsing error has caused the connection to close. |
+ if (HasClosedConnection(connection)) |
+ return ERR_CONNECTION_CLOSED; |
break; |
} |
@@ -378,7 +381,8 @@ int charToInput(char ch) { |
} // namespace |
-bool HttpServer::ParseHeaders(const char* data, |
+bool HttpServer::ParseHeaders(int connection_id, |
+ const char* data, |
size_t data_len, |
HttpServerRequestInfo* info, |
size_t* ppos) { |
@@ -406,8 +410,10 @@ bool HttpServer::ParseHeaders(const char* data, |
buffer.clear(); |
break; |
case ST_PROTO: |
- // TODO(mbelshe): Deal better with parsing protocol. |
- DCHECK(buffer == "HTTP/1.1"); |
+ if (buffer != "HTTP/1.1") { |
+ LOG(ERROR) << "Ignoring request with protocol: " << buffer; |
+ next_state = ST_ERR; |
+ } |
buffer.clear(); |
break; |
case ST_NAME: |
@@ -445,6 +451,7 @@ bool HttpServer::ParseHeaders(const char* data, |
DCHECK(input == INPUT_LF); |
return true; |
case ST_ERR: |
+ Close(connection_id); |
return false; |
} |
} |