p5-Protocol-HTTP2 icon indicating copy to clipboard operation
p5-Protocol-HTTP2 copied to clipboard

accessing reconstructed streamed objects

Open bf31415 opened this issue 9 years ago • 1 comments

I'm trying to use this module as an http2 server. I've got a client which opens a connection to the server and streams objects. The tcp connection forms and I see the client streaming objects. I'm using the example code provided here (http://search.cpan.org/~crux/Protocol-HTTP2-0.15/lib/Protocol/HTTP2/Server.pm). In the $handle->on_read, I can dump out the $handle->{rbuf} info I see the raw data coming from the client. in the code, this information is then past to $server->feed{$handle->{rbuf}} which I think takes the streaming data and decodes.

What I'm hoping to find is a way to access the reconstructed objects-- how would I get access to an entire reconstructured object? It's not clear how I gain access to these object in the server code.

Thanks

bf31415 avatar Nov 10 '16 13:11 bf31415

When you've created Protocol::HTTP::Server you've specified callback on_request, which is called on every arrived http-request. Callback will receive 3 parameters: sream id, ref to headers array (including specific http2-headers, which started with «:» symbol), data (for POST/PUT methods). You should send HTTP response inside this callback with method response. So, all application level logic must be implemented inside this callback.

If i correclty understood your question, you need client->server streaming for continuos reception of every chunk of headers/data on server side?

Right now there is no support for streaming from client to server, i.e. on_request is called only when all headers and data frames of request have arrived. But server to client streaming is possible (method response_stream).

It isn't hard to implement on_request_headers и on_request_body callbacks similarly with the client's class, which is called on every HEADERS/DATA frame.

vlet avatar Nov 11 '16 08:11 vlet