Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 1 | /* |
Willy Tarreau | b0c9bc4 | 2009-10-04 15:56:38 +0200 | [diff] [blame] | 2 | * include/proto/proto_http.h |
| 3 | * This file contains HTTP protocol definitions. |
| 4 | * |
Willy Tarreau | ff011f2 | 2011-01-06 17:51:27 +0100 | [diff] [blame] | 5 | * Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu |
Willy Tarreau | b0c9bc4 | 2009-10-04 15:56:38 +0200 | [diff] [blame] | 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 | */ |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 21 | |
| 22 | #ifndef _PROTO_PROTO_HTTP_H |
| 23 | #define _PROTO_PROTO_HTTP_H |
| 24 | |
Willy Tarreau | e3ba5f0 | 2006-06-29 18:54:54 +0200 | [diff] [blame] | 25 | #include <common/config.h> |
Christopher Faulet | 711ed6a | 2019-07-16 14:16:10 +0200 | [diff] [blame] | 26 | #include <common/htx.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 27 | #include <types/proto_http.h> |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 28 | #include <types/stream.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 29 | #include <types/task.h> |
Willy Tarreau | 3ee8344 | 2018-06-15 16:42:02 +0200 | [diff] [blame] | 30 | #include <proto/channel.h> |
Christopher Faulet | f0216da | 2018-12-14 13:44:53 +0100 | [diff] [blame] | 31 | #include <proto/stream.h> |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 32 | |
Willy Tarreau | 79e5733 | 2018-10-02 16:01:16 +0200 | [diff] [blame] | 33 | extern struct pool_head *pool_head_uniqueid; |
| 34 | |
Christopher Faulet | e0768eb | 2018-10-03 16:38:02 +0200 | [diff] [blame] | 35 | int htx_wait_for_request(struct stream *s, struct channel *req, int an_bit); |
| 36 | int htx_process_req_common(struct stream *s, struct channel *req, int an_bit, struct proxy *px); |
| 37 | int htx_process_request(struct stream *s, struct channel *req, int an_bit); |
| 38 | int htx_process_tarpit(struct stream *s, struct channel *req, int an_bit); |
| 39 | int htx_wait_for_request_body(struct stream *s, struct channel *req, int an_bit); |
Christopher Faulet | e0768eb | 2018-10-03 16:38:02 +0200 | [diff] [blame] | 40 | int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit); |
| 41 | int htx_process_res_common(struct stream *s, struct channel *rep, int an_bit, struct proxy *px); |
| 42 | int htx_request_forward_body(struct stream *s, struct channel *req, int an_bit); |
| 43 | int htx_response_forward_body(struct stream *s, struct channel *res, int an_bit); |
Christopher Faulet | f2824e6 | 2018-10-01 12:12:37 +0200 | [diff] [blame] | 44 | int htx_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struct http_txn *txn); |
Christopher Faulet | 7233352 | 2018-10-24 11:25:02 +0200 | [diff] [blame] | 45 | int htx_transform_header_str(struct stream* s, struct channel *chn, struct htx *htx, |
| 46 | struct ist name, const char *str, struct my_regex *re, int action); |
Christopher Faulet | 8d8ac19 | 2018-10-24 11:27:39 +0200 | [diff] [blame] | 47 | int htx_req_replace_stline(int action, const char *replace, int len, |
| 48 | struct proxy *px, struct stream *s); |
| 49 | void htx_res_set_status(unsigned int status, const char *reason, struct stream *s); |
Christopher Faulet | 25a02f6 | 2018-10-24 12:00:25 +0200 | [diff] [blame] | 50 | void htx_check_request_for_cacheability(struct stream *s, struct channel *req); |
| 51 | void htx_check_response_for_cacheability(struct stream *s, struct channel *res); |
Christopher Faulet | 64159df | 2018-10-24 21:15:35 +0200 | [diff] [blame] | 52 | int htx_send_name_header(struct stream *s, struct proxy *be, const char *srv_name); |
Christopher Faulet | fefc73d | 2018-10-24 21:18:04 +0200 | [diff] [blame] | 53 | void htx_perform_server_redirect(struct stream *s, struct stream_interface *si); |
Christopher Faulet | 0f22695 | 2018-10-22 09:29:56 +0200 | [diff] [blame] | 54 | void htx_server_error(struct stream *s, struct stream_interface *si, int err, int finst, const struct buffer *msg); |
| 55 | void htx_reply_and_close(struct stream *s, short status, struct buffer *msg); |
Christopher Faulet | 304cc40 | 2019-07-15 15:46:28 +0200 | [diff] [blame] | 56 | void htx_return_srv_error(struct stream *s, struct stream_interface *si); |
Christopher Faulet | a7b677c | 2018-11-29 16:48:49 +0100 | [diff] [blame] | 57 | struct buffer *htx_error_message(struct stream *s); |
Christopher Faulet | e0768eb | 2018-10-03 16:38:02 +0200 | [diff] [blame] | 58 | |
Willy Tarreau | eee5b51 | 2015-04-03 23:46:31 +0200 | [diff] [blame] | 59 | struct http_txn *http_alloc_txn(struct stream *s); |
Willy Tarreau | 87b0966 | 2015-04-03 00:22:06 +0200 | [diff] [blame] | 60 | void http_init_txn(struct stream *s); |
| 61 | void http_end_txn(struct stream *s); |
| 62 | void http_reset_txn(struct stream *s); |
Willy Tarreau | 2d8e485 | 2014-04-17 20:08:17 +0200 | [diff] [blame] | 63 | |
Willy Tarreau | 326e27e | 2018-12-11 11:04:56 +0100 | [diff] [blame] | 64 | /* for debugging, reports the HTTP/1 message state name (legacy version) */ |
| 65 | static inline const char *h1_msg_state_str(enum h1_state msg_state) |
| 66 | { |
| 67 | switch (msg_state) { |
| 68 | case HTTP_MSG_RQBEFORE: return "MSG_RQBEFORE"; |
Willy Tarreau | 326e27e | 2018-12-11 11:04:56 +0100 | [diff] [blame] | 69 | case HTTP_MSG_RPBEFORE: return "MSG_RPBEFORE"; |
Willy Tarreau | 326e27e | 2018-12-11 11:04:56 +0100 | [diff] [blame] | 70 | case HTTP_MSG_ERROR: return "MSG_ERROR"; |
| 71 | case HTTP_MSG_BODY: return "MSG_BODY"; |
Willy Tarreau | 326e27e | 2018-12-11 11:04:56 +0100 | [diff] [blame] | 72 | case HTTP_MSG_DATA: return "MSG_DATA"; |
Willy Tarreau | 326e27e | 2018-12-11 11:04:56 +0100 | [diff] [blame] | 73 | case HTTP_MSG_ENDING: return "MSG_ENDING"; |
| 74 | case HTTP_MSG_DONE: return "MSG_DONE"; |
| 75 | case HTTP_MSG_CLOSING: return "MSG_CLOSING"; |
| 76 | case HTTP_MSG_CLOSED: return "MSG_CLOSED"; |
| 77 | case HTTP_MSG_TUNNEL: return "MSG_TUNNEL"; |
| 78 | default: return "MSG_??????"; |
| 79 | } |
| 80 | } |
| 81 | |
Willy Tarreau | baaee00 | 2006-06-26 02:48:02 +0200 | [diff] [blame] | 82 | #endif /* _PROTO_PROTO_HTTP_H */ |
| 83 | |
| 84 | /* |
| 85 | * Local variables: |
| 86 | * c-indent-level: 8 |
| 87 | * c-basic-offset: 8 |
| 88 | * End: |
| 89 | */ |