Rev 5105: (vila) Correctly set the Content-Type header when POSTing http in file:///home/pqm/archives/thelove/bzr/2.2/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sat Oct 30 09:50:19 BST 2010


At file:///home/pqm/archives/thelove/bzr/2.2/

------------------------------------------------------------
revno: 5105 [merge]
revision-id: pqm at pqm.ubuntu.com-20101030085017-9n3634rvcmht8vqs
parent: pqm at pqm.ubuntu.com-20101018101101-1recje2rg2bqg3m2
parent: v.ladeuil+lp at free.fr-20101030065955-q86b222f4zisce3w
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: 2.2
timestamp: Sat 2010-10-30 09:50:17 +0100
message:
  (vila) Correctly set the Content-Type header when POSTing http
  	requests. (Vincent Ladeuil)
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_http.py      testhttp.py-20051018020158-b2eef6e867c514d9
  bzrlib/transport/http/_pycurl.py pycurlhttp.py-20060110060940-4e2a705911af77a6
  bzrlib/transport/http/_urllib.py _urlgrabber.py-20060113083826-0bbf7d992fbf090c
=== modified file 'NEWS'
--- a/NEWS	2010-10-18 08:06:05 +0000
+++ b/NEWS	2010-10-30 06:59:55 +0000
@@ -19,6 +19,9 @@
 Bug Fixes
 *********
 
+* Correctly set the Content-Type  header when http POSTing to comply
+  with stricter web frameworks. (Vincent Ladeuil, #655100)
+
 * ``NotBranchError`` no longer allows errors from calling
   ``bzrdir.open_repository()`` to propagate.  This is unhelpful at best,
   and at worst can trigger infinite loops in callers.  (Andrew Bennetts)

=== modified file 'bzrlib/tests/test_http.py'
--- a/bzrlib/tests/test_http.py	2010-06-11 10:59:23 +0000
+++ b/bzrlib/tests/test_http.py	2010-10-30 06:59:55 +0000
@@ -551,6 +551,8 @@
         self.assertTrue(
             server.received_bytes.startswith('POST /.bzr/smart HTTP/1.'))
         self.assertTrue('content-length: 19\r' in server.received_bytes.lower())
+        self.assertTrue('content-type: application/octet-stream\r'
+                        in server.received_bytes.lower())
         # The transport should not be assuming that the server can accept
         # chunked encoding the first time it connects, because HTTP/1.1, so we
         # check for the literal string.

=== modified file 'bzrlib/transport/http/_pycurl.py'
--- a/bzrlib/transport/http/_pycurl.py	2010-05-30 16:22:32 +0000
+++ b/bzrlib/transport/http/_pycurl.py	2010-10-30 06:59:55 +0000
@@ -262,7 +262,9 @@
         # We override the Expect: header so that pycurl will send the POST
         # body immediately.
         try:
-            self._curl_perform(curl, header, ['Expect: '])
+            self._curl_perform(curl, header,
+                               ['Expect: ',
+                                'Content-Type: application/octet-stream'])
         except pycurl.error, e:
             if e[0] == CURLE_SEND_ERROR:
                 # When talking to an HTTP/1.0 server, getting a 400+ error code

=== modified file 'bzrlib/transport/http/_urllib.py'
--- a/bzrlib/transport/http/_urllib.py	2010-02-17 17:11:16 +0000
+++ b/bzrlib/transport/http/_urllib.py	2010-10-30 06:59:55 +0000
@@ -133,8 +133,10 @@
         abspath = self._remote_path('.bzr/smart')
         # We include 403 in accepted_errors so that send_http_smart_request can
         # handle a 403.  Otherwise a 403 causes an unhandled TransportError.
-        response = self._perform(Request('POST', abspath, body_bytes,
-                                         accepted_errors=[200, 403]))
+        response = self._perform(
+            Request('POST', abspath, body_bytes,
+                    {'Content-Type': 'application/octet-stream'},
+                    accepted_errors=[200, 403]))
         code = response.code
         data = handle_response(abspath, code, response.info(), response)
         return code, data




More information about the bazaar-commits mailing list