mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-31 18:41:39 +00:00
MINOR: proto_htx: Add function to handle the header "Expect: 100-continue"
The function htx_handle_expect_hdr() is now responsible to search the header "Expect" and send the corresponding response if necessary.
This commit is contained in:
parent
87451fd0bf
commit
4a28a536a3
@ -60,6 +60,7 @@ static void htx_manage_server_side_cookies(struct stream *s, struct channel *res
|
||||
static int htx_stats_check_uri(struct stream *s, struct http_txn *txn, struct proxy *backend);
|
||||
static int htx_handle_stats(struct stream *s, struct channel *req);
|
||||
|
||||
static int htx_handle_expect_hdr(struct stream *s, struct htx *htx, struct http_msg *msg);
|
||||
static int htx_reply_100_continue(struct stream *s);
|
||||
static int htx_reply_40x_unauthorized(struct stream *s, const char *auth_realm);
|
||||
|
||||
@ -1075,22 +1076,8 @@ int htx_wait_for_request_body(struct stream *s, struct channel *req, int an_bit)
|
||||
*/
|
||||
|
||||
if (msg->msg_state < HTTP_MSG_DATA) {
|
||||
/* If we have HTTP/1.1 and Expect: 100-continue, then we must
|
||||
* send an HTTP/1.1 100 Continue intermediate response.
|
||||
*/
|
||||
if (msg->flags & HTTP_MSGF_VER_11) {
|
||||
struct ist hdr = { .ptr = "Expect", .len = 6 };
|
||||
struct http_hdr_ctx ctx;
|
||||
|
||||
ctx.blk = NULL;
|
||||
/* Expect is allowed in 1.1, look for it */
|
||||
if (http_find_header(htx, hdr, &ctx, 0) &&
|
||||
unlikely(isteqi(ctx.value, ist2("100-continue", 12)))) {
|
||||
if (htx_reply_100_continue(s) == -1)
|
||||
goto return_bad_req;
|
||||
http_remove_header(htx, &ctx);
|
||||
}
|
||||
}
|
||||
if (htx_handle_expect_hdr(s, htx, msg) == -1)
|
||||
goto return_bad_req;
|
||||
}
|
||||
|
||||
msg->msg_state = HTTP_MSG_DATA;
|
||||
@ -5361,6 +5348,31 @@ struct buffer *htx_error_message(struct stream *s)
|
||||
}
|
||||
|
||||
|
||||
/* Handle Expect: 100-continue for HTTP/1.1 messages if necessary. It returns 0
|
||||
* on success and -1 on error.
|
||||
*/
|
||||
static int htx_handle_expect_hdr(struct stream *s, struct htx *htx, struct http_msg *msg)
|
||||
{
|
||||
/* If we have HTTP/1.1 message with a body and Expect: 100-continue,
|
||||
* then we must send an HTTP/1.1 100 Continue intermediate response.
|
||||
*/
|
||||
if (msg->msg_state == HTTP_MSG_BODY && (msg->flags & HTTP_MSGF_VER_11) &&
|
||||
(msg->flags & (HTTP_MSGF_CNT_LEN|HTTP_MSGF_TE_CHNK))) {
|
||||
struct ist hdr = { .ptr = "Expect", .len = 6 };
|
||||
struct http_hdr_ctx ctx;
|
||||
|
||||
ctx.blk = NULL;
|
||||
/* Expect is allowed in 1.1, look for it */
|
||||
if (http_find_header(htx, hdr, &ctx, 0) &&
|
||||
unlikely(isteqi(ctx.value, ist2("100-continue", 12)))) {
|
||||
if (htx_reply_100_continue(s) == -1)
|
||||
return -1;
|
||||
http_remove_header(htx, &ctx);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Send a 100-Continue response to the client. It returns 0 on success and -1
|
||||
* on error. The response channel is updated accordingly.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user