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

http server seems to ignore incoming body (checked for POST) #7

Closed
soumith opened this issue Dec 6, 2013 · 8 comments · Fixed by #8
Closed

http server seems to ignore incoming body (checked for POST) #7

soumith opened this issue Dec 6, 2013 · 8 comments · Fixed by #8

Comments

@soumith
Copy link
Contributor

soumith commented Dec 6, 2013

The http server seems to never trigger the onBody function, even when given an incoming valid request.

For example:

POST HTTP/1.1
Host: localhost:8080
Cache-Control: no-cache

{"title":"Hello World!","body":"This is my first post!"}

The request.body field is just an empty table, and I see that onBody is not triggered.

@clementfarabet
Copy link
Owner

Yeah the http server is very much half baked at this point. Everything is in place though, so parsing the body should be straightforward.

Just for info: we're using async in production here, for all our internal networking needs. It's working really well, but pretty much as with a basic node.js server, there's no protection / robustness ensured at any level. Recently we added a async.pcall(), which catches any crash in a callback, and gives you a traceback that goes through the callback levels. That alone is pretty much enough to build crash-free services.

Looking forward to your feedback / use cases for this. LibUV and the async model is really really exciting, it's been the backbone of everything we've built at Madbits, we just love it.

@soumith
Copy link
Contributor Author

soumith commented Dec 6, 2013

I've actually traced through the code, and it seems like even though there is a body in the incoming request, lhttp_parser never calls the onBody function.

I wasn't sure if it was a shortcoming of lhttp_parser or the handler in ASyNC itself. wdyt?

@clementfarabet
Copy link
Owner

That line never gets called? Not sure why, I've really never looked at it. I only use plain TCP connections most of the time, and a basic http server for a few things, but that's all. It would be great to get into this though.

@soumith
Copy link
Contributor Author

soumith commented Dec 6, 2013

Yes it never gets called.
I'll have a look into it.

Thanks.

Might send in some patches for a better http client as well.
Using async internally for a couple of things, I like the design.
async+persist is quite a breeze.

@clementfarabet
Copy link
Owner

Cool. If you're interested in this aync model, we've also started an async client for redis. Not really documented but very usable: here. Unfortunately persist can't really be built on top of an async client. We use that driver for our queuing system.

@soumith
Copy link
Contributor Author

soumith commented Dec 6, 2013

i'm curious, why cant persist be used in an async client? (i know it might be blocking, but it can still be used right?)

@clementfarabet
Copy link
Owner

It can definitely be used, but it's blocking. If you're writing a server / process that needs to be available with low-latency, and you're doing a lot of redis lookups, it's better to have an async client for redis: this way the main event loop is literally never blocking...

@soumith
Copy link
Contributor Author

soumith commented Dec 6, 2013

right! got it.

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

Successfully merging a pull request may close this issue.

2 participants