chobie / php-uv

libuv php extension
184 stars 21 forks source link

uv_http_parser_execute buffering requests #46

Closed csaoh closed 11 years ago

csaoh commented 11 years ago

As I understand the behaviour of php-uv, if a Content-Length is specified, uv_http_parser_execute will fail if there's not enough data in the message body. This might not be an bug but a wanted feature, but there are situations in which this is an issue: for instance, if I try to send a 10000 characters long message, I'd like to be able to start parsing headers before all of the 10000 bytes are finished being sent.

I asked people from joyent about it, here's what I got:

csaoh: I realized I couldn't parse headers from a request unless it's been completely sent. For instance, if I send a request with Content-Length set to 5096, but with only 4096 bytes in the body (assuming the rest will be sent later), is there a way to parse the headers anyway ?
bnoordhuis: csaoh: well, the headers will have been parsed. http-parser doesn't buffer anything, it emits parsed header names/values immediately

So my guess is there is something in the php port that is blocking it (intentionally or not). Am I right ?

igorw commented 11 years ago

Sounds like it. Ping @chobie.

chobie commented 11 years ago

https://github.com/chobie/php-uv/blob/master/php_uv.c#L6258

Currently, I didn't make a result hash until http context is finished. Do you mean You want to retrive available result hash every uv_http_parser_execute, right?

btw, I was stacked many tough tasks from my boss. I'll try to adjust my schedules but i guess i need some days to fix this issue.

csaoh commented 11 years ago

yep, I saw this line, and been trying to mess with it this afternoon.

Ideally, it would be even greater if I could retrieve results once the headers are sent but the message body is not sent yet, but I don't know if it's possible, so just being able to retrieve results every time uv_http_parser_execute is called would be nice, yeah.

chobie commented 11 years ago

@csaoh for now, I changed function behavior. coud you try this one?

I guess my implementation has some latent issues (currently, don't check errno when calling uv_http_parser_execute.). I'll fix this when I have time