changeset 16755:bcaee8677d7d

lib-http: http-client: Implemented explicit HTTP/1.0 support.
author Stephan Bosch <stephan@rename-it.nl>
date Sun, 15 Sep 2013 03:56:47 +0300
parents ccd39339596e
children 7fc1dcfc5e3a
files src/lib-http/http-client-request.c
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-http/http-client-request.c	Sun Sep 15 03:56:25 2013 +0300
+++ b/src/lib-http/http-client-request.c	Sun Sep 15 03:56:47 2013 +0300
@@ -151,9 +151,9 @@
 				    const char *key, const char *value)
 {
 	i_assert(req->state == HTTP_REQUEST_STATE_NEW);
-	/* don't allow setting Date header directly;
+	/* don't allow setting Date or Connection header directly;
 	   this is ignored for now for backwards compatibility */
-	if (strcasecmp(key, "Date") == 0)
+	if (strcasecmp(key, "Date") == 0 || strcasecmp(key, "Connection") == 0)
 		return;
 	str_printfa(req->headers, "%s: %s\r\n", key, value);
 }
@@ -423,6 +423,7 @@
 		str_append(rtext, "Expect: 100-continue\r\n");
 	}
 	if (req->payload_chunked) {
+		// FIXME: can't do this for a HTTP/1.0 server
 		str_append(rtext, "Transfer-Encoding: chunked\r\n");
 		req->payload_output =
 			http_transfer_chunked_ostream_create(output);
@@ -434,6 +435,7 @@
 		req->payload_output = output;
 		o_stream_ref(output);
 	}
+	str_append(rtext, "Connection: Keep-Alive\r\n");
 
 	iov[0].iov_base = str_data(rtext);
 	iov[0].iov_len = str_len(rtext);