Rev 5515: Correctly set the Content-Type header when POSTing http requests in http://bazaar.launchpad.net/~vila/bzr/integration/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Oct 26 09:08:24 BST 2010


At http://bazaar.launchpad.net/~vila/bzr/integration/

------------------------------------------------------------
revno: 5515 [merge]
revision-id: v.ladeuil+lp at free.fr-20101026080823-3wggo03b7cpn9908
parent: pqm at pqm.ubuntu.com-20101022181024-0xj4kn2fc8s1cr3r
parent: v.ladeuil+lp at free.fr-20101023082711-40j4jawodrrnjza6
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: trunk
timestamp: Tue 2010-10-26 10:08:23 +0200
message:
  Correctly set the Content-Type header when POSTing http requests
modified:
  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
  doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
-------------- next part --------------
=== modified file 'bzrlib/tests/test_http.py'
--- a/bzrlib/tests/test_http.py	2010-10-18 10:01:47 +0000
+++ b/bzrlib/tests/test_http.py	2010-10-23 08:27:11 +0000
@@ -507,6 +507,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-10-08 04:38:25 +0000
+++ b/bzrlib/transport/http/_pycurl.py	2010-10-23 08:27:11 +0000
@@ -268,7 +268,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-06-01 13:01:20 +0000
+++ b/bzrlib/transport/http/_urllib.py	2010-10-23 08:27:11 +0000
@@ -138,8 +138,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

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2010-10-21 07:51:44 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2010-10-23 08:27:11 +0000
@@ -49,6 +49,9 @@
 * ``bzr status -r X..Y`` was failing because RevisionTree didn't implement
   ``get_shelf_manager``. (John Arbash Meinel, #662053)
 
+* Correctly set the Content-Type  header when http POSTing to comply
+  with stricter web frameworks. (Vincent Ladeuil, #655100)
+
 * Don't force openssh to use protocol=2, since that is now the default.
   (Neil Martinsen-Burrell, #561061)
 



More information about the bazaar-commits mailing list