- Notifications
You must be signed in to change notification settings - Fork425
Fixes #635 - bug in async server's connection read#637
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This changes the example file server to use the read handler forPOST/PUT requests. This currently assumes that there's a content-lengthheader (not much error handling is happening here, but it's meant as aproof of concept anyway).Using this code path in an example should be good enough for the momentuntil we have better tests and a better API for this functionality.
References#635 -- looking for reviewers and people to try it out. |
@@ -389,11 +389,12 @@ struct async_connection | |||
} | |||
auto self = this->shared_from_this(); |
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.
You do not needself
here anymore, since it is not used in the lambda (can also be removed from the capture section of the lambda).
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.
Actually, this "self" variable makes sure that the object is alive -- it ensures that there's a shared reference in the callback that depends on the state of the connection. It's a trick that's tied to how asynchronous programming is really hard to debug. 😀
This changes the example file server to use the read handler for
POST/PUT requests. This currently assumes that there's a content-length
header (not much error handling is happening here, but it's meant as a
proof of concept anyway).
Using this code path in an example should be good enough for the moment
until we have better tests and a better API for this functionality.