Le 01/11/2012 16:48, Willy Tarreau a écrit :
On Thu, Nov 01, 2012 at 04:19:03PM +0100, Michael Seiferle wrote:
Hi Again,

I hope I have been testing the right stuff thing; I changed my config to look 
like so:
         http-send-name-header Host
         option forwardfor
        option http-server-close
        option httpclose
        option http-pretend-keepalive
[?]
listen  jiffy
         bind *:8181
#        reqidel ^Host:

It won't work correctly if I remove the reqidel Host line; the POST uploads 
lead to:
        ? Status Code:500 could not parse request

Let me know if I should test different options.

Could you please run a tcpdump capture between haproxy and the server ?
Please use "tcpdump -i eth0 -s 0 -w trace.cap host x.y.z" for this and
provide the resulting file. It will help us understand what happens. If
there is a risk that any private information stays in the file, you can
send it off-list to Cyril and I.

Mmmh yes, indeed I could reproduce issues. Michael, is it possible to retry with the patch attached ? It's nearly the same as before, except that the delta is calculated after inserting the new header.


Thanks,
Willy



--
Cyril Bonté
>From bbde204b5500d1529b4e20ff6bf879fd7771319c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cyril=20Bont=C3=A9?= <cyril.bo...@free.fr>
Date: Thu, 1 Nov 2012 17:03:37 +0100
Subject: [PATCH] BUG: fix garbage data when http-send-name-header replaces an
 existing header

This patch is an attempt to prevent sending garbage data when
http-send-name-header replaced existing headers in the request.

http-send-name-header is applied late in the request processing. The buffer is
already ready to be sent to the backend server. When headers are removed, the
data length is not modified, resulting in sending more data than required. By
reducing the data length to send after removing them, this should fix the
issue.
---
 src/proto_http.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/proto_http.c b/src/proto_http.c
index dc65cbd..1807dc3 100644
--- a/src/proto_http.c
+++ b/src/proto_http.c
@@ -3981,12 +3981,11 @@ int http_send_name_header(struct http_txn *txn, struct http_msg *msg, struct buf
 
 	char *hdr_val;
 
+	int delta = txn->req.eoh;
 	while (http_find_header2(hdr_name, hdr_name_len, msg->sol, &txn->hdr_idx, &ctx)) {
 		/* remove any existing values from the header */
 	        http_remove_header2(msg, buf, &txn->hdr_idx, &ctx);
 	}
-
-	/* Add the new header requested with the server value */
 	hdr_val = trash;
 	memcpy(hdr_val, hdr_name, hdr_name_len);
 	hdr_val += hdr_name_len;
@@ -3994,6 +3993,9 @@ int http_send_name_header(struct http_txn *txn, struct http_msg *msg, struct buf
 	*hdr_val++ = ' ';
 	hdr_val += strlcpy2(hdr_val, srv_name, trash + trashlen - hdr_val);
 	http_header_add_tail2(buf, msg, &txn->hdr_idx, trash, hdr_val - trash);
+	delta -= txn->req.eoh;
+	/* Add the new header requested with the server value */
+	buf->send_max -= delta;
 
 	return 0;
 }
-- 
1.7.10.4

Reply via email to