blob: f7becff268887c6d7723c82a8845252e6999917c [file] [log] [blame]
Christopher Faulet47596d32018-10-22 09:17:28 +02001/*
Willy Tarreau87735332020-06-04 09:08:41 +02002 * include/haproxy/http_htx-t.h
Christopher Faulet47596d32018-10-22 09:17:28 +02003 * This file defines function prototypes for HTTP manipulation using the
4 * internal representation.
5 *
6 * Copyright (C) 2018 HAProxy Technologies, Christopher Faulet <cfaulet@haproxy.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation, version 2.1
11 * exclusively.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
Willy Tarreau87735332020-06-04 09:08:41 +020023#ifndef _HAPROXY_HTTP_HTX_H
24#define _HAPROXY_HTTP_HTX_H
Christopher Faulet47596d32018-10-22 09:17:28 +020025
Willy Tarreaueb6f7012020-05-27 16:21:26 +020026#include <import/ist.h>
Willy Tarreau87735332020-06-04 09:08:41 +020027#include <haproxy/buf-t.h>
28#include <haproxy/http_htx-t.h>
Willy Tarreaua264d962020-06-04 22:29:18 +020029#include <haproxy/proxy-t.h>
Willy Tarreau7cd8b6e2020-06-02 17:32:26 +020030#include <haproxy/regex-t.h>
Christopher Faulet47596d32018-10-22 09:17:28 +020031
Christopher Fauletf7346382019-07-17 22:02:08 +020032extern struct buffer http_err_chunks[HTTP_ERR_SIZE];
Christopher Faulet1b13eca2020-05-14 09:54:26 +020033extern struct http_reply http_err_replies[HTTP_ERR_SIZE];
Christopher Faulet554c0eb2020-01-14 12:00:28 +010034extern struct list http_errors_list;
Christopher Fauleta7b677c2018-11-29 16:48:49 +010035
Tim Duesterhusb8ee8942021-04-03 20:39:20 +020036struct htx_sl *http_get_stline(const struct htx *htx);
Christopher Faulet727a3f12020-02-07 16:39:41 +010037size_t http_get_hdrs_size(struct htx *htx);
Christopher Faulet47596d32018-10-22 09:17:28 +020038int http_find_header(const struct htx *htx, const struct ist name, struct http_hdr_ctx *ctx, int full);
Christopher Faulet8dd33e12020-05-05 07:42:42 +020039int http_find_str_header(const struct htx *htx, const struct ist name, struct http_hdr_ctx *ctx, int full);
40int http_find_pfx_header(const struct htx *htx, const struct ist prefix, struct http_hdr_ctx *ctx, int full);
41int http_find_sfx_header(const struct htx *htx, const struct ist suffix, struct http_hdr_ctx *ctx, int full);
42int http_find_sub_header(const struct htx *htx, const struct ist sub, struct http_hdr_ctx *ctx, int full);
43int http_match_header(const struct htx *htx, const struct my_regex *re, struct http_hdr_ctx *ctx, int full);
Christopher Faulet47596d32018-10-22 09:17:28 +020044int http_add_header(struct htx *htx, const struct ist n, const struct ist v);
Christopher Fauletf1ba18d2018-11-26 21:37:08 +010045int http_replace_stline(struct htx *htx, const struct ist p1, const struct ist p2, const struct ist p3);
Christopher Faulete010c802018-10-24 10:36:45 +020046int http_replace_req_meth(struct htx *htx, const struct ist meth);
47int http_replace_req_uri(struct htx *htx, const struct ist uri);
Christopher Fauletb8ce5052020-08-31 16:11:57 +020048int http_replace_req_path(struct htx *htx, const struct ist path, int with_qs);
Christopher Faulete010c802018-10-24 10:36:45 +020049int http_replace_req_query(struct htx *htx, const struct ist query);
Christopher Fauletbde2c4c2020-08-31 16:43:34 +020050int http_replace_res_status(struct htx *htx, const struct ist status, const struct ist reason);
Christopher Faulete010c802018-10-24 10:36:45 +020051int http_replace_res_reason(struct htx *htx, const struct ist reason);
Christopher Faulet47596d32018-10-22 09:17:28 +020052int http_replace_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist data);
53int http_replace_header(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist name, const struct ist value);
54int http_remove_header(struct htx *htx, struct http_hdr_ctx *ctx);
Christopher Faulet1543d442020-04-28 19:57:29 +020055int http_update_authority(struct htx *htx, struct htx_sl *sl, const struct ist host);
56int http_update_host(struct htx *htx, struct htx_sl *sl, const struct ist uri);
57
Christopher Faulet7ff1cea2018-10-24 10:39:35 +020058unsigned int http_get_htx_hdr(const struct htx *htx, const struct ist hdr,
59 int occ, struct http_hdr_ctx *ctx, char **vptr, size_t *vlen);
60unsigned int http_get_htx_fhdr(const struct htx *htx, const struct ist hdr,
61 int occ, struct http_hdr_ctx *ctx, char **vptr, size_t *vlen);
Christopher Fauleta66adf42020-11-05 22:43:41 +010062int http_str_to_htx(struct buffer *buf, struct ist raw, char **errmsg);
Christopher Faulet47596d32018-10-22 09:17:28 +020063
Christopher Faulet18630642020-05-12 18:57:28 +020064void release_http_reply(struct http_reply *http_reply);
Christopher Faulet7eea2412020-05-13 15:02:59 +020065int http_check_http_reply(struct http_reply *reply, struct proxy*px, char **errmsg);
Christopher Faulet47e791e2020-05-13 14:36:55 +020066struct http_reply *http_parse_http_reply(const char **args, int *orig_arg, struct proxy *px,
67 int default_status, char **errmsg);
Christopher Faulet18630642020-05-12 18:57:28 +020068
Amaury Denoyelleca87a9a2021-07-07 10:49:26 +020069int http_scheme_based_normalize(struct htx *htx);
70
Christopher Faulet58857752020-01-15 15:19:50 +010071struct buffer *http_load_errorfile(const char *file, char **errmsg);
72struct buffer *http_load_errormsg(const char *key, const struct ist msg, char **errmsg);
73struct buffer *http_parse_errorfile(int status, const char *file, char **errmsg);
74struct buffer *http_parse_errorloc(int errloc, int status, const char *url, char **errmsg);
Willy Tarreau016255a2021-02-12 08:40:29 +010075int proxy_dup_default_conf_errors(struct proxy *curpx, const struct proxy *defpx, char **errmsg);
Christopher Faulet76edc0f2020-01-13 15:52:01 +010076void proxy_release_conf_errors(struct proxy *px);
Christopher Faulet5031ef52020-01-15 11:22:07 +010077
Willy Tarreau87735332020-06-04 09:08:41 +020078#endif /* _HAPROXY_HTTP_HTX_H */