blob: 6bef553c9e830b0d51f05d2714e99557641585f5 [file] [log] [blame]
Christopher Fauletfc9cfe42019-07-16 14:54:53 +02001/*
2 * include/proto/http_ana.h
3 * This file contains HTTP protocol definitions.
4 *
5 * Copyright (C) 2000-2011 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_PROTO_HTTP_H
23#define _PROTO_PROTO_HTTP_H
24
25#include <common/config.h>
26#include <common/htx.h>
27#include <types/channel.h>
28#include <types/http_ana.h>
29#include <types/stream.h>
30
31extern struct pool_head *pool_head_uniqueid;
32
33int http_wait_for_request(struct stream *s, struct channel *req, int an_bit);
34int http_process_req_common(struct stream *s, struct channel *req, int an_bit, struct proxy *px);
35int http_process_request(struct stream *s, struct channel *req, int an_bit);
36int http_process_tarpit(struct stream *s, struct channel *req, int an_bit);
37int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit);
38int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit);
39int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, struct proxy *px);
40int http_request_forward_body(struct stream *s, struct channel *req, int an_bit);
41int http_response_forward_body(struct stream *s, struct channel *res, int an_bit);
42int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struct http_txn *txn);
Christopher Faulet92d34fe2019-12-17 09:20:34 +010043int http_replace_hdrs(struct stream* s, struct htx *htx, struct ist name, const char *str, struct my_regex *re, int full);
Christopher Fauletfc9cfe42019-07-16 14:54:53 +020044int http_req_replace_stline(int action, const char *replace, int len,
45 struct proxy *px, struct stream *s);
Christopher Faulet96bff762019-12-17 13:46:18 +010046int http_res_set_status(unsigned int status, struct ist reason, struct stream *s);
Christopher Fauletfc9cfe42019-07-16 14:54:53 +020047void http_check_request_for_cacheability(struct stream *s, struct channel *req);
48void http_check_response_for_cacheability(struct stream *s, struct channel *res);
Christopher Fauletfc9cfe42019-07-16 14:54:53 +020049void http_perform_server_redirect(struct stream *s, struct stream_interface *si);
50void http_server_error(struct stream *s, struct stream_interface *si, int err, int finst, const struct buffer *msg);
51void http_reply_and_close(struct stream *s, short status, struct buffer *msg);
52void http_return_srv_error(struct stream *s, struct stream_interface *si);
53struct buffer *http_error_message(struct stream *s);
54
55struct http_txn *http_alloc_txn(struct stream *s);
56void http_init_txn(struct stream *s);
57void http_end_txn(struct stream *s);
Christopher Fauletfc9cfe42019-07-16 14:54:53 +020058
59/* for debugging, reports the HTTP/1 message state name (legacy version) */
60static inline const char *h1_msg_state_str(enum h1_state msg_state)
61{
62 switch (msg_state) {
63 case HTTP_MSG_RQBEFORE: return "MSG_RQBEFORE";
64 case HTTP_MSG_RPBEFORE: return "MSG_RPBEFORE";
65 case HTTP_MSG_ERROR: return "MSG_ERROR";
66 case HTTP_MSG_BODY: return "MSG_BODY";
67 case HTTP_MSG_DATA: return "MSG_DATA";
68 case HTTP_MSG_ENDING: return "MSG_ENDING";
69 case HTTP_MSG_DONE: return "MSG_DONE";
70 case HTTP_MSG_CLOSING: return "MSG_CLOSING";
71 case HTTP_MSG_CLOSED: return "MSG_CLOSED";
72 case HTTP_MSG_TUNNEL: return "MSG_TUNNEL";
73 default: return "MSG_??????";
74 }
75}
76
77#endif /* _PROTO_PROTO_HTTP_H */
78
79/*
80 * Local variables:
81 * c-indent-level: 8
82 * c-basic-offset: 8
83 * End:
84 */