Re: chunked transfer encoding and HTTP::Daemon
[email protected] (Andreas J. Koenig)
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Message-ID | <[email protected]> |
>>>>> On 12 Dec 2005 10:00:04 -0800, Gisle Aas <[email protected]> said: > [email protected] (Andreas J. Koenig) writes: >> Thanks for coming back to my question. In the meantime I have verified >> that $c->get_request() does it right. I append a testscript for that; >> hope you like it. > I did't find anything appended. Ooops, sorry, I'll retry now. >> What I had problems to get to work was the $c->get_request(1) + "do >> the parsing yourself" variant. It would be a great help if there were >> a sample implementation (maybe it would fit into my testscript?) that >> is more or less bullet proof. > Inside the get_request method you will find a block that goes like this: > if ($te && lc($te) eq 'chunked') { > # Handle chunked transfer encoding > my $body = ""; > CHUNK: > while (1) { > print STDERR "Chunked\n" if $DEBUG; > if ($buf =~ s/^([^\012]*)\012//) { > my $chunk_head = $1; > unless ($chunk_head =~ /^([0-9A-Fa-f]+)/) { > $self->send_error(400); > $self->reason("Bad chunk header $chunk_head"); > return; > } > my $size = hex($1); > last CHUNK if $size == 0; > my $missing = $size - length($buf) + 2; # 2=CRLF at chunk end > # must read until we have a complete chunk > while ($missing > 0) { > print STDERR "Need $missing more bytes\n" if $DEBUG; > my $n = $self->_need_more($buf, $timeout, $fdset); Watch that the arguments to _need_more() are not supplied within this snippet. I'd have to write a variation of the whole 210 lines of get_request including the use of a seemingly private method (as its name starts with an underscore) and dereferencing ${*$self}. You will understand that this is a bit against the usual rules? > [...SNIP...] > This is basically what you need to do :) Sure:) But maybe you have a slightly more ecouraging idea for a interface? -- andreas
http-daemon.t
(application/octet-stream, 7.2 KB) - not displayed