-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add possibility to upgrade the current session to a new TCP handler #75
Conversation
and add a Websocket example demonstrating this new feature.
@@ -0,0 +1,32 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not commit the lock.json? that tends to lead to wtf with tests etc.
is this required? i assume it isn't. (if we do remove, lets add it to the .gitignore)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in the example. We can totally keep it out. My thought was that it is usually good practice to include it to improve reproducability of the build of this corral project, as the lock is where the version/git-tag pinning happens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ive had to do chasing down lock files to find broken builds related to examples that otherwise would have worked. I see your point, its a tough one. They can both lead to pain, the "having lock file" is fresher for pain for me.
@mfelsche seems like we should add |
Or perhaps @mfelsche, would it make sense to incorporate |
This needs release notes. |
{ | ||
"locator": ".", | ||
"revision": "main" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather we use "../" in the use in examples.
_session.send_raw( | ||
_response_builder.set_status(StatusSwitchingProtocols) | ||
.add_header("Upgrade", "websocket") | ||
.add_header("Connection", "Upgrade") | ||
.add_header("Sec-WebSocket-Accept", sec_ws_accept) | ||
.finish_headers() | ||
.build(), | ||
request_id | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be integrated be integrated with the _session.upgrade
method so that this "Switching Protocols" response will definitely happen (without the user needing to remember to implement this)?
I think it would be better to make this all in one call rather than asking the protocol switching handler to construct a raw response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are websockets the only reason one would upgrade the session, or might there be other reasons and the header would look different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrade is a general part of the HTTP protocol, so it isn't websocket specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about integrating sending a 101 Response with in the Session.upgrade_protocol
function. I initially voted against it, because i wanted to keep the library as raw and low-level as possible. While nearly all protocol upgrades will be used for Websockets, I'd rather not block the path for upgrading to other protocols. And people might want to add special headers to their response and we have multiple API styles used in this library for sending responses, so a generic upgrade_protocol method that does all the upgrading boilerplate while still being generic enough so people can change the response as they see fit, didn't seem worthwile to me.
I'd suggest to move the discussion about a more higher-level API for this to new Issue if need be.
If the websocket library isn't a ponylang project then the example shouldnt be part of this repo. The build could be broken by the websocket library falling out of date and maintainers for this package who aren't Matthias wouldn't be able to fix without removing the example. I think either example goes or we commit to making the websocket library a ponylang project. IF we go for "example goes", then I think we should take the example and it can be an example repo unto itself OR we can do a blog post on the website after this is released with an example (and perhaps some FAQ fun on the website). |
Co-authored-by: Joe Eli McIlvain <[email protected]>
@mfelsche for the largest question first so we can move this along, do you want to pull the example out that relies on an external 3rd party library out and use some other location to detail the example or do you want to have the websockets library become a ponylang project that we make sure works with pony language changes going forward? |
Maybe remove the example for now, and if/when the websocket library is a ponylang project it can be added back in? |
Sorry for the late reply. In order to move this forward, lets for now move this example out. I will improve the documentation of the |
Yes, it does. Thank you for your work! |
for representing the HTTP version as 8 byte number for faster comparison during parsing.
stdlib first, external packages second. Alphabetical order in each section.
Makefile
Outdated
EXAMPLES := $(notdir $(shell find $(EXAMPLES_DIR)/* -maxdepth 0 -type d -not -name websocket_echo_server)) | ||
EXAMPLES_SOURCE_FILES := $(shell find $(EXAMPLES_DIR) -name *.pony -not -path '**/websocket_echo_server/*') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be rolled back to how it was previously.
http_server/_server_connection.pony
Outdated
use "net" | ||
use "collections" | ||
use "valbytes" | ||
use "debug" | ||
use "net" | ||
use "time" | ||
|
||
use "valbytes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled bacl
use "net" | ||
use "debug" | ||
use "net" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
http_server/_test.pony
Outdated
use "pony_check" | ||
use "pony_test" | ||
use "net" | ||
use "buffered" | ||
use "collections" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
@@ -1,5 +1,5 @@ | |||
use "pony_test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
http_server/_test_headers.pony
Outdated
@@ -1,6 +1,7 @@ | |||
use "debug" | |||
use "pony_check" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
http_server/_test_pipelining.pony
Outdated
@@ -1,7 +1,8 @@ | |||
use "net" | |||
use "time" | |||
use "pony_test" | |||
use "random" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
@@ -1,6 +1,7 @@ | |||
use "debug" | |||
use "itertools" | |||
use "pony_test" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be rolled back
http_server/request_parser.pony
Outdated
use "valbytes" | ||
use "debug" | ||
|
||
use "valbytes" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
http_server/response.pony
Outdated
use "valbytes" | ||
use "format" | ||
|
||
use "valbytes" | ||
|
||
interface val Response is ByteSeqIter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
http_server/server.pony
Outdated
use "collections" | ||
use "debug" | ||
use "net" | ||
use "net_ssl" | ||
use "time" | ||
use "debug" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
http_server/sync_handler.pony
Outdated
use "valbytes" | ||
use "debug" | ||
|
||
use "valbytes" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unrelated at this point, no new uses were added so I think this should be rolled back
Co-authored-by: Joe Eli McIlvain <[email protected]>
This reverts commit 8e8d9f7.
and add a Websocket example demonstrating this new feature.