2006-06-26 00:48:02 +00:00
|
|
|
/*
|
2009-10-04 13:56:38 +00:00
|
|
|
* include/proto/proto_http.h
|
|
|
|
* This file contains HTTP protocol definitions.
|
|
|
|
*
|
2011-01-06 16:51:27 +00:00
|
|
|
* Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu
|
2009-10-04 13:56:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
2006-06-26 00:48:02 +00:00
|
|
|
|
|
|
|
#ifndef _PROTO_PROTO_HTTP_H
|
|
|
|
#define _PROTO_PROTO_HTTP_H
|
|
|
|
|
2006-06-29 16:54:54 +00:00
|
|
|
#include <common/config.h>
|
2006-06-26 00:48:02 +00:00
|
|
|
#include <types/proto_http.h>
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
#include <types/stream.h>
|
2006-06-26 00:48:02 +00:00
|
|
|
#include <types/task.h>
|
2018-06-15 14:42:02 +00:00
|
|
|
#include <proto/channel.h>
|
2017-09-21 07:30:46 +00:00
|
|
|
#include <proto/h1.h>
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2006-12-04 01:26:12 +00:00
|
|
|
|
2018-10-02 14:01:16 +00:00
|
|
|
extern struct pool_head *pool_head_uniqueid;
|
|
|
|
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
int process_cli(struct stream *s);
|
|
|
|
int process_srv_data(struct stream *s);
|
|
|
|
int process_srv_conn(struct stream *s);
|
|
|
|
int http_wait_for_request(struct stream *s, struct channel *req, int an_bit);
|
|
|
|
int http_process_req_common(struct stream *s, struct channel *req, int an_bit, struct proxy *px);
|
|
|
|
int http_process_request(struct stream *s, struct channel *req, int an_bit);
|
|
|
|
int http_process_tarpit(struct stream *s, struct channel *req, int an_bit);
|
|
|
|
int http_wait_for_request_body(struct stream *s, struct channel *req, int an_bit);
|
2012-03-09 11:11:57 +00:00
|
|
|
int http_send_name_header(struct http_txn *txn, struct proxy* be, const char* svr_name);
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit);
|
|
|
|
int http_process_res_common(struct stream *s, struct channel *rep, int an_bit, struct proxy *px);
|
|
|
|
int http_request_forward_body(struct stream *s, struct channel *req, int an_bit);
|
|
|
|
int http_response_forward_body(struct stream *s, struct channel *res, int an_bit);
|
2018-10-02 14:01:16 +00:00
|
|
|
int http_upgrade_v09_to_v10(struct http_txn *txn);
|
2015-09-25 09:06:37 +00:00
|
|
|
void http_msg_analyzer(struct http_msg *msg, struct hdr_idx *idx);
|
2015-09-25 16:53:18 +00:00
|
|
|
void http_txn_reset_req(struct http_txn *txn);
|
|
|
|
void http_txn_reset_res(struct http_txn *txn);
|
2006-06-26 00:48:02 +00:00
|
|
|
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void debug_hdr(const char *dir, struct stream *s, const char *start, const char *end);
|
|
|
|
int apply_filter_to_req_headers(struct stream *s, struct channel *req, struct hdr_exp *exp);
|
|
|
|
int apply_filter_to_req_line(struct stream *s, struct channel *req, struct hdr_exp *exp);
|
|
|
|
int apply_filters_to_request(struct stream *s, struct channel *req, struct proxy *px);
|
|
|
|
int apply_filters_to_response(struct stream *s, struct channel *rtr, struct proxy *px);
|
|
|
|
void manage_client_side_cookies(struct stream *s, struct channel *req);
|
|
|
|
void manage_server_side_cookies(struct stream *s, struct channel *rtr);
|
2017-12-22 14:03:36 +00:00
|
|
|
void check_request_for_cacheability(struct stream *s, struct channel *chn);
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void check_response_for_cacheability(struct stream *s, struct channel *rtr);
|
2011-03-10 10:25:07 +00:00
|
|
|
int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct proxy *backend);
|
2006-12-24 16:47:20 +00:00
|
|
|
void init_proto_http();
|
2013-06-10 16:39:42 +00:00
|
|
|
int http_find_full_header2(const char *name, int len,
|
|
|
|
char *sol, struct hdr_idx *idx,
|
|
|
|
struct hdr_ctx *ctx);
|
2008-04-14 18:47:37 +00:00
|
|
|
int http_find_header2(const char *name, int len,
|
2010-01-18 13:54:04 +00:00
|
|
|
char *sol, struct hdr_idx *idx,
|
2008-04-14 18:47:37 +00:00
|
|
|
struct hdr_ctx *ctx);
|
2015-09-25 13:10:50 +00:00
|
|
|
int http_find_next_header(char *sol, struct hdr_idx *idx,
|
|
|
|
struct hdr_ctx *ctx);
|
2013-10-15 09:43:19 +00:00
|
|
|
int http_remove_header2(struct http_msg *msg, struct hdr_idx *idx, struct hdr_ctx *ctx);
|
|
|
|
int http_header_add_tail2(struct http_msg *msg, struct hdr_idx *hdr_idx, const char *text, int len);
|
2015-04-03 23:09:08 +00:00
|
|
|
int http_replace_req_line(int action, const char *replace, int len, struct proxy *px, struct stream *s);
|
2017-01-01 21:10:52 +00:00
|
|
|
void http_set_status(unsigned int status, const char *reason, struct stream *s);
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
int http_transform_header_str(struct stream* s, struct http_msg *msg, const char* name,
|
2015-03-16 10:15:50 +00:00
|
|
|
unsigned int name_len, const char *str, struct my_regex *re,
|
|
|
|
int action);
|
2016-05-18 14:17:44 +00:00
|
|
|
void inet_set_tos(int fd, const struct sockaddr_storage *from, int tos);
|
2018-10-03 13:17:28 +00:00
|
|
|
int http_handle_stats(struct stream *s, struct channel *req);
|
|
|
|
enum rule_result http_req_get_intercept_rule(struct proxy *px, struct list *rules,
|
|
|
|
struct stream *s, int *deny_status);
|
|
|
|
enum rule_result http_res_get_intercept_rule(struct proxy *px, struct list *rules,
|
|
|
|
struct stream *s);
|
|
|
|
int http_apply_redirect_rule(struct redirect_rule *rule, struct stream *s, struct http_txn *txn);
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void http_perform_server_redirect(struct stream *s, struct stream_interface *si);
|
|
|
|
void http_return_srv_error(struct stream *s, struct stream_interface *si);
|
2018-10-03 13:17:28 +00:00
|
|
|
void http_capture_headers(char *som, struct hdr_idx *idx,
|
|
|
|
char **cap, struct cap_hdr *cap_hdr);
|
2018-09-07 16:01:03 +00:00
|
|
|
void http_capture_bad_message(struct proxy *proxy, struct stream *s,
|
2012-03-09 12:39:23 +00:00
|
|
|
struct http_msg *msg,
|
2017-09-21 07:30:46 +00:00
|
|
|
enum h1_state state, struct proxy *other_end);
|
2012-04-26 13:11:51 +00:00
|
|
|
unsigned int http_get_hdr(const struct http_msg *msg, const char *hname, int hlen,
|
2011-12-16 20:35:50 +00:00
|
|
|
struct hdr_idx *idx, int occ,
|
2018-07-13 08:54:26 +00:00
|
|
|
struct hdr_ctx *ctx, char **vptr, size_t *vlen);
|
2018-10-02 14:01:16 +00:00
|
|
|
unsigned int http_get_fhdr(const struct http_msg *msg, const char *hname, int hlen,
|
|
|
|
struct hdr_idx *idx, int occ,
|
|
|
|
struct hdr_ctx *ctx, char **vptr, size_t *vlen);
|
2018-09-10 15:45:34 +00:00
|
|
|
char *http_txn_get_path(const struct http_txn *txn);
|
2006-06-26 00:48:02 +00:00
|
|
|
|
2015-04-03 21:46:31 +00:00
|
|
|
struct http_txn *http_alloc_txn(struct stream *s);
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void http_init_txn(struct stream *s);
|
|
|
|
void http_end_txn(struct stream *s);
|
|
|
|
void http_reset_txn(struct stream *s);
|
MAJOR: filters: Add filters support
This patch adds the support of filters in HAProxy. The main idea is to have a
way to "easely" extend HAProxy by adding some "modules", called filters, that
will be able to change HAProxy behavior in a programmatic way.
To do so, many entry points has been added in code to let filters to hook up to
different steps of the processing. A filter must define a flt_ops sutrctures
(see include/types/filters.h for details). This structure contains all available
callbacks that a filter can define:
struct flt_ops {
/*
* Callbacks to manage the filter lifecycle
*/
int (*init) (struct proxy *p);
void (*deinit)(struct proxy *p);
int (*check) (struct proxy *p);
/*
* Stream callbacks
*/
void (*stream_start) (struct stream *s);
void (*stream_accept) (struct stream *s);
void (*session_establish)(struct stream *s);
void (*stream_stop) (struct stream *s);
/*
* HTTP callbacks
*/
int (*http_start) (struct stream *s, struct http_msg *msg);
int (*http_start_body) (struct stream *s, struct http_msg *msg);
int (*http_start_chunk) (struct stream *s, struct http_msg *msg);
int (*http_data) (struct stream *s, struct http_msg *msg);
int (*http_last_chunk) (struct stream *s, struct http_msg *msg);
int (*http_end_chunk) (struct stream *s, struct http_msg *msg);
int (*http_chunk_trailers)(struct stream *s, struct http_msg *msg);
int (*http_end_body) (struct stream *s, struct http_msg *msg);
void (*http_end) (struct stream *s, struct http_msg *msg);
void (*http_reset) (struct stream *s, struct http_msg *msg);
int (*http_pre_process) (struct stream *s, struct http_msg *msg);
int (*http_post_process) (struct stream *s, struct http_msg *msg);
void (*http_reply) (struct stream *s, short status,
const struct chunk *msg);
};
To declare and use a filter, in the configuration, the "filter" keyword must be
used in a listener/frontend section:
frontend test
...
filter <FILTER-NAME> [OPTIONS...]
The filter referenced by the <FILTER-NAME> must declare a configuration parser
on its own name to fill flt_ops and filter_conf field in the proxy's
structure. An exemple will be provided later to make it perfectly clear.
For now, filters cannot be used in backend section. But this is only a matter of
time. Documentation will also be added later. This is the first commit of a long
list about filters.
It is possible to have several filters on the same listener/frontend. These
filters are stored in an array of at most MAX_FILTERS elements (define in
include/types/filters.h). Again, this will be replaced later by a list of
filters.
The filter API has been highly refactored. Main changes are:
* Now, HA supports an infinite number of filters per proxy. To do so, filters
are stored in list.
* Because filters are stored in list, filters state has been moved from the
channel structure to the filter structure. This is cleaner because there is no
more info about filters in channel structure.
* It is possible to defined filters on backends only. For such filters,
stream_start/stream_stop callbacks are not called. Of course, it is possible
to mix frontend and backend filters.
* Now, TCP streams are also filtered. All callbacks without the 'http_' prefix
are called for all kind of streams. In addition, 2 new callbacks were added to
filter data exchanged through a TCP stream:
- tcp_data: it is called when new data are available or when old unprocessed
data are still waiting.
- tcp_forward_data: it is called when some data can be consumed.
* New callbacks attached to channel were added:
- channel_start_analyze: it is called when a filter is ready to process data
exchanged through a channel. 2 new analyzers (a frontend and a backend)
are attached to channels to call this callback. For a frontend filter, it
is called before any other analyzer. For a backend filter, it is called
when a backend is attached to a stream. So some processing cannot be
filtered in that case.
- channel_analyze: it is called before each analyzer attached to a channel,
expects analyzers responsible for data sending.
- channel_end_analyze: it is called when all other analyzers have finished
their processing. A new analyzers is attached to channels to call this
callback. For a TCP stream, this is always the last one called. For a HTTP
one, the callback is called when a request/response ends, so it is called
one time for each request/response.
* 'session_established' callback has been removed. Everything that is done in
this callback can be handled by 'channel_start_analyze' on the response
channel.
* 'http_pre_process' and 'http_post_process' callbacks have been replaced by
'channel_analyze'.
* 'http_start' callback has been replaced by 'http_headers'. This new one is
called just before headers sending and parsing of the body.
* 'http_end' callback has been replaced by 'channel_end_analyze'.
* It is possible to set a forwarder for TCP channels. It was already possible to
do it for HTTP ones.
* Forwarders can partially consumed forwardable data. For this reason a new
HTTP message state was added before HTTP_MSG_DONE : HTTP_MSG_ENDING.
Now all filters can define corresponding callbacks (http_forward_data
and tcp_forward_data). Each filter owns 2 offsets relative to buf->p, next and
forward, to track, respectively, input data already parsed but not forwarded yet
by the filter and parsed data considered as forwarded by the filter. A any time,
we have the warranty that a filter cannot parse or forward more input than
previous ones. And, of course, it cannot forward more input than it has
parsed. 2 macros has been added to retrieve these offets: FLT_NXT and FLT_FWD.
In addition, 2 functions has been added to change the 'next size' and the
'forward size' of a filter. When a filter parses input data, it can alter these
data, so the size of these data can vary. This action has an effet on all
previous filters that must be handled. To do so, the function
'filter_change_next_size' must be called, passing the size variation. In the
same spirit, if a filter alter forwarded data, it must call the function
'filter_change_forward_size'. 'filter_change_next_size' can be called in
'http_data' and 'tcp_data' callbacks and only these ones. And
'filter_change_forward_size' can be called in 'http_forward_data' and
'tcp_forward_data' callbacks and only these ones. The data changes are the
filter responsability, but with some limitation. It must not change already
parsed/forwarded data or data that previous filters have not parsed/forwarded
yet.
Because filters can be used on backends, when we the backend is set for a
stream, we add filters defined for this backend in the filter list of the
stream. But we must only do that when the backend and the frontend of the stream
are not the same. Else same filters are added a second time leading to undefined
behavior.
The HTTP compression code had to be moved.
So it simplifies http_response_forward_body function. To do so, the way the data
are forwarded has changed. Now, a filter (and only one) can forward data. In a
commit to come, this limitation will be removed to let all filters take part to
data forwarding. There are 2 new functions that filters should use to deal with
this feature:
* flt_set_http_data_forwarder: This function sets the filter (using its id)
that will forward data for the specified HTTP message. It is possible if it
was not already set by another filter _AND_ if no data was yet forwarded
(msg->msg_state <= HTTP_MSG_BODY). It returns -1 if an error occurs.
* flt_http_data_forwarder: This function returns the filter id that will
forward data for the specified HTTP message. If there is no forwarder set, it
returns -1.
When an HTTP data forwarder is set for the response, the HTTP compression is
disabled. Of course, this is not definitive.
2015-04-30 09:48:27 +00:00
|
|
|
void http_end_txn_clean_session(struct stream *s);
|
2018-10-03 13:17:28 +00:00
|
|
|
void http_resync_states(struct stream *s);
|
|
|
|
void http_parse_connection_header(struct http_txn *txn, struct http_msg *msg, int to_del);
|
|
|
|
void http_change_connection_header(struct http_txn *txn, struct http_msg *msg, int wanted);
|
REORG/MAJOR: session: rename the "session" entity to "stream"
With HTTP/2, we'll have to support multiplexed streams. A stream is in
fact the largest part of what we currently call a session, it has buffers,
logs, etc.
In order to catch any error, this commit removes any reference to the
struct session and tries to rename most "session" occurrences in function
names to "stream" and "sess" to "strm" when that's related to a session.
The files stream.{c,h} were added and session.{c,h} removed.
The session will be reintroduced later and a few parts of the stream
will progressively be moved overthere. It will more or less contain
only what we need in an embryonic session.
Sample fetch functions and converters will have to change a bit so
that they'll use an L5 (session) instead of what's currently called
"L4" which is in fact L6 for now.
Once all changes are completed, we should see approximately this :
L7 - http_txn
L6 - stream
L5 - session
L4 - connection | applet
There will be at most one http_txn per stream, and a same session will
possibly be referenced by multiple streams. A connection will point to
a session and to a stream. The session will hold all the information
we need to keep even when we don't yet have a stream.
Some more cleanup is needed because some code was already far from
being clean. The server queue management still refers to sessions at
many places while comments talk about connections. This will have to
be cleaned up once we have a server-side connection pool manager.
Stream flags "SN_*" still need to be renamed, it doesn't seem like
any of them will need to move to the session.
2015-04-02 22:22:06 +00:00
|
|
|
void http_adjust_conn_mode(struct stream *s, struct http_txn *txn, struct http_msg *msg);
|
2009-12-22 14:03:09 +00:00
|
|
|
|
2018-10-03 13:17:28 +00:00
|
|
|
int http_msg_forward_body(struct stream *s, struct http_msg *msg);
|
|
|
|
int http_msg_forward_chunked_body(struct stream *s, struct http_msg *msg);
|
|
|
|
|
2018-07-13 09:56:34 +00:00
|
|
|
void http_reply_and_close(struct stream *s, short status, struct buffer *msg);
|
|
|
|
struct buffer *http_error_message(struct stream *s);
|
MEDIUM: http: register http-request and http-response keywords
The http_(res|req)_keywords_register() functions allow to register
new keywords.
You need to declare a keyword list:
struct http_req_action_kw_list test_kws = {
.scope = "testscope",
.kw = {
{ "test", parse_test },
{ NULL, NULL },
}
};
and a parsing function:
int parse_test(const char **args, int *cur_arg, struct proxy *px, struct http_req_rule *rule, char **err)
{
rule->action = HTTP_REQ_ACT_CUSTOM_STOP;
rule->action_ptr = action_function;
return 0;
}
http_req_keywords_register(&test_kws);
The HTTP_REQ_ACT_CUSTOM_STOP action stops evaluation of rules after
your rule, HTTP_REQ_ACT_CUSTOM_CONT permits the evaluation of rules
after your rule.
2014-04-24 12:38:37 +00:00
|
|
|
|
2009-11-29 17:12:29 +00:00
|
|
|
/* to be used when contents change in an HTTP message */
|
|
|
|
#define http_msg_move_end(msg, bytes) do { \
|
|
|
|
unsigned int _bytes = (bytes); \
|
2012-03-05 10:17:50 +00:00
|
|
|
(msg)->next += (_bytes); \
|
2009-11-29 17:12:29 +00:00
|
|
|
(msg)->sov += (_bytes); \
|
|
|
|
(msg)->eoh += (_bytes); \
|
|
|
|
} while (0)
|
|
|
|
|
2014-04-17 18:08:17 +00:00
|
|
|
|
2014-04-17 18:18:08 +00:00
|
|
|
/* Return the amount of bytes that need to be rewound before buf->p to access
|
|
|
|
* the current message's headers. The purpose is to be able to easily fetch
|
|
|
|
* the message's beginning before headers are forwarded, as well as after.
|
2014-04-17 19:14:47 +00:00
|
|
|
* The principle is that msg->eoh and msg->eol are immutable while msg->sov
|
|
|
|
* equals the sum of the two before forwarding and is zero after forwarding,
|
|
|
|
* so the difference cancels the rewinding.
|
2014-04-17 18:18:08 +00:00
|
|
|
*/
|
|
|
|
static inline int http_hdr_rewind(const struct http_msg *msg)
|
|
|
|
{
|
2014-04-17 19:14:47 +00:00
|
|
|
return msg->eoh + msg->eol - msg->sov;
|
2014-04-17 18:18:08 +00:00
|
|
|
}
|
|
|
|
|
2014-04-17 18:24:24 +00:00
|
|
|
/* Return the amount of bytes that need to be rewound before buf->p to access
|
|
|
|
* the current message's URI. The purpose is to be able to easily fetch
|
|
|
|
* the message's beginning before headers are forwarded, as well as after.
|
|
|
|
*/
|
|
|
|
static inline int http_uri_rewind(const struct http_msg *msg)
|
|
|
|
{
|
|
|
|
return http_hdr_rewind(msg) - msg->sl.rq.u;
|
|
|
|
}
|
|
|
|
|
2014-04-17 18:31:44 +00:00
|
|
|
/* Return the amount of bytes that need to be rewound before buf->p to access
|
|
|
|
* the current message's BODY. The purpose is to be able to easily fetch
|
|
|
|
* the message's beginning before headers are forwarded, as well as after.
|
|
|
|
*/
|
|
|
|
static inline int http_body_rewind(const struct http_msg *msg)
|
|
|
|
{
|
|
|
|
return http_hdr_rewind(msg) - msg->eoh - msg->eol;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return the amount of bytes that need to be rewound before buf->p to access
|
|
|
|
* the current message's DATA. The difference with the function above is that
|
|
|
|
* if a chunk is present and has already been parsed, its size is skipped so
|
|
|
|
* that the byte pointed to is the first byte of actual data. The function is
|
|
|
|
* safe for use in state HTTP_MSG_DATA regardless of whether the headers were
|
|
|
|
* already forwarded or not.
|
|
|
|
*/
|
|
|
|
static inline int http_data_rewind(const struct http_msg *msg)
|
|
|
|
{
|
|
|
|
return http_body_rewind(msg) - msg->sol;
|
|
|
|
}
|
|
|
|
|
2014-04-17 18:08:17 +00:00
|
|
|
/* Return the maximum amount of bytes that may be read after the beginning of
|
|
|
|
* the message body, according to the advertised length. The function is safe
|
|
|
|
* for use between HTTP_MSG_BODY and HTTP_MSG_DATA regardless of whether the
|
|
|
|
* headers were already forwarded or not.
|
|
|
|
*/
|
|
|
|
static inline int http_body_bytes(const struct http_msg *msg)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
|
2018-06-15 14:42:02 +00:00
|
|
|
len = ci_data(msg->chn) - msg->sov - msg->sol;
|
2014-04-17 18:08:17 +00:00
|
|
|
if (len > msg->body_len)
|
|
|
|
len = msg->body_len;
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2006-06-26 00:48:02 +00:00
|
|
|
#endif /* _PROTO_PROTO_HTTP_H */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-indent-level: 8
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|