Willy Tarreau | 0da5b3b | 2017-09-21 09:30:46 +0200 | [diff] [blame] | 1 | /* |
| 2 | * include/proto/h1.h |
| 3 | * This file contains HTTP/1 protocol definitions. |
| 4 | * |
| 5 | * Copyright (C) 2000-2017 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 _PROTO_H1_H |
| 23 | #define _PROTO_H1_H |
| 24 | |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 25 | #include <common/buffer.h> |
Willy Tarreau | 0da5b3b | 2017-09-21 09:30:46 +0200 | [diff] [blame] | 26 | #include <common/compiler.h> |
| 27 | #include <common/config.h> |
Willy Tarreau | 35b51c6 | 2018-09-10 15:38:55 +0200 | [diff] [blame] | 28 | #include <common/http.h> |
Willy Tarreau | 794f9af | 2017-07-26 09:07:47 +0200 | [diff] [blame] | 29 | #include <common/http-hdr.h> |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 30 | #include <common/standard.h> |
Willy Tarreau | 0da5b3b | 2017-09-21 09:30:46 +0200 | [diff] [blame] | 31 | #include <types/h1.h> |
| 32 | |
Willy Tarreau | 794f9af | 2017-07-26 09:07:47 +0200 | [diff] [blame] | 33 | int h1_headers_to_hdr_list(char *start, const char *stop, |
| 34 | struct http_hdr *hdr, unsigned int hdr_num, |
Willy Tarreau | a41393f | 2018-09-11 15:34:50 +0200 | [diff] [blame] | 35 | struct h1m *h1m, union h1_sl *slp); |
Willy Tarreau | f40e682 | 2018-06-14 16:52:02 +0200 | [diff] [blame] | 36 | int h1_measure_trailers(const struct buffer *buf, unsigned int ofs, unsigned int max); |
Willy Tarreau | 0da5b3b | 2017-09-21 09:30:46 +0200 | [diff] [blame] | 37 | |
Christopher Faulet | 55d6be7 | 2018-10-17 11:05:51 +0200 | [diff] [blame] | 38 | int h1_parse_cont_len_header(struct h1m *h1m, struct ist *value); |
| 39 | void h1_parse_xfer_enc_header(struct h1m *h1m, struct ist value); |
| 40 | void h1_parse_connection_header(struct h1m *h1m, struct ist value); |
| 41 | |
Willy Tarreau | 801250e | 2018-09-11 11:45:04 +0200 | [diff] [blame] | 42 | /* for debugging, reports the HTTP/1 message state name (legacy version) */ |
Willy Tarreau | 0da5b3b | 2017-09-21 09:30:46 +0200 | [diff] [blame] | 43 | static inline const char *h1_msg_state_str(enum h1_state msg_state) |
| 44 | { |
| 45 | switch (msg_state) { |
| 46 | case HTTP_MSG_RQBEFORE: return "MSG_RQBEFORE"; |
| 47 | case HTTP_MSG_RQBEFORE_CR: return "MSG_RQBEFORE_CR"; |
| 48 | case HTTP_MSG_RQMETH: return "MSG_RQMETH"; |
| 49 | case HTTP_MSG_RQMETH_SP: return "MSG_RQMETH_SP"; |
| 50 | case HTTP_MSG_RQURI: return "MSG_RQURI"; |
| 51 | case HTTP_MSG_RQURI_SP: return "MSG_RQURI_SP"; |
| 52 | case HTTP_MSG_RQVER: return "MSG_RQVER"; |
| 53 | case HTTP_MSG_RQLINE_END: return "MSG_RQLINE_END"; |
| 54 | case HTTP_MSG_RPBEFORE: return "MSG_RPBEFORE"; |
| 55 | case HTTP_MSG_RPBEFORE_CR: return "MSG_RPBEFORE_CR"; |
| 56 | case HTTP_MSG_RPVER: return "MSG_RPVER"; |
| 57 | case HTTP_MSG_RPVER_SP: return "MSG_RPVER_SP"; |
| 58 | case HTTP_MSG_RPCODE: return "MSG_RPCODE"; |
| 59 | case HTTP_MSG_RPCODE_SP: return "MSG_RPCODE_SP"; |
| 60 | case HTTP_MSG_RPREASON: return "MSG_RPREASON"; |
| 61 | case HTTP_MSG_RPLINE_END: return "MSG_RPLINE_END"; |
| 62 | case HTTP_MSG_HDR_FIRST: return "MSG_HDR_FIRST"; |
| 63 | case HTTP_MSG_HDR_NAME: return "MSG_HDR_NAME"; |
| 64 | case HTTP_MSG_HDR_COL: return "MSG_HDR_COL"; |
| 65 | case HTTP_MSG_HDR_L1_SP: return "MSG_HDR_L1_SP"; |
| 66 | case HTTP_MSG_HDR_L1_LF: return "MSG_HDR_L1_LF"; |
| 67 | case HTTP_MSG_HDR_L1_LWS: return "MSG_HDR_L1_LWS"; |
| 68 | case HTTP_MSG_HDR_VAL: return "MSG_HDR_VAL"; |
| 69 | case HTTP_MSG_HDR_L2_LF: return "MSG_HDR_L2_LF"; |
| 70 | case HTTP_MSG_HDR_L2_LWS: return "MSG_HDR_L2_LWS"; |
| 71 | case HTTP_MSG_LAST_LF: return "MSG_LAST_LF"; |
| 72 | case HTTP_MSG_ERROR: return "MSG_ERROR"; |
| 73 | case HTTP_MSG_BODY: return "MSG_BODY"; |
| 74 | case HTTP_MSG_100_SENT: return "MSG_100_SENT"; |
| 75 | case HTTP_MSG_CHUNK_SIZE: return "MSG_CHUNK_SIZE"; |
| 76 | case HTTP_MSG_DATA: return "MSG_DATA"; |
| 77 | case HTTP_MSG_CHUNK_CRLF: return "MSG_CHUNK_CRLF"; |
| 78 | case HTTP_MSG_TRAILERS: return "MSG_TRAILERS"; |
| 79 | case HTTP_MSG_ENDING: return "MSG_ENDING"; |
| 80 | case HTTP_MSG_DONE: return "MSG_DONE"; |
| 81 | case HTTP_MSG_CLOSING: return "MSG_CLOSING"; |
| 82 | case HTTP_MSG_CLOSED: return "MSG_CLOSED"; |
| 83 | case HTTP_MSG_TUNNEL: return "MSG_TUNNEL"; |
| 84 | default: return "MSG_??????"; |
| 85 | } |
| 86 | } |
| 87 | |
Willy Tarreau | 801250e | 2018-09-11 11:45:04 +0200 | [diff] [blame] | 88 | /* for debugging, reports the HTTP/1 message state name */ |
Dirkjan Bussink | c26c72d | 2018-09-14 14:30:25 +0200 | [diff] [blame] | 89 | static inline const char *h1m_state_str(enum h1m_state msg_state) |
Willy Tarreau | 801250e | 2018-09-11 11:45:04 +0200 | [diff] [blame] | 90 | { |
| 91 | switch (msg_state) { |
| 92 | case H1_MSG_RQBEFORE: return "MSG_RQBEFORE"; |
| 93 | case H1_MSG_RQBEFORE_CR: return "MSG_RQBEFORE_CR"; |
| 94 | case H1_MSG_RQMETH: return "MSG_RQMETH"; |
| 95 | case H1_MSG_RQMETH_SP: return "MSG_RQMETH_SP"; |
| 96 | case H1_MSG_RQURI: return "MSG_RQURI"; |
| 97 | case H1_MSG_RQURI_SP: return "MSG_RQURI_SP"; |
| 98 | case H1_MSG_RQVER: return "MSG_RQVER"; |
| 99 | case H1_MSG_RQLINE_END: return "MSG_RQLINE_END"; |
| 100 | case H1_MSG_RPBEFORE: return "MSG_RPBEFORE"; |
| 101 | case H1_MSG_RPBEFORE_CR: return "MSG_RPBEFORE_CR"; |
| 102 | case H1_MSG_RPVER: return "MSG_RPVER"; |
| 103 | case H1_MSG_RPVER_SP: return "MSG_RPVER_SP"; |
| 104 | case H1_MSG_RPCODE: return "MSG_RPCODE"; |
| 105 | case H1_MSG_RPCODE_SP: return "MSG_RPCODE_SP"; |
| 106 | case H1_MSG_RPREASON: return "MSG_RPREASON"; |
| 107 | case H1_MSG_RPLINE_END: return "MSG_RPLINE_END"; |
| 108 | case H1_MSG_HDR_FIRST: return "MSG_HDR_FIRST"; |
| 109 | case H1_MSG_HDR_NAME: return "MSG_HDR_NAME"; |
| 110 | case H1_MSG_HDR_COL: return "MSG_HDR_COL"; |
| 111 | case H1_MSG_HDR_L1_SP: return "MSG_HDR_L1_SP"; |
| 112 | case H1_MSG_HDR_L1_LF: return "MSG_HDR_L1_LF"; |
| 113 | case H1_MSG_HDR_L1_LWS: return "MSG_HDR_L1_LWS"; |
| 114 | case H1_MSG_HDR_VAL: return "MSG_HDR_VAL"; |
| 115 | case H1_MSG_HDR_L2_LF: return "MSG_HDR_L2_LF"; |
| 116 | case H1_MSG_HDR_L2_LWS: return "MSG_HDR_L2_LWS"; |
| 117 | case H1_MSG_LAST_LF: return "MSG_LAST_LF"; |
Willy Tarreau | 801250e | 2018-09-11 11:45:04 +0200 | [diff] [blame] | 118 | case H1_MSG_CHUNK_SIZE: return "MSG_CHUNK_SIZE"; |
| 119 | case H1_MSG_DATA: return "MSG_DATA"; |
| 120 | case H1_MSG_CHUNK_CRLF: return "MSG_CHUNK_CRLF"; |
| 121 | case H1_MSG_TRAILERS: return "MSG_TRAILERS"; |
Willy Tarreau | 801250e | 2018-09-11 11:45:04 +0200 | [diff] [blame] | 122 | case H1_MSG_DONE: return "MSG_DONE"; |
Willy Tarreau | 801250e | 2018-09-11 11:45:04 +0200 | [diff] [blame] | 123 | case H1_MSG_TUNNEL: return "MSG_TUNNEL"; |
| 124 | default: return "MSG_??????"; |
| 125 | } |
| 126 | } |
| 127 | |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 128 | /* This function may be called only in HTTP_MSG_CHUNK_CRLF. It reads the CRLF or |
| 129 | * a possible LF alone at the end of a chunk. The caller should adjust msg->next |
| 130 | * in order to include this part into the next forwarding phase. Note that the |
Willy Tarreau | c0973c6 | 2018-06-14 15:53:21 +0200 | [diff] [blame] | 131 | * caller must ensure that head+start points to the first byte to parse. It |
| 132 | * returns the number of bytes parsed on success, so the caller can set msg_state |
| 133 | * to HTTP_MSG_CHUNK_SIZE. If not enough data are available, the function does not |
Willy Tarreau | b289256 | 2017-09-21 11:33:54 +0200 | [diff] [blame] | 134 | * change anything and returns zero. Otherwise it returns a negative value |
| 135 | * indicating the error positionn relative to <stop>. Note: this function is |
| 136 | * designed to parse wrapped CRLF at the end of the buffer. |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 137 | */ |
Willy Tarreau | b289256 | 2017-09-21 11:33:54 +0200 | [diff] [blame] | 138 | static inline int h1_skip_chunk_crlf(const struct buffer *buf, int start, int stop) |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 139 | { |
Willy Tarreau | c0973c6 | 2018-06-14 15:53:21 +0200 | [diff] [blame] | 140 | const char *ptr = b_peek(buf, start); |
Willy Tarreau | b289256 | 2017-09-21 11:33:54 +0200 | [diff] [blame] | 141 | int bytes = 1; |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 142 | |
Joseph Herlant | 30bc509 | 2018-11-25 10:52:20 -0800 | [diff] [blame] | 143 | /* NB: we'll check data availability at the end. It's not a |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 144 | * problem because whatever we match first will be checked |
| 145 | * against the correct length. |
| 146 | */ |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 147 | if (*ptr == '\r') { |
| 148 | bytes++; |
| 149 | ptr++; |
Willy Tarreau | c0973c6 | 2018-06-14 15:53:21 +0200 | [diff] [blame] | 150 | if (ptr >= b_wrap(buf)) |
Willy Tarreau | 591d445 | 2018-06-15 17:21:00 +0200 | [diff] [blame] | 151 | ptr = b_orig(buf); |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 152 | } |
| 153 | |
Willy Tarreau | b289256 | 2017-09-21 11:33:54 +0200 | [diff] [blame] | 154 | if (bytes > stop - start) |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 155 | return 0; |
| 156 | |
Willy Tarreau | c0973c6 | 2018-06-14 15:53:21 +0200 | [diff] [blame] | 157 | if (*ptr != '\n') // negative position to stop |
| 158 | return ptr - __b_peek(buf, stop); |
Willy Tarreau | b289256 | 2017-09-21 11:33:54 +0200 | [diff] [blame] | 159 | |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 160 | return bytes; |
| 161 | } |
| 162 | |
Willy Tarreau | 84d6b7a | 2018-06-14 15:59:05 +0200 | [diff] [blame] | 163 | /* Parse the chunk size start at buf + start and stops before buf + stop. The |
| 164 | * positions are relative to the buffer's head. |
Willy Tarreau | e56cdd3 | 2017-09-21 08:36:33 +0200 | [diff] [blame] | 165 | * It returns the chunk size in <res> and the amount of bytes read this way : |
| 166 | * < 0 : error at this position relative to <stop> |
| 167 | * = 0 : not enough bytes to read a complete chunk size |
| 168 | * > 0 : number of bytes successfully read that the caller can skip |
| 169 | * On success, the caller should adjust its msg->next to point to the first |
| 170 | * byte of data after the chunk size, so that we know we can forward exactly |
| 171 | * msg->next bytes, and msg->sol to contain the exact number of bytes forming |
| 172 | * the chunk size. That way it is always possible to differentiate between the |
| 173 | * start of the body and the start of the data. Note: this function is designed |
| 174 | * to parse wrapped CRLF at the end of the buffer. |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 175 | */ |
Willy Tarreau | e56cdd3 | 2017-09-21 08:36:33 +0200 | [diff] [blame] | 176 | static inline int h1_parse_chunk_size(const struct buffer *buf, int start, int stop, unsigned int *res) |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 177 | { |
Willy Tarreau | 84d6b7a | 2018-06-14 15:59:05 +0200 | [diff] [blame] | 178 | const char *ptr = b_peek(buf, start); |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 179 | const char *ptr_old = ptr; |
Willy Tarreau | 84d6b7a | 2018-06-14 15:59:05 +0200 | [diff] [blame] | 180 | const char *end = b_wrap(buf); |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 181 | unsigned int chunk = 0; |
| 182 | |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 183 | stop -= start; // bytes left |
| 184 | start = stop; // bytes to transfer |
| 185 | |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 186 | /* The chunk size is in the following form, though we are only |
| 187 | * interested in the size and CRLF : |
| 188 | * 1*HEXDIGIT *WSP *[ ';' extensions ] CRLF |
| 189 | */ |
| 190 | while (1) { |
| 191 | int c; |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 192 | if (!stop) |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 193 | return 0; |
| 194 | c = hex2i(*ptr); |
| 195 | if (c < 0) /* not a hex digit anymore */ |
| 196 | break; |
| 197 | if (unlikely(++ptr >= end)) |
Willy Tarreau | 591d445 | 2018-06-15 17:21:00 +0200 | [diff] [blame] | 198 | ptr = b_orig(buf); |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 199 | if (unlikely(chunk & 0xF8000000)) /* integer overflow will occur if result >= 2GB */ |
| 200 | goto error; |
| 201 | chunk = (chunk << 4) + c; |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 202 | stop--; |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | /* empty size not allowed */ |
| 206 | if (unlikely(ptr == ptr_old)) |
| 207 | goto error; |
| 208 | |
| 209 | while (HTTP_IS_SPHT(*ptr)) { |
| 210 | if (++ptr >= end) |
Willy Tarreau | 591d445 | 2018-06-15 17:21:00 +0200 | [diff] [blame] | 211 | ptr = b_orig(buf); |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 212 | if (--stop == 0) |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | /* Up to there, we know that at least one byte is present at *ptr. Check |
| 217 | * for the end of chunk size. |
| 218 | */ |
| 219 | while (1) { |
| 220 | if (likely(HTTP_IS_CRLF(*ptr))) { |
| 221 | /* we now have a CR or an LF at ptr */ |
| 222 | if (likely(*ptr == '\r')) { |
| 223 | if (++ptr >= end) |
Willy Tarreau | 591d445 | 2018-06-15 17:21:00 +0200 | [diff] [blame] | 224 | ptr = b_orig(buf); |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 225 | if (--stop == 0) |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 226 | return 0; |
| 227 | } |
| 228 | |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 229 | if (*ptr != '\n') |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 230 | goto error; |
| 231 | if (++ptr >= end) |
Willy Tarreau | 591d445 | 2018-06-15 17:21:00 +0200 | [diff] [blame] | 232 | ptr = b_orig(buf); |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 233 | --stop; |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 234 | /* done */ |
| 235 | break; |
| 236 | } |
| 237 | else if (likely(*ptr == ';')) { |
| 238 | /* chunk extension, ends at next CRLF */ |
| 239 | if (++ptr >= end) |
Willy Tarreau | 591d445 | 2018-06-15 17:21:00 +0200 | [diff] [blame] | 240 | ptr = b_orig(buf); |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 241 | if (--stop == 0) |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 242 | return 0; |
| 243 | |
| 244 | while (!HTTP_IS_CRLF(*ptr)) { |
| 245 | if (++ptr >= end) |
Willy Tarreau | 591d445 | 2018-06-15 17:21:00 +0200 | [diff] [blame] | 246 | ptr = b_orig(buf); |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 247 | if (--stop == 0) |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 248 | return 0; |
| 249 | } |
| 250 | /* we have a CRLF now, loop above */ |
| 251 | continue; |
| 252 | } |
| 253 | else |
| 254 | goto error; |
| 255 | } |
| 256 | |
| 257 | /* OK we found our CRLF and now <ptr> points to the next byte, which may |
Willy Tarreau | e56cdd3 | 2017-09-21 08:36:33 +0200 | [diff] [blame] | 258 | * or may not be present. Let's return the number of bytes parsed. |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 259 | */ |
Willy Tarreau | e56cdd3 | 2017-09-21 08:36:33 +0200 | [diff] [blame] | 260 | *res = chunk; |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 261 | return start - stop; |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 262 | error: |
Willy Tarreau | e56cdd3 | 2017-09-21 08:36:33 +0200 | [diff] [blame] | 263 | *res = 0; // just to stop gcc's -Wuninitialized warning :-( |
Willy Tarreau | b15e3fe | 2017-11-10 11:17:08 +0100 | [diff] [blame] | 264 | return -stop; |
Willy Tarreau | db4893d | 2017-09-21 08:40:02 +0200 | [diff] [blame] | 265 | } |
| 266 | |
Willy Tarreau | 7f437ff | 2018-09-11 13:51:19 +0200 | [diff] [blame] | 267 | /* initializes an H1 message for a request */ |
| 268 | static inline struct h1m *h1m_init_req(struct h1m *h1m) |
Willy Tarreau | 4093a4d | 2017-09-21 11:46:43 +0200 | [diff] [blame] | 269 | { |
Willy Tarreau | 801250e | 2018-09-11 11:45:04 +0200 | [diff] [blame] | 270 | h1m->state = H1_MSG_RQBEFORE; |
Willy Tarreau | b3b0152 | 2018-09-11 11:51:31 +0200 | [diff] [blame] | 271 | h1m->next = 0; |
Willy Tarreau | ccaf233 | 2018-09-11 16:47:23 +0200 | [diff] [blame] | 272 | h1m->flags = H1_MF_NONE; |
Willy Tarreau | 4093a4d | 2017-09-21 11:46:43 +0200 | [diff] [blame] | 273 | h1m->curr_len = 0; |
| 274 | h1m->body_len = 0; |
Willy Tarreau | bbf3823 | 2018-09-12 09:08:54 +0200 | [diff] [blame] | 275 | h1m->err_pos = -2; |
Willy Tarreau | 4093a4d | 2017-09-21 11:46:43 +0200 | [diff] [blame] | 276 | h1m->err_state = 0; |
| 277 | return h1m; |
| 278 | } |
Willy Tarreau | 0da5b3b | 2017-09-21 09:30:46 +0200 | [diff] [blame] | 279 | |
Willy Tarreau | 7f437ff | 2018-09-11 13:51:19 +0200 | [diff] [blame] | 280 | /* initializes an H1 message for a response */ |
| 281 | static inline struct h1m *h1m_init_res(struct h1m *h1m) |
| 282 | { |
| 283 | h1m->state = H1_MSG_RPBEFORE; |
| 284 | h1m->next = 0; |
Willy Tarreau | ccaf233 | 2018-09-11 16:47:23 +0200 | [diff] [blame] | 285 | h1m->flags = H1_MF_RESP; |
Willy Tarreau | 7f437ff | 2018-09-11 13:51:19 +0200 | [diff] [blame] | 286 | h1m->curr_len = 0; |
| 287 | h1m->body_len = 0; |
Willy Tarreau | bbf3823 | 2018-09-12 09:08:54 +0200 | [diff] [blame] | 288 | h1m->err_pos = -2; |
Willy Tarreau | 7f437ff | 2018-09-11 13:51:19 +0200 | [diff] [blame] | 289 | h1m->err_state = 0; |
| 290 | return h1m; |
| 291 | } |
| 292 | |
Willy Tarreau | 0da5b3b | 2017-09-21 09:30:46 +0200 | [diff] [blame] | 293 | #endif /* _PROTO_H1_H */ |