Browse code

* s3cmd: Set Content-Length header for requests with 'body'.

git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@369 830e0280-6d2a-0410-9c65-932aecc39d9d

Michal Ludvig authored on 2009/02/12 06:56:44
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+2009-02-12  Michal Ludvig  <michal@logix.cz>
2
+
3
+	* s3cmd: Set Content-Length header for requests with 'body'.
4
+
1 5
 2009-02-02  Michal Ludvig  <michal@logix.cz>
2 6
 
3 7
 	* Released version 0.9.9-rc3
... ...
@@ -154,7 +154,6 @@ class S3(object):
154 154
 			self.check_bucket_name(bucket, dns_strict = True)
155 155
 		else:
156 156
 			self.check_bucket_name(bucket, dns_strict = False)
157
-		headers["content-length"] = len(body)
158 157
 		if self.config.acl_public:
159 158
 			headers["x-amz-acl"] = "public-read"
160 159
 		request = self.create_request("BUCKET_CREATE", bucket = bucket, headers = headers)
... ...
@@ -356,6 +355,8 @@ class S3(object):
356 356
 	def send_request(self, request, body = None, retries = _max_retries):
357 357
 		method_string, resource, headers = request
358 358
 		debug("Processing request, please wait...")
359
+		if body and not headers.has_key('content-length'):
360
+			headers['content-length'] = len(body)
359 361
 		try:
360 362
 			conn = self.get_connection(resource['bucket'])
361 363
 			conn.request(method_string, self.format_uri(resource), body, headers)