[Checkins] [zopefoundation/zope.app.http] 6abbcc: The PUT views should return an empty bytes string.

GitHub noreply at github.com
Fri May 12 20:51:33 CEST 2017


  Branch: refs/heads/put-content-type
  Home:   https://github.com/zopefoundation/zope.app.http
  Commit: 6abbcca247f62b27a36d3303bcdae16f6be5cfb6
      https://github.com/zopefoundation/zope.app.http/commit/6abbcca247f62b27a36d3303bcdae16f6be5cfb6
  Author: Jason Madden <jamadden at gmail.com>
  Date:   2017-05-12 (Fri, 12 May 2017)

  Changed paths:
    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.




More information about the checkins mailing list