-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup Content-Type to application/octet-stream by default #1124
Changes from 3 commits
3afd52d
f86db67
04842ca
5b35a7a
841e0aa
dbe75ac
bcbf144
ce207aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -774,7 +774,7 @@ def __init__(self, *, body=None, status=200, | |
self.set_tcp_cork(True) | ||
|
||
if body is not None and text is not None: | ||
raise ValueError("body and text are not allowed together.") | ||
raise ValueError('body and text are not allowed together') | ||
|
||
if text is not None: | ||
if hdrs.CONTENT_TYPE not in self.headers: | ||
|
@@ -794,25 +794,23 @@ def __init__(self, *, body=None, status=200, | |
self._content_dict = {'charset': charset} | ||
self.body = text.encode(charset) | ||
else: | ||
self.text = text | ||
if content_type or charset: | ||
raise ValueError("Passing both Content-Type header and " | ||
"content_type or charset params " | ||
"is forbidden") | ||
raise ValueError('passing both Content-Type header and ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
'content_type or charset params ' | ||
'is forbidden') | ||
self.text = text | ||
else: | ||
if hdrs.CONTENT_TYPE in self.headers: | ||
if content_type or charset: | ||
raise ValueError("Passing both Content-Type header and " | ||
"content_type or charset params " | ||
"is forbidden") | ||
if content_type: | ||
self.content_type = content_type | ||
raise ValueError('passing both Content-Type header and ' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
'content_type or charset params ' | ||
'is forbidden') | ||
if content_type is None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this code should be in |
||
content_type = 'application/octet-stream' | ||
self.content_type = content_type | ||
if charset: | ||
self.charset = charset | ||
if body is not None: | ||
self.body = body | ||
else: | ||
self.body = None | ||
self.body = body | ||
|
||
@property | ||
def body(self): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use
"
for exception messagesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the difference in quotes usage was due to different contributors. I'll change it back