Christopher Faulet | 47596d3 | 2018-10-22 09:17:28 +0200 | [diff] [blame] | 1 | /* |
| 2 | * include/types/http_htx.h |
| 3 | * 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 | |
| 23 | #ifndef _PROTO_HTTP_HTX_H |
| 24 | #define _PROTO_HTTP_HTX_H |
| 25 | |
| 26 | #include <common/buf.h> |
Christopher Faulet | a7b677c | 2018-11-29 16:48:49 +0100 | [diff] [blame] | 27 | #include <common/ist.h> |
Christopher Faulet | 8dd33e1 | 2020-05-05 07:42:42 +0200 | [diff] [blame] | 28 | #include <common/regex.h> |
Christopher Faulet | 47596d3 | 2018-10-22 09:17:28 +0200 | [diff] [blame] | 29 | |
Christopher Faulet | 47596d3 | 2018-10-22 09:17:28 +0200 | [diff] [blame] | 30 | #include <types/http_htx.h> |
| 31 | |
Christopher Faulet | f734638 | 2019-07-17 22:02:08 +0200 | [diff] [blame] | 32 | extern struct buffer http_err_chunks[HTTP_ERR_SIZE]; |
Christopher Faulet | 554c0eb | 2020-01-14 12:00:28 +0100 | [diff] [blame] | 33 | extern struct list http_errors_list; |
Christopher Faulet | a7b677c | 2018-11-29 16:48:49 +0100 | [diff] [blame] | 34 | |
Christopher Faulet | 297fbb4 | 2019-05-13 14:41:27 +0200 | [diff] [blame] | 35 | struct htx_sl *http_get_stline(struct htx *htx); |
Christopher Faulet | 727a3f1 | 2020-02-07 16:39:41 +0100 | [diff] [blame] | 36 | size_t http_get_hdrs_size(struct htx *htx); |
Christopher Faulet | 47596d3 | 2018-10-22 09:17:28 +0200 | [diff] [blame] | 37 | int http_find_header(const struct htx *htx, const struct ist name, struct http_hdr_ctx *ctx, int full); |
Christopher Faulet | 8dd33e1 | 2020-05-05 07:42:42 +0200 | [diff] [blame] | 38 | int http_find_str_header(const struct htx *htx, const struct ist name, struct http_hdr_ctx *ctx, int full); |
| 39 | int http_find_pfx_header(const struct htx *htx, const struct ist prefix, struct http_hdr_ctx *ctx, int full); |
| 40 | int http_find_sfx_header(const struct htx *htx, const struct ist suffix, struct http_hdr_ctx *ctx, int full); |
| 41 | int http_find_sub_header(const struct htx *htx, const struct ist sub, struct http_hdr_ctx *ctx, int full); |
| 42 | int http_match_header(const struct htx *htx, const struct my_regex *re, struct http_hdr_ctx *ctx, int full); |
Christopher Faulet | 47596d3 | 2018-10-22 09:17:28 +0200 | [diff] [blame] | 43 | int http_add_header(struct htx *htx, const struct ist n, const struct ist v); |
Christopher Faulet | f1ba18d | 2018-11-26 21:37:08 +0100 | [diff] [blame] | 44 | int http_replace_stline(struct htx *htx, const struct ist p1, const struct ist p2, const struct ist p3); |
Christopher Faulet | e010c80 | 2018-10-24 10:36:45 +0200 | [diff] [blame] | 45 | int http_replace_req_meth(struct htx *htx, const struct ist meth); |
| 46 | int http_replace_req_uri(struct htx *htx, const struct ist uri); |
| 47 | int http_replace_req_path(struct htx *htx, const struct ist path); |
| 48 | int http_replace_req_query(struct htx *htx, const struct ist query); |
| 49 | int http_replace_res_status(struct htx *htx, const struct ist status); |
| 50 | int http_replace_res_reason(struct htx *htx, const struct ist reason); |
Christopher Faulet | 47596d3 | 2018-10-22 09:17:28 +0200 | [diff] [blame] | 51 | int http_replace_header_value(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist data); |
| 52 | int http_replace_header(struct htx *htx, struct http_hdr_ctx *ctx, const struct ist name, const struct ist value); |
| 53 | int http_remove_header(struct htx *htx, struct http_hdr_ctx *ctx); |
Christopher Faulet | 1543d44 | 2020-04-28 19:57:29 +0200 | [diff] [blame] | 54 | int http_update_authority(struct htx *htx, struct htx_sl *sl, const struct ist host); |
| 55 | int http_update_host(struct htx *htx, struct htx_sl *sl, const struct ist uri); |
| 56 | |
Christopher Faulet | 7ff1cea | 2018-10-24 10:39:35 +0200 | [diff] [blame] | 57 | unsigned int http_get_htx_hdr(const struct htx *htx, const struct ist hdr, |
| 58 | int occ, struct http_hdr_ctx *ctx, char **vptr, size_t *vlen); |
| 59 | unsigned int http_get_htx_fhdr(const struct htx *htx, const struct ist hdr, |
| 60 | int occ, struct http_hdr_ctx *ctx, char **vptr, size_t *vlen); |
Christopher Faulet | 90cc481 | 2019-07-22 16:49:30 +0200 | [diff] [blame] | 61 | int http_str_to_htx(struct buffer *buf, struct ist raw); |
Christopher Faulet | 47596d3 | 2018-10-22 09:17:28 +0200 | [diff] [blame] | 62 | |
Christopher Faulet | 1863064 | 2020-05-12 18:57:28 +0200 | [diff] [blame] | 63 | void release_http_reply(struct http_reply *http_reply); |
Christopher Faulet | 7eea241 | 2020-05-13 15:02:59 +0200 | [diff] [blame] | 64 | int http_check_http_reply(struct http_reply *reply, struct proxy*px, char **errmsg); |
Christopher Faulet | 47e791e | 2020-05-13 14:36:55 +0200 | [diff] [blame] | 65 | struct http_reply *http_parse_http_reply(const char **args, int *orig_arg, struct proxy *px, |
| 66 | int default_status, char **errmsg); |
Christopher Faulet | 1863064 | 2020-05-12 18:57:28 +0200 | [diff] [blame] | 67 | |
Christopher Faulet | 5885775 | 2020-01-15 15:19:50 +0100 | [diff] [blame] | 68 | struct buffer *http_load_errorfile(const char *file, char **errmsg); |
| 69 | struct buffer *http_load_errormsg(const char *key, const struct ist msg, char **errmsg); |
| 70 | struct buffer *http_parse_errorfile(int status, const char *file, char **errmsg); |
| 71 | struct buffer *http_parse_errorloc(int errloc, int status, const char *url, char **errmsg); |
Christopher Faulet | 76edc0f | 2020-01-13 15:52:01 +0100 | [diff] [blame] | 72 | int proxy_dup_default_conf_errors(struct proxy *curpx, struct proxy *defpx, char **errmsg); |
| 73 | void proxy_release_conf_errors(struct proxy *px); |
Christopher Faulet | 5031ef5 | 2020-01-15 11:22:07 +0100 | [diff] [blame] | 74 | |
Christopher Faulet | 47596d3 | 2018-10-22 09:17:28 +0200 | [diff] [blame] | 75 | #endif /* _PROTO_HTTP_HTX_H */ |