tailhook / rotor-http

The mio/rotor based http server library for rust (UNMAINTAINED, use tk-http)
MIT License
110 stars 11 forks source link

Handle wakeup for all Parser states #46

Closed KodrAus closed 7 years ago

KodrAus commented 8 years ago

Fixes #45

I've just used the intent function like you've done above for other states. Not sure if this is the correct way to handle all other states except Idle.

I've done a simple test binary spanking a connection with wakeups and it's handled them as expected instead of panicking. Should I write a test function for this? If so how should I go about it?

tailhook commented 8 years ago

About the fix: I'm not sure this is a good idea. When we are in the middle of sending request the wakeup event should probably be used to add some info for making a request. E.g. if you want to send a file as a part of the request, you might read the part of the file in separate thread and send a wakeup event to the requester, so the Requester can write it to the connection buffer.

So I think you should forward event in all the states that have child state machine present.

The test is appreciated. Just pick up a test from parser.rs which has a request body. And put a wakeup event somewhere between push_bytes() calls. (And you know, make sure it breaks something on old version)

KodrAus commented 8 years ago

Ah I see what you mean, I've reset my solution and added a failing test for wakeups. If you're happy with the shape of that I'll implement the match arm to make it pass.

KodrAus commented 8 years ago

@tailhook Is this getting closer to the mark or should I leave this for someone with more rotor experience to implement?

tailhook commented 8 years ago

Yeah. It looks good. I'm not sure if is_head is right, need to investigate it a little bit more.

tailhook commented 7 years ago

Yeah, sorry for being silent. We have tk-http based on tokio instead of this one. And as you might notice this library is not maintained anymore.

KodrAus commented 7 years ago

No problem :) I've just closed a bunch of my old PRs. Thanks for building rotor! I was a fan of the API once I got the hang of it.