From 45c0d98769fe7cd23608c5d547a8aa19d7120837 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 9 Mar 2012 12:11:57 +0100 Subject: [PATCH] MEDIUM: http: http_send_name_header: remove references to msg and buffer They can be deduced from txn. --- include/proto/proto_http.h | 2 +- src/proto_http.c | 9 +++++---- src/session.c | 11 +++-------- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h index 9e1dcb960..7e2151d46 100644 --- a/include/proto/proto_http.h +++ b/include/proto/proto_http.h @@ -71,7 +71,7 @@ int http_process_req_common(struct session *s, struct buffer *req, int an_bit, s int http_process_request(struct session *t, struct buffer *req, int an_bit); int http_process_tarpit(struct session *s, struct buffer *req, int an_bit); int http_process_request_body(struct session *s, struct buffer *req, int an_bit); -int http_send_name_header(struct http_txn *txn, struct http_msg *msg, struct buffer *buf, struct proxy* be, const char* svr_name); +int http_send_name_header(struct http_txn *txn, struct proxy* be, const char* svr_name); int http_wait_for_response(struct session *s, struct buffer *rep, int an_bit); int http_process_res_common(struct session *t, struct buffer *rep, int an_bit, struct proxy *px); int http_request_forward_body(struct session *s, struct buffer *req, int an_bit); diff --git a/src/proto_http.c b/src/proto_http.c index af44a0f28..17d21259f 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -3665,7 +3665,8 @@ int http_process_request_body(struct session *s, struct buffer *req, int an_bit) return 0; } -int http_send_name_header(struct http_txn *txn, struct http_msg *msg, struct buffer *buf, struct proxy* be, const char* srv_name) { +/* send a server's name with an outgoing request over an established connection */ +int http_send_name_header(struct http_txn *txn, struct proxy* be, const char* srv_name) { struct hdr_ctx ctx; @@ -3676,9 +3677,9 @@ int http_send_name_header(struct http_txn *txn, struct http_msg *msg, struct buf ctx.idx = 0; - while (http_find_header2(hdr_name, hdr_name_len, buf->p + msg->sol, &txn->hdr_idx, &ctx)) { + while (http_find_header2(hdr_name, hdr_name_len, txn->req.buf->p + txn->req.sol, &txn->hdr_idx, &ctx)) { /* remove any existing values from the header */ - http_remove_header2(msg, buf, &txn->hdr_idx, &ctx); + http_remove_header2(&txn->req, txn->req.buf, &txn->hdr_idx, &ctx); } /* Add the new header requested with the server value */ @@ -3688,7 +3689,7 @@ int http_send_name_header(struct http_txn *txn, struct http_msg *msg, struct buf *hdr_val++ = ':'; *hdr_val++ = ' '; hdr_val += strlcpy2(hdr_val, srv_name, trash + sizeof(trash) - hdr_val); - http_header_add_tail2(buf, msg, &txn->hdr_idx, trash, hdr_val - trash); + http_header_add_tail2(txn->req.buf, &txn->req, &txn->hdr_idx, trash, hdr_val - trash); return 0; } diff --git a/src/session.c b/src/session.c index ac8a8cc7c..e930dafd1 100644 --- a/src/session.c +++ b/src/session.c @@ -1954,14 +1954,9 @@ struct task *process_session(struct task *t) /* Now we can add the server name to a header (if requested) */ /* check for HTTP mode and proxy server_name_hdr_name != NULL */ if ((s->flags & SN_BE_ASSIGNED) && - (s->be->mode == PR_MODE_HTTP) && - (s->be->server_id_hdr_name != NULL)) { - - http_send_name_header(&s->txn, - &s->txn.req, - s->req, - s->be, - target_srv(&s->target)->id); + (s->be->mode == PR_MODE_HTTP) && + (s->be->server_id_hdr_name != NULL)) { + http_send_name_header(&s->txn, s->be, target_srv(&s->target)->id); } }