Skip to content
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

While running a SSL server, responding an empty bytes causes an SSLEOFError. #1659

Closed
relent95 opened this issue Oct 22, 2019 · 3 comments
Closed
Assignees
Milestone

Comments

@relent95
Copy link

@relent95 relent95 commented Oct 22, 2019

Expected Behavior

In a request handler(endpoint), responding an empty bytes should be OK as in the following example.

@app.route('/test', methods = ['PUT'])
def test():
  return b'', 204 # HTTP_NO_CONTENT

Actual Behavior

But currently, this causes an SSLEOFError exception.

Error on request:
Traceback (most recent call last):
  File "/home/relent95/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 303, in run_wsgi
    execute(self.server.app)
  File "/home/relent95/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 294, in execute
    write(data)
  File "/home/relent95/.local/lib/python3.5/site-packages/werkzeug/serving.py", line 275, in write
    self.wfile.write(data)
  File "/usr/lib/python3.5/socket.py", line 593, in write
    return self._sock.send(b)
  File "/usr/lib/python3.5/ssl.py", line 861, in send
    return self._sslobj.write(data)
  File "/usr/lib/python3.5/ssl.py", line 586, in write
    return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1848)

Environment

  • Python version: 3.5.2
  • Flask version: 1.1.1
  • Werkzeug version: 0.15.5
@greyli
Copy link
Member

@greyli greyli commented Nov 7, 2019

Hi, I can't reproduce your issue. I tested your code on Windows 10 and macOS with Python 3.5.2, Flask 1.1.1 and Werkzeug 0.15.5.

$ http put :5000/test
HTTP/1.0 204 NO CONTENT
Content-Type: text/html; charset=utf-8
Date: Thu, 07 Nov 2019 14:02:29 GMT
Server: Werkzeug/0.15.5 Python/3.5.2

@davidism davidism transferred this issue from pallets/flask Nov 7, 2019
@relent95
Copy link
Author

@relent95 relent95 commented Nov 7, 2019

Hi, this problem occurs only when you run the SSL server.
(e.g. app.run(ssl_context=...))

@nmoehrle
Copy link

@nmoehrle nmoehrle commented Dec 9, 2019

Ran into the same issue when flask was responding with 304 to static file requests - Not Modified. The fix works for me :-) Thank you!

@davidism davidism added this to the 0.16.1 milestone Jan 4, 2020
@davidism davidism closed this as completed Jan 4, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants