"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "include/common/h2.h" between
haproxy-1.9.3.tar.gz and haproxy-1.9.4.tar.gz

About: HAProxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments.

h2.h  (haproxy-1.9.3):h2.h  (haproxy-1.9.4)
skipping to change at line 177 skipping to change at line 177
#define H2_CONN_PREFACE \ #define H2_CONN_PREFACE \
"\x50\x52\x49\x20\x2a\x20\x48\x54" \ "\x50\x52\x49\x20\x2a\x20\x48\x54" \
"\x54\x50\x2f\x32\x2e\x30\x0d\x0a" \ "\x54\x50\x2f\x32\x2e\x30\x0d\x0a" \
"\x0d\x0a\x53\x4d\x0d\x0a\x0d\x0a" "\x0d\x0a\x53\x4d\x0d\x0a\x0d\x0a"
/* some flags related to protocol parsing */ /* some flags related to protocol parsing */
#define H2_MSGF_BODY 0x0001 // a body is present #define H2_MSGF_BODY 0x0001 // a body is present
#define H2_MSGF_BODY_CL 0x0002 // content-length is present #define H2_MSGF_BODY_CL 0x0002 // content-length is present
#define H2_MSGF_BODY_TUNNEL 0x0004 // a tunnel is in use (CONNECT) #define H2_MSGF_BODY_TUNNEL 0x0004 // a tunnel is in use (CONNECT)
#define H2_MAX_STREAM_ID ((1U << 31) - 1)
#define H2_MAX_FRAME_LEN ((1U << 24) - 1)
#define H2_DIR_REQ 1
#define H2_DIR_RES 2
#define H2_DIR_BOTH 3
/* constraints imposed by the protocol on each frame type, in terms of stream
* ID values, frame sizes, and direction so that most connection-level checks
* can be centralized regardless of the frame's acceptance.
*/
struct h2_frame_definition {
int32_t dir; /* 0=none, 1=request, 2=response, 3=both */
int32_t min_id; /* minimum allowed stream ID */
int32_t max_id; /* maximum allowed stream ID */
int32_t min_len; /* minimum frame length */
int32_t max_len; /* maximum frame length */
};
extern struct h2_frame_definition h2_frame_definition[H2_FT_ENTRIES];
/* various protocol processing functions */ /* various protocol processing functions */
int h2_make_h1_request(struct http_hdr *list, char *out, int osize, unsigned int *msgf); int h2_make_h1_request(struct http_hdr *list, char *out, int osize, unsigned int *msgf, unsigned long long *body_len);
int h2_make_h1_trailers(struct http_hdr *list, char *out, int osize); int h2_make_h1_trailers(struct http_hdr *list, char *out, int osize);
int h2_parse_cont_len_header(unsigned int *msgf, struct ist *value, unsigned lon g long *body_len); int h2_parse_cont_len_header(unsigned int *msgf, struct ist *value, unsigned lon g long *body_len);
int h2_make_htx_request(struct http_hdr *list, struct htx *htx, unsigned int *ms int h2_make_htx_request(struct http_hdr *list, struct htx *htx, unsigned int *ms
gf); gf, unsigned long long *body_len);
int h2_make_htx_response(struct http_hdr *list, struct htx *htx, unsigned int *m int h2_make_htx_response(struct http_hdr *list, struct htx *htx, unsigned int *m
sgf); sgf, unsigned long long *body_len);
int h2_make_htx_trailers(struct http_hdr *list, struct htx *htx); int h2_make_htx_trailers(struct http_hdr *list, struct htx *htx);
/* /*
* Some helpful debugging functions. * Some helpful debugging functions.
*/ */
/* returns a bit corresponding to the frame type */ /* returns a bit corresponding to the frame type */
static inline unsigned int h2_ft_bit(enum h2_ft ft) static inline unsigned int h2_ft_bit(enum h2_ft ft)
{ {
return 1U << ft; return 1U << ft;
skipping to change at line 213 skipping to change at line 233
case H2_FT_RST_STREAM : return "RST_STREAM"; case H2_FT_RST_STREAM : return "RST_STREAM";
case H2_FT_SETTINGS : return "SETTINGS"; case H2_FT_SETTINGS : return "SETTINGS";
case H2_FT_PUSH_PROMISE : return "PUSH_PROMISE"; case H2_FT_PUSH_PROMISE : return "PUSH_PROMISE";
case H2_FT_PING : return "PING"; case H2_FT_PING : return "PING";
case H2_FT_GOAWAY : return "GOAWAY"; case H2_FT_GOAWAY : return "GOAWAY";
case H2_FT_WINDOW_UPDATE : return "WINDOW_UPDATE"; case H2_FT_WINDOW_UPDATE : return "WINDOW_UPDATE";
default : return "_UNKNOWN_"; default : return "_UNKNOWN_";
} }
} }
/* Returns an error code if the frame is valid protocol-wise, otherwise 0. <ft>
* is the frame type (H2_FT_*), <dir> is the direction (1=req, 2=res), <id> is
* the stream ID from the frame header, <len> is the frame length from the
* header. The purpose is to be able to quickly return a PROTOCOL_ERROR or
* FRAME_SIZE_ERROR connection error even for situations where the frame will
* be ignored. <mfs> must be the max frame size currently in place for the
* protocol.
*/
static inline int h2_frame_check(enum h2_ft ft, int dir, int32_t id, int32_t len
, int32_t mfs)
{
struct h2_frame_definition *fd;
if (ft >= H2_FT_ENTRIES)
return H2_ERR_NO_ERROR; // ignore unhandled frame types
fd = &h2_frame_definition[ft];
if (!(dir & fd->dir))
return H2_ERR_PROTOCOL_ERROR;
if (id < fd->min_id || id > fd->max_id)
return H2_ERR_PROTOCOL_ERROR;
if (len < fd->min_len || len > fd->max_len)
return H2_ERR_FRAME_SIZE_ERROR;
if (len > mfs)
return H2_ERR_FRAME_SIZE_ERROR;
if (ft == H2_FT_SETTINGS && (len % 6) != 0)
return H2_ERR_FRAME_SIZE_ERROR; // RFC7540#6.5
return H2_ERR_NO_ERROR;
}
/* returns the pseudo-header <str> corresponds to among H2_PHDR_IDX_*, 0 if not a /* returns the pseudo-header <str> corresponds to among H2_PHDR_IDX_*, 0 if not a
* pseudo-header, or -1 if not a valid pseudo-header. * pseudo-header, or -1 if not a valid pseudo-header.
*/ */
static inline int h2_str_to_phdr(const struct ist str) static inline int h2_str_to_phdr(const struct ist str)
{ {
if (*str.ptr == ':') { if (*str.ptr == ':') {
if (isteq(str, ist(":path"))) return H2_PHDR_IDX_PATH; if (isteq(str, ist(":path"))) return H2_PHDR_IDX_PATH;
else if (isteq(str, ist(":method"))) return H2_PHDR_IDX_METH; else if (isteq(str, ist(":method"))) return H2_PHDR_IDX_METH;
else if (isteq(str, ist(":scheme"))) return H2_PHDR_IDX_SCHM; else if (isteq(str, ist(":scheme"))) return H2_PHDR_IDX_SCHM;
else if (isteq(str, ist(":status"))) return H2_PHDR_IDX_STAT; else if (isteq(str, ist(":status"))) return H2_PHDR_IDX_STAT;
 End of changes. 4 change blocks. 
5 lines changed or deleted 61 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)