Skip to content

Commit 089e829

Browse files
committed
Set default Content-Type for post requests #184
1 parent e6d2980 commit 089e829

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGES.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ CHANGES
44
0.15.0 (Unreleased)
55
-------------------
66

7-
- Client WebSockets support.
7+
- Client WebSockets support
88

99
- New Multipart system #273
1010

1111
- Support for "Except" header #287 #267
1212

13+
- Set default Content-Type for post requests #184
14+
1315
- Fix issue with construction dynamic route with regexps and trailing slash #266
1416

1517
- Add repr to web.Request

aiohttp/client.py

+5
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,11 @@ def send(self, writer, reader):
548548
request.enable_chunked_encoding()
549549
request.add_chunking_filter(self.chunked)
550550

551+
# set default content-type
552+
if (self.method in self.POST_METHODS and
553+
hdrs.CONTENT_TYPE not in self.headers):
554+
self.headers[hdrs.CONTENT_TYPE] = 'application/octet-stream'
555+
551556
request.add_headers(
552557
*((k, v)
553558
for k, v in ((k, value)

tests/test_client_functional.py

+2
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,8 @@ def stream():
686686

687687
self.assertEqual(str(len(data)),
688688
content['headers']['Content-Length'])
689+
self.assertEqual('application/octet-stream',
690+
content['headers']['Content-Type'])
689691

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

0 commit comments

Comments
 (0)