Skip to content

Commit

Permalink
Set default Content-Type for post requests #184
Browse files Browse the repository at this point in the history
  • Loading branch information
fafhrd91 committed Mar 27, 2015
1 parent e6d2980 commit 089e829
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ CHANGES
0.15.0 (Unreleased)
-------------------

- Client WebSockets support.
- Client WebSockets support

- New Multipart system #273

- Support for "Except" header #287 #267

- Set default Content-Type for post requests #184

- Fix issue with construction dynamic route with regexps and trailing slash #266

- Add repr to web.Request
Expand Down
5 changes: 5 additions & 0 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ def send(self, writer, reader):
request.enable_chunked_encoding()
request.add_chunking_filter(self.chunked)

# set default content-type
if (self.method in self.POST_METHODS and
hdrs.CONTENT_TYPE not in self.headers):
self.headers[hdrs.CONTENT_TYPE] = 'application/octet-stream'

request.add_headers(
*((k, v)
for k, v in ((k, value)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ def stream():

self.assertEqual(str(len(data)),
content['headers']['Content-Length'])
self.assertEqual('application/octet-stream',
content['headers']['Content-Type'])

def test_POST_StreamReader(self):
with test_utils.run_server(self.loop, router=Functional) as httpd:
Expand Down

0 comments on commit 089e829

Please sign in to comment.