haproxy/include/haproxy/http_ext.h
Aurelien DARRAGON b2e2ec51b3 MEDIUM: proxy/http_ext: implement dynamic http_ext
proxy http-only options implemented in http_ext were statically stored
within proxy struct.

We're making some changes so that http_ext are now stored in a dynamically
allocated structs.
http_ext related structs are only allocated when needed to save some space
whenever possible, and they are automatically freed upon proxy deletion.

Related PX_O_HTTP{7239,XFF,XOT) option flags were removed because we're now
considering an http_ext option as 'active' if it is allocated (ptr is not NULL)

A few checks (and BUG_ON) were added to make these changes safe because
it adds some (acceptable) complexity to the previous design.

Also, proxy.http was renamed to proxy.http_ext to make things more explicit.
2023-01-27 15:18:59 +01:00

59 lines
2.4 KiB
C

/*
* include/haproxy/http_ext.h
* Functions for Version-agnostic and implementation-agnostic HTTP extensions
*
* Copyright 2022 HAProxy Technologies
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, version 2.1
* exclusively.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _HAPROXY_HTTPEXT_H
#define _HAPROXY_HTTPEXT_H
#include <haproxy/http_ext-t.h>
#include <haproxy/channel-t.h>
#include <haproxy/proxy-t.h>
#include <haproxy/stream-t.h>
int http_validate_7239_header(struct ist hdr, int required_steps, struct forwarded_header_ctx *ctx);
int http_handle_7239_header(struct stream *s, struct channel *req);
int http_handle_xff_header(struct stream *s, struct channel *req);
int http_handle_xot_header(struct stream *s, struct channel *req);
int proxy_http_parse_7239(char **args, int cur_arg, struct proxy *curproxy, const struct proxy *defpx, const char *file, int linenum);
int proxy_http_compile_7239(struct proxy *curproxy);
int proxy_http_parse_xff(char **args, int cur_arg, struct proxy *curproxy, const struct proxy *defpx, const char *file, int linenum);
int proxy_http_parse_xot(char **args, int cur_arg, struct proxy *curproxy, const struct proxy *defpx, const char *file, int linenum);
int http_ext_7239_prepare(struct proxy *cur);
int http_ext_xff_prepare(struct proxy *cur);
int http_ext_xot_prepare(struct proxy *cur);
void http_ext_7239_dup(const struct proxy *def, struct proxy *cpy);
void http_ext_xff_dup(const struct proxy *def, struct proxy *cpy);
void http_ext_xot_dup(const struct proxy *def, struct proxy *cpy);
void http_ext_7239_clean(struct proxy *cur);
void http_ext_xff_clean(struct proxy *cur);
void http_ext_xot_clean(struct proxy *cur);
int http_ext_prepare(struct proxy *cur);
void http_ext_dup(const struct proxy *def, struct proxy *cpy);
void http_ext_clean(struct proxy *cur);
void http_ext_softclean(struct proxy *cur);
#endif /* !_HAPROXY_HTTPEXT_H */