Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
| 2 | include/types/proto_http.h |
| 3 | This file contains HTTP protocol definitions. |
| 4 | |
| 5 | Copyright (C) 2000-2006 Willy Tarreau - w@1wt.eu |
| 6 | |
| 7 | This library is free software; you can redistribute it and/or |
| 8 | modify it under the terms of the GNU Lesser General Public |
| 9 | License as published by the Free Software Foundation, version 2.1 |
| 10 | exclusively. |
| 11 | |
| 12 | This library is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | Lesser General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU Lesser General Public |
| 18 | License along with this library; if not, write to the Free Software |
| 19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 20 | */ |
| 21 | |
| 22 | #ifndef _TYPES_PROTO_HTTP_H |
| 23 | #define _TYPES_PROTO_HTTP_H |
| 24 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 25 | #include <common/config.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * FIXME: break this into HTTP state and TCP socket state. |
| 29 | * See server.h for the other end. |
| 30 | */ |
| 31 | |
| 32 | /* different possible states for the client side */ |
| 33 | #define CL_STHEADERS 0 |
| 34 | #define CL_STDATA 1 |
| 35 | #define CL_STSHUTR 2 |
| 36 | #define CL_STSHUTW 3 |
| 37 | #define CL_STCLOSE 4 |
| 38 | |
| 39 | /* |
| 40 | * FIXME: break this into HTTP state and TCP socket state. |
| 41 | * See client.h for the other end. |
| 42 | */ |
| 43 | |
| 44 | /* different possible states for the server side */ |
| 45 | #define SV_STIDLE 0 |
| 46 | #define SV_STCONN 1 |
| 47 | #define SV_STHEADERS 2 |
| 48 | #define SV_STDATA 3 |
| 49 | #define SV_STSHUTR 4 |
| 50 | #define SV_STSHUTW 5 |
| 51 | #define SV_STCLOSE 6 |
| 52 | |
| 53 | |
Willy Tarreau | 8d5d7f2 | 2007-01-21 19:16:41 +0100 | [diff] [blame] | 54 | /* The HTTP parser is more complex than it looks like, because we have to |
| 55 | * support multi-line headers and any number of spaces between the colon and |
| 56 | * the value. |
| 57 | * |
| 58 | * All those examples must work : |
| 59 | |
| 60 | Hdr1:val1\r\n |
| 61 | Hdr1: val1\r\n |
| 62 | Hdr1:\t val1\r\n |
| 63 | Hdr1: \r\n |
| 64 | val1\r\n |
| 65 | Hdr1:\r\n |
| 66 | val1\n |
| 67 | \tval2\r\n |
| 68 | val3\n |
| 69 | |
| 70 | * |
| 71 | */ |
| 72 | |
Willy Tarreau | 58f10d7 | 2006-12-04 02:26:12 +0100 | [diff] [blame] | 73 | /* Possible states while parsing HTTP messages (request|response) */ |
Willy Tarreau | 8d5d7f2 | 2007-01-21 19:16:41 +0100 | [diff] [blame] | 74 | #define HTTP_MSG_RQBEFORE 0 // request: leading LF, before start line |
| 75 | #define HTTP_MSG_RQBEFORE_CR 1 // request: leading CRLF, before start line |
| 76 | |
| 77 | /* these ones define a request start line */ |
| 78 | #define HTTP_MSG_RQMETH 2 // parsing the Method |
| 79 | #define HTTP_MSG_RQMETH_SP 3 // space(s) after the ethod |
| 80 | #define HTTP_MSG_RQURI 4 // parsing the Request URI |
| 81 | #define HTTP_MSG_RQURI_SP 5 // space(s) after the Request URI |
| 82 | #define HTTP_MSG_RQVER 6 // parsing the Request Version |
| 83 | #define HTTP_MSG_RQLINE_END 7 // end of request line (CR or LF) |
| 84 | |
| 85 | #define HTTP_MSG_RPBEFORE 8 // response: leading LF, before start line |
| 86 | #define HTTP_MSG_RPBEFORE_CR 9 // response: leading CRLF, before start line |
| 87 | |
| 88 | /* these ones define a response start line */ |
| 89 | #define HTTP_MSG_RPVER 10 // parsing the Response Version |
| 90 | #define HTTP_MSG_RPVER_SP 11 // space(s) after the Response Version |
| 91 | #define HTTP_MSG_RPCODE 12 // response code |
| 92 | #define HTTP_MSG_RPCODE_SP 13 // space(s) after the response code |
| 93 | #define HTTP_MSG_RPREASON 14 // response reason |
| 94 | #define HTTP_MSG_RPLINE_END 15 // end of response line (CR or LF) |
| 95 | |
| 96 | /* common header processing */ |
| 97 | |
| 98 | #define HTTP_MSG_HDR_FIRST 16 // waiting for first header or last CRLF (no LWS possible) |
| 99 | #define HTTP_MSG_HDR_NAME 17 // parsing header name |
| 100 | #define HTTP_MSG_HDR_COL 18 // parsing header colon |
| 101 | #define HTTP_MSG_HDR_L1_SP 19 // parsing header LWS (SP|HT) before value |
| 102 | #define HTTP_MSG_HDR_L1_LF 20 // parsing header LWS (LF) before value |
| 103 | #define HTTP_MSG_HDR_L1_LWS 21 // checking whether it's a new header or an LWS |
| 104 | #define HTTP_MSG_HDR_VAL 22 // parsing header value |
| 105 | #define HTTP_MSG_HDR_L2_LF 23 // parsing header LWS (LF) inside/after value |
| 106 | #define HTTP_MSG_HDR_L2_LWS 24 // checking whether it's a new header or an LWS |
| 107 | |
| 108 | #define HTTP_MSG_LAST_LF 25 // parsing last LF |
| 109 | #define HTTP_MSG_BODY 26 // parsing body at end of headers |
| 110 | #define HTTP_MSG_ERROR 27 // an error occurred |
| 111 | |
Willy Tarreau | 58f10d7 | 2006-12-04 02:26:12 +0100 | [diff] [blame] | 112 | |
Willy Tarreau | c0dde7a | 2007-01-01 21:38:07 +0100 | [diff] [blame] | 113 | /* various data sources for the responses */ |
| 114 | #define DATA_SRC_NONE 0 |
| 115 | #define DATA_SRC_STATS 1 |
| 116 | |
| 117 | /* data transmission states for the stats responses */ |
| 118 | enum { |
| 119 | DATA_ST_INIT = 0, |
| 120 | DATA_ST_HEAD, |
| 121 | DATA_ST_INFO, |
| 122 | DATA_ST_LIST, |
| 123 | DATA_ST_END, |
| 124 | DATA_ST_FIN, |
| 125 | }; |
| 126 | |
| 127 | /* data transmission states for the stats responses inside a proxy */ |
| 128 | enum { |
| 129 | DATA_ST_PX_INIT = 0, |
| 130 | DATA_ST_PX_TH, |
| 131 | DATA_ST_PX_FE, |
| 132 | DATA_ST_PX_SV, |
| 133 | DATA_ST_PX_BE, |
| 134 | DATA_ST_PX_END, |
| 135 | DATA_ST_PX_FIN, |
| 136 | }; |
| 137 | |
Willy Tarreau | 58f10d7 | 2006-12-04 02:26:12 +0100 | [diff] [blame] | 138 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 139 | #endif /* _TYPES_PROTO_HTTP_H */ |
| 140 | |
| 141 | /* |
| 142 | * Local variables: |
| 143 | * c-indent-level: 8 |
| 144 | * c-basic-offset: 8 |
| 145 | * End: |
| 146 | */ |