-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
Improve documentation around customizing handling of handshake #197
Comments
Go for it and make a PR! |
Okay, great. Though if you're open to my comment here (which I wrote later), this issue would probably be subsumed. |
Since #248 was merged, it's time to reopen the discussion here! |
The section about "Port sharing" in deployment.rst should be updated, since it is now possible to implement basic HTTP responses. |
See issue python-websockets#197 for related discussion.
* Eliminate the need to wrap serve(). See issue #197 for related discussion. * Fix Python 3.4. * Choose better names per @aaugustin's comment. * Update client.py. * Fix flake8. * Fix test for Python 3.4.
Since I restructured the docs, the best place to put this information would be in its own page, linked from the "howto" section in index.rst. |
By now, I believe this issue has become a duplicate of #354 for which I submitted PR #387. The original issue is "I was trying to figure out how to return a 404 on a bad path." The modern API for doing that is async def process_request(self, path, request_headers):
if path != '/':
return http.HTTPStatus.NOT_FOUND, [], b'sorry not found\n' This is close enough to the example in #387. |
I was trying to figure out how to return a 404 on a bad path. Two things occur to me that would have made this a bit easier to figure out.
First, the end of the docstring of the server's
handshake()
method could be expanded to say, "Return the URI of the request, or None if the handshake was aborted."Second, the docstring of the server's
get_response_status()
method could be expanded to say that the request path (e.g. to decide whether to return a 404) is available atself.path
when that method is called. Currently, you have to notice thatread_http_request()
is called at the beginning ofhandshake()
and then see thatread_http_request()
setsself.path
. But even then, it's not clear if you'd be relying on implementation details.The text was updated successfully, but these errors were encountered: