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

headers use integer for Access-Control-Max-Age #228

Closed
alon opened this issue Nov 3, 2015 · 1 comment
Closed

headers use integer for Access-Control-Max-Age #228

alon opened this issue Nov 3, 2015 · 1 comment

Comments

@alon
Copy link

alon commented Nov 3, 2015

Headers should be string/unicode (python 2/3) and this is being violated when Access-Control-Max-Age is set to 3600. It should be set to '3600' (str) instead:

see https://github.com/gevent/gevent/blob/master/gevent/pywsgi.py#L737which quotes Pep 3333 "The start_response callable" for the enforcement and see https://github.com/abourget/gevent-socketio/blob/master/socketio/handler.py#L77 for the offending code.

i.e. suggested patch (I can do a pull request if needed):

diff --git a/socketio/handler.py b/socketio/handler.py
index e4b972f..6bdb5b1 100644
--- a/socketio/handler.py
+++ b/socketio/handler.py
@@ -74,7 +74,7 @@ class SocketIOHandler(WSGIHandler):
             ("Access-Control-Allow-Origin", self.environ.get('HTTP_ORIGIN', '*')),
             ("Access-Control-Allow-Credentials", "true"),
             ("Access-Control-Allow-Methods", "POST, GET, OPTIONS"),
-            ("Access-Control-Max-Age", 3600),
+            ("Access-Control-Max-Age", str(3600)),
             ("Content-Type", "text/plain"),
         ])
         self.result = [data]

(edited for style)

@tshirtman
Copy link

Yes, getting the same issue, and was getting to the same cause, a pull request would be very useful :)

Edit: saw #227 nice!

alon added a commit to Rhizi/gevent-socketio that referenced this issue Nov 25, 2015
klaftertief pushed a commit to iosphere/gevent-socketio that referenced this issue Oct 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants