OLD | NEW |
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 #include "net/server/http_server.h" | 5 #include "net/server/http_server.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 ST_HEADER, // Starting a Request Header | 339 ST_HEADER, // Starting a Request Header |
340 ST_NAME, // Receiving a request header name | 340 ST_NAME, // Receiving a request header name |
341 ST_SEPARATOR, // Receiving the separator between header name and value | 341 ST_SEPARATOR, // Receiving the separator between header name and value |
342 ST_VALUE, // Receiving a request header value | 342 ST_VALUE, // Receiving a request header value |
343 ST_DONE, // Parsing is complete and successful | 343 ST_DONE, // Parsing is complete and successful |
344 ST_ERR, // Parsing encountered invalid syntax. | 344 ST_ERR, // Parsing encountered invalid syntax. |
345 MAX_STATES | 345 MAX_STATES |
346 }; | 346 }; |
347 | 347 |
348 // State transition table | 348 // State transition table |
349 int parser_state[MAX_STATES][MAX_INPUTS] = { | 349 const int parser_state[MAX_STATES][MAX_INPUTS] = { |
350 /* METHOD */ { ST_URL, ST_ERR, ST_ERR, ST_ERR, ST_METHOD }, | 350 /* METHOD */ {ST_URL, ST_ERR, ST_ERR, ST_ERR, ST_METHOD}, |
351 /* URL */ { ST_PROTO, ST_ERR, ST_ERR, ST_URL, ST_URL }, | 351 /* URL */ {ST_PROTO, ST_ERR, ST_ERR, ST_URL, ST_URL}, |
352 /* PROTOCOL */ { ST_ERR, ST_HEADER, ST_NAME, ST_ERR, ST_PROTO }, | 352 /* PROTOCOL */ {ST_ERR, ST_HEADER, ST_NAME, ST_ERR, ST_PROTO}, |
353 /* HEADER */ { ST_ERR, ST_ERR, ST_NAME, ST_ERR, ST_ERR }, | 353 /* HEADER */ {ST_ERR, ST_ERR, ST_NAME, ST_ERR, ST_ERR}, |
354 /* NAME */ { ST_SEPARATOR, ST_DONE, ST_ERR, ST_VALUE, ST_NAME }, | 354 /* NAME */ {ST_SEPARATOR, ST_DONE, ST_ERR, ST_VALUE, ST_NAME}, |
355 /* SEPARATOR */ { ST_SEPARATOR, ST_ERR, ST_ERR, ST_VALUE, ST_ERR }, | 355 /* SEPARATOR */ {ST_SEPARATOR, ST_ERR, ST_ERR, ST_VALUE, ST_ERR}, |
356 /* VALUE */ { ST_VALUE, ST_HEADER, ST_NAME, ST_VALUE, ST_VALUE }, | 356 /* VALUE */ {ST_VALUE, ST_HEADER, ST_NAME, ST_VALUE, ST_VALUE}, |
357 /* DONE */ { ST_DONE, ST_DONE, ST_DONE, ST_DONE, ST_DONE }, | 357 /* DONE */ {ST_DONE, ST_DONE, ST_DONE, ST_DONE, ST_DONE}, |
358 /* ERR */ { ST_ERR, ST_ERR, ST_ERR, ST_ERR, ST_ERR } | 358 /* ERR */ {ST_ERR, ST_ERR, ST_ERR, ST_ERR, ST_ERR}}; |
359 }; | |
360 | 359 |
361 // Convert an input character to the parser's input token. | 360 // Convert an input character to the parser's input token. |
362 int charToInput(char ch) { | 361 int charToInput(char ch) { |
363 switch(ch) { | 362 switch(ch) { |
364 case ' ': | 363 case ' ': |
365 case '\t': | 364 case '\t': |
366 return INPUT_LWS; | 365 return INPUT_LWS; |
367 case '\r': | 366 case '\r': |
368 return INPUT_CR; | 367 return INPUT_CR; |
369 case '\n': | 368 case '\n': |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 459 |
461 // This is called after any delegate callbacks are called to check if Close() | 460 // This is called after any delegate callbacks are called to check if Close() |
462 // has been called during callback processing. Using the pointer of connection, | 461 // has been called during callback processing. Using the pointer of connection, |
463 // |connection| is safe here because Close() deletes the connection in next run | 462 // |connection| is safe here because Close() deletes the connection in next run |
464 // loop. | 463 // loop. |
465 bool HttpServer::HasClosedConnection(HttpConnection* connection) { | 464 bool HttpServer::HasClosedConnection(HttpConnection* connection) { |
466 return FindConnection(connection->id()) != connection; | 465 return FindConnection(connection->id()) != connection; |
467 } | 466 } |
468 | 467 |
469 } // namespace net | 468 } // namespace net |
OLD | NEW |