[Checkins] [zopefoundation/zope.app.http] cf4f04: The PUT views should return an empty bytes string.
GitHub
noreply at github.com
Mon May 15 17:02:33 CEST 2017
Branch: refs/heads/master
Home: https://github.com/zopefoundation/zope.app.http
Commit: cf4f04715d8bd9dcfdfef3071e3e84fb7d53b685
https://github.com/zopefoundation/zope.app.http/commit/cf4f04715d8bd9dcfdfef3071e3e84fb7d53b685
Author: Jason Madden <jamadden at gmail.com>
Date: 2017-05-12 (Fri, 12 May 2017)
Changed paths:
M .travis.yml
M CHANGES.txt
M src/zope/app/http/put.py
M src/zope/app/http/tests/test_put.py
Log Message:
-----------
The PUT views should return an empty bytes string.
If they don't, on Python 3 we run afoul of the zope.publisher rule
that says that unicode response bodies need to have a content-type.
But since the put view never sets a content type (due to being a
redirect), we get a TypeError instead:
```
File "/py35/zope/app/wsgi/testlayer.py", line 210, in http
response = request.get_response(wsgi_app)
File "/py35/webob/request.py", line 1316, in send
application, catch_exc_info=False)
File "/py35/webob/request.py", line 1283, in call_application
output.extend(app_iter)
File "/py35/zope/app/wsgi/testlayer.py", line 94, in __call__
for entry in self.wsgi_stack(environ, application_start_response):
File "/py35/zope/app/wsgi/testlayer.py", line 68, in __call__
for entry in self.wsgi_stack(environ, start_response):
File "/py35/zope/app/wsgi/__init__.py", line 65, in __call__
request = publish(request, handle_errors=handle_errors)
File "/py35/zope/publisher/publish.py", line 148, in publish
response.setResult(result)
File "/py35/zope/publisher/http.py", line 796, in setResult
r, headers = self._implicitResult(r)
File "/py35/zope/publisher/http.py", line 821, in _implicitResult
if not unicode_mimetypes_re.match(ct):
TypeError: expected string or bytes-like object
```
Here, `ct` is the content-type header, and its None. Returning bytes
bypasses the issue.
This was discovered testing with zope.app.file.
Commit: 3a17a700bffb688e44bf10a8fc0bc45088ec2ff4
https://github.com/zopefoundation/zope.app.http/commit/3a17a700bffb688e44bf10a8fc0bc45088ec2ff4
Author: Jason Madden <jason+github at nextthought.com>
Date: 2017-05-15 (Mon, 15 May 2017)
Changed paths:
M .travis.yml
M CHANGES.txt
M src/zope/app/http/put.py
M src/zope/app/http/tests/test_put.py
Log Message:
-----------
Merge pull request #2 from zopefoundation/put-content-type
The PUT views should return an empty bytes string.
Compare: https://github.com/zopefoundation/zope.app.http/compare/9bffedd1e641...3a17a700bffb
More information about the checkins
mailing list