Merge lp:~vila/bzr/665100-content-type into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5515
Proposed branch: lp:~vila/bzr/665100-content-type
Merge into: lp:bzr
Diff against target: 57 lines (+12/-3)
4 files modified
bzrlib/tests/test_http.py (+2/-0)
bzrlib/transport/http/_pycurl.py (+3/-1)
bzrlib/transport/http/_urllib.py (+4/-2)
doc/en/release-notes/bzr-2.3.txt (+3/-0)
To merge this branch: bzr merge lp:~vila/bzr/665100-content-type
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+39194@code.launchpad.net

Commit message

Correctly set the Content-Type header when POSTing http requests.

Description of the change

Amazingly we have never set the Content-Type header for the http POST requests...

It turns out we should. The fix is pretty trivial and we even had a test waiting for us to add the appropriate check :)

To post a comment you must log in.
Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/tests/test_http.py'
--- bzrlib/tests/test_http.py 2010-10-18 10:01:47 +0000
+++ bzrlib/tests/test_http.py 2010-10-23 08:42:50 +0000
@@ -507,6 +507,8 @@
507 self.assertTrue(507 self.assertTrue(
508 server.received_bytes.startswith('POST /.bzr/smart HTTP/1.'))508 server.received_bytes.startswith('POST /.bzr/smart HTTP/1.'))
509 self.assertTrue('content-length: 19\r' in server.received_bytes.lower())509 self.assertTrue('content-length: 19\r' in server.received_bytes.lower())
510 self.assertTrue('content-type: application/octet-stream\r'
511 in server.received_bytes.lower())
510 # The transport should not be assuming that the server can accept512 # The transport should not be assuming that the server can accept
511 # chunked encoding the first time it connects, because HTTP/1.1, so we513 # chunked encoding the first time it connects, because HTTP/1.1, so we
512 # check for the literal string.514 # check for the literal string.
513515
=== modified file 'bzrlib/transport/http/_pycurl.py'
--- bzrlib/transport/http/_pycurl.py 2010-10-08 04:38:25 +0000
+++ bzrlib/transport/http/_pycurl.py 2010-10-23 08:42:50 +0000
@@ -268,7 +268,9 @@
268 # We override the Expect: header so that pycurl will send the POST268 # We override the Expect: header so that pycurl will send the POST
269 # body immediately.269 # body immediately.
270 try:270 try:
271 self._curl_perform(curl, header, ['Expect: '])271 self._curl_perform(curl, header,
272 ['Expect: ',
273 'Content-Type: application/octet-stream'])
272 except pycurl.error, e:274 except pycurl.error, e:
273 if e[0] == CURLE_SEND_ERROR:275 if e[0] == CURLE_SEND_ERROR:
274 # When talking to an HTTP/1.0 server, getting a 400+ error code276 # When talking to an HTTP/1.0 server, getting a 400+ error code
275277
=== modified file 'bzrlib/transport/http/_urllib.py'
--- bzrlib/transport/http/_urllib.py 2010-06-01 13:01:20 +0000
+++ bzrlib/transport/http/_urllib.py 2010-10-23 08:42:50 +0000
@@ -138,8 +138,10 @@
138 abspath = self._remote_path('.bzr/smart')138 abspath = self._remote_path('.bzr/smart')
139 # We include 403 in accepted_errors so that send_http_smart_request can139 # We include 403 in accepted_errors so that send_http_smart_request can
140 # handle a 403. Otherwise a 403 causes an unhandled TransportError.140 # handle a 403. Otherwise a 403 causes an unhandled TransportError.
141 response = self._perform(Request('POST', abspath, body_bytes,141 response = self._perform(
142 accepted_errors=[200, 403]))142 Request('POST', abspath, body_bytes,
143 {'Content-Type': 'application/octet-stream'},
144 accepted_errors=[200, 403]))
143 code = response.code145 code = response.code
144 data = handle_response(abspath, code, response.info(), response)146 data = handle_response(abspath, code, response.info(), response)
145 return code, data147 return code, data
146148
=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- doc/en/release-notes/bzr-2.3.txt 2010-10-21 07:51:44 +0000
+++ doc/en/release-notes/bzr-2.3.txt 2010-10-23 08:42:50 +0000
@@ -49,6 +49,9 @@
49* ``bzr status -r X..Y`` was failing because RevisionTree didn't implement49* ``bzr status -r X..Y`` was failing because RevisionTree didn't implement
50 ``get_shelf_manager``. (John Arbash Meinel, #662053)50 ``get_shelf_manager``. (John Arbash Meinel, #662053)
5151
52* Correctly set the Content-Type header when http POSTing to comply
53 with stricter web frameworks. (Vincent Ladeuil, #655100)
54
52* Don't force openssh to use protocol=2, since that is now the default.55* Don't force openssh to use protocol=2, since that is now the default.
53 (Neil Martinsen-Burrell, #561061)56 (Neil Martinsen-Burrell, #561061)
5457