blob: e360a5a40932eaff941e2e267373522086cef102 [file] [log] [blame]
Willy Tarreaubaaee002006-06-26 02:48:02 +02001/*
Willy Tarreaub0c9bc42009-10-04 15:56:38 +02002 * include/proto/proto_http.h
3 * This file contains HTTP protocol definitions.
4 *
Willy Tarreauff011f22011-01-06 17:51:27 +01005 * Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu
Willy Tarreaub0c9bc42009-10-04 15:56:38 +02006 *
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 Tarreaubaaee002006-06-26 02:48:02 +020021
22#ifndef _PROTO_PROTO_HTTP_H
23#define _PROTO_PROTO_HTTP_H
24
Willy Tarreaue3ba5f02006-06-29 18:54:54 +020025#include <common/config.h>
Christopher Faulet711ed6a2019-07-16 14:16:10 +020026#include <common/htx.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020027#include <types/proto_http.h>
Willy Tarreau87b09662015-04-03 00:22:06 +020028#include <types/stream.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020029#include <types/task.h>
Willy Tarreau3ee83442018-06-15 16:42:02 +020030#include <proto/channel.h>
Christopher Fauletf0216da2018-12-14 13:44:53 +010031#include <proto/stream.h>
Willy Tarreaubaaee002006-06-26 02:48:02 +020032
Willy Tarreau79e57332018-10-02 16:01:16 +020033extern struct pool_head *pool_head_uniqueid;
34
Christopher Faulete0768eb2018-10-03 16:38:02 +020035int htx_wait_for_request(struct stream *s, struct channel *req, int an_bit);
36int htx_process_req_common(struct stream *s, struct channel *req, int an_bit, struct proxy *px);
37int htx_process_request(struct stream *s, struct channel *req, int an_bit);
38int htx_process_tarpit(struct stream *s, struct channel *req, int an_bit);
39int htx_wait_for_request_body(struct stream *s, struct channel *req, int an_bit);
Christopher Faulete0768eb2018-10-03 16:38:02 +020040int htx_wait_for_response(struct stream *s, struct channel *rep, int an_bit);
41int htx_process_res_common(struct stream *s, struct channel *rep, int an_bit, struct proxy *px);
42int htx_request_forward_body(struct stream *s, struct channel *req, int an_bit);
43int htx_response_forward_body(struct stream *s, struct channel *res, int an_bit);
Christopher Fauletf2824e62018-10-01 12:12:37 +020044int htx_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struct http_txn *txn);
Christopher Faulet72333522018-10-24 11:25:02 +020045int 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 Faulet8d8ac192018-10-24 11:27:39 +020047int htx_req_replace_stline(int action, const char *replace, int len,
48 struct proxy *px, struct stream *s);
49void htx_res_set_status(unsigned int status, const char *reason, struct stream *s);
Christopher Faulet25a02f62018-10-24 12:00:25 +020050void htx_check_request_for_cacheability(struct stream *s, struct channel *req);
51void htx_check_response_for_cacheability(struct stream *s, struct channel *res);
Christopher Faulet64159df2018-10-24 21:15:35 +020052int htx_send_name_header(struct stream *s, struct proxy *be, const char *srv_name);
Christopher Fauletfefc73d2018-10-24 21:18:04 +020053void htx_perform_server_redirect(struct stream *s, struct stream_interface *si);
Christopher Faulet0f226952018-10-22 09:29:56 +020054void htx_server_error(struct stream *s, struct stream_interface *si, int err, int finst, const struct buffer *msg);
55void htx_reply_and_close(struct stream *s, short status, struct buffer *msg);
Christopher Faulet304cc402019-07-15 15:46:28 +020056void htx_return_srv_error(struct stream *s, struct stream_interface *si);
Christopher Fauleta7b677c2018-11-29 16:48:49 +010057struct buffer *htx_error_message(struct stream *s);
Christopher Faulete0768eb2018-10-03 16:38:02 +020058
Willy Tarreaueee5b512015-04-03 23:46:31 +020059struct http_txn *http_alloc_txn(struct stream *s);
Willy Tarreau87b09662015-04-03 00:22:06 +020060void http_init_txn(struct stream *s);
61void http_end_txn(struct stream *s);
62void http_reset_txn(struct stream *s);
Willy Tarreau2d8e4852014-04-17 20:08:17 +020063
Willy Tarreau326e27e2018-12-11 11:04:56 +010064/* for debugging, reports the HTTP/1 message state name (legacy version) */
65static 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 Tarreau326e27e2018-12-11 11:04:56 +010069 case HTTP_MSG_RPBEFORE: return "MSG_RPBEFORE";
Willy Tarreau326e27e2018-12-11 11:04:56 +010070 case HTTP_MSG_ERROR: return "MSG_ERROR";
71 case HTTP_MSG_BODY: return "MSG_BODY";
Willy Tarreau326e27e2018-12-11 11:04:56 +010072 case HTTP_MSG_DATA: return "MSG_DATA";
Willy Tarreau326e27e2018-12-11 11:04:56 +010073 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 Tarreaubaaee002006-06-26 02:48:02 +020082#endif /* _PROTO_PROTO_HTTP_H */
83
84/*
85 * Local variables:
86 * c-indent-level: 8
87 * c-basic-offset: 8
88 * End:
89 */