Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1204)

Side by Side Diff: net/server/http_server.h

Issue 2314073003: Handle non-HTTP/1.1 requests more gracefully in net::HttpServer. (Closed)
Patch Set: Close the connection on a parsing error Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/server/http_server.cc » ('j') | net/server/http_server_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_SERVER_HTTP_SERVER_H_ 5 #ifndef NET_SERVER_HTTP_SERVER_H_
6 #define NET_SERVER_HTTP_SERVER_H_ 6 #define NET_SERVER_HTTP_SERVER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void DoReadLoop(HttpConnection* connection); 91 void DoReadLoop(HttpConnection* connection);
92 void OnReadCompleted(int connection_id, int rv); 92 void OnReadCompleted(int connection_id, int rv);
93 int HandleReadResult(HttpConnection* connection, int rv); 93 int HandleReadResult(HttpConnection* connection, int rv);
94 94
95 void DoWriteLoop(HttpConnection* connection); 95 void DoWriteLoop(HttpConnection* connection);
96 void OnWriteCompleted(int connection_id, int rv); 96 void OnWriteCompleted(int connection_id, int rv);
97 int HandleWriteResult(HttpConnection* connection, int rv); 97 int HandleWriteResult(HttpConnection* connection, int rv);
98 98
99 // Expects the raw data to be stored in recv_data_. If parsing is successful, 99 // Expects the raw data to be stored in recv_data_. If parsing is successful,
100 // will remove the data parsed from recv_data_, leaving only the unused 100 // will remove the data parsed from recv_data_, leaving only the unused
101 // recv data. 101 // recv data. If parsing fails, the connection will be closed.
mmenke 2016/09/12 20:35:04 Here's my suggestion: Return false on error, leav
slan 2016/09/14 15:50:57 Done.
102 bool ParseHeaders(const char* data, 102 bool ParseHeaders(int connection_id,
103 const char* data,
103 size_t data_len, 104 size_t data_len,
104 HttpServerRequestInfo* info, 105 HttpServerRequestInfo* info,
105 size_t* pos); 106 size_t* pos);
106 107
107 HttpConnection* FindConnection(int connection_id); 108 HttpConnection* FindConnection(int connection_id);
108 109
109 // Whether or not Close() has been called during delegate callback processing. 110 // Whether or not Close() has been called during delegate callback processing.
110 bool HasClosedConnection(HttpConnection* connection); 111 bool HasClosedConnection(HttpConnection* connection);
111 112
112 const std::unique_ptr<ServerSocket> server_socket_; 113 const std::unique_ptr<ServerSocket> server_socket_;
113 std::unique_ptr<StreamSocket> accepted_socket_; 114 std::unique_ptr<StreamSocket> accepted_socket_;
114 HttpServer::Delegate* const delegate_; 115 HttpServer::Delegate* const delegate_;
115 116
116 int last_id_; 117 int last_id_;
117 IdToConnectionMap id_to_connection_; 118 IdToConnectionMap id_to_connection_;
118 119
119 base::WeakPtrFactory<HttpServer> weak_ptr_factory_; 120 base::WeakPtrFactory<HttpServer> weak_ptr_factory_;
120 121
121 DISALLOW_COPY_AND_ASSIGN(HttpServer); 122 DISALLOW_COPY_AND_ASSIGN(HttpServer);
122 }; 123 };
123 124
124 } // namespace net 125 } // namespace net
125 126
126 #endif // NET_SERVER_HTTP_SERVER_H_ 127 #endif // NET_SERVER_HTTP_SERVER_H_
OLDNEW
« no previous file with comments | « no previous file | net/server/http_server.cc » ('j') | net/server/http_server_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698