1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef NET_TOOLS_FLIP_SERVER_BALSA_ENUMS_H_
6 #define NET_TOOLS_FLIP_SERVER_BALSA_ENUMS_H_
10 struct BalsaFrameEnums
{
13 READING_HEADER_AND_FIRSTLINE
,
15 READING_CHUNK_EXTENSION
,
18 READING_LAST_CHUNK_TERM
,
27 NO_ERROR
= 0, // A sentinel value for convenience, none of the callbacks
28 // should ever see this error code.
29 // Header parsing errors
30 // Note that adding one to many of the REQUEST errors yields the
31 // appropriate RESPONSE error.
32 // Particularly, when parsing the first line of a request or response,
33 // there are three sequences of non-whitespace regardless of whether or
34 // not it is a request or response. These are listed below, in order.
36 // firstline_a firstline_b firstline_c
37 // REQ: method request_uri version
38 // RESP: version statuscode reason
40 // As you can see, the first token is the 'method' field for a request,
41 // and 'version' field for a response. We call the first non whitespace
42 // token firstline_a, the second firstline_b, and the third token
43 // followed by [^\r\n]*) firstline_c.
45 // This organization is important, as it lets us determine the error code
46 // to use without a branch based on is_response. Instead, we simply add
47 // is_response to the response error code-- If is_response is true, then
48 // we'll get the response error code, thanks to the fact that the error
49 // code numbers are organized to ensure that response error codes always
50 // precede request error codes.
55 NO_STATUS_LINE_IN_RESPONSE
, // |
56 NO_REQUEST_LINE_IN_REQUEST
, // |
57 FAILED_TO_FIND_WS_AFTER_RESPONSE_VERSION
, // | firstline_a
58 FAILED_TO_FIND_WS_AFTER_REQUEST_METHOD
, // | firstline_a
59 FAILED_TO_FIND_WS_AFTER_RESPONSE_STATUSCODE
, // | firstline_b
60 FAILED_TO_FIND_WS_AFTER_REQUEST_REQUEST_URI
, // | firstline_b
61 FAILED_TO_FIND_NL_AFTER_RESPONSE_REASON_PHRASE
, // | firstline_c
62 FAILED_TO_FIND_NL_AFTER_REQUEST_HTTP_VERSION
, // | firstline_c
64 FAILED_CONVERTING_STATUS_CODE_TO_INT
,
65 REQUEST_URI_TOO_LONG
, // Request URI greater than kMaxUrlLen.
68 UNPARSABLE_CONTENT_LENGTH
,
69 // Warning: there may be a body but there was no content-length/chunked
71 MAYBE_BODY_BUT_NO_CONTENT_LENGTH
,
73 // This is used if a body is required for a request.
74 REQUIRED_BODY_BUT_NO_CONTENT_LENGTH
,
80 CHUNK_LENGTH_OVERFLOW
,
83 CALLED_BYTES_SPLICED_WHEN_UNSAFE_TO_DO_SO
,
84 CALLED_BYTES_SPLICED_AND_EXCEEDED_SAFE_SPLICE_AMOUNT
,
85 MULTIPLE_CONTENT_LENGTH_KEYS
,
86 MULTIPLE_TRANSFER_ENCODING_KEYS
,
87 UNKNOWN_TRANSFER_ENCODING
,
88 INVALID_HEADER_FORMAT
,
90 // A detected internal inconsistency was found.
95 static const char* ParseStateToString(ParseState error_code
);
96 static const char* ErrorCodeToString(ErrorCode error_code
);
99 struct BalsaHeadersEnums
{
100 enum ContentLengthStatus
{
101 INVALID_CONTENT_LENGTH
,
102 CONTENT_LENGTH_OVERFLOW
,
104 VALID_CONTENT_LENGTH
,
110 #endif // NET_TOOLS_FLIP_SERVER_BALSA_ENUMS_H_