haxetink / tink_http

Cross platform HTTP abstraction
https://haxetink.github.io/tink_http
33 stars 19 forks source link

Chunked responses #27

Open back2dos opened 8 years ago

back2dos commented 8 years ago

This came up in #18.

To my understanding, this could be implemented as a function of type OutgoingResponse->OutgoingResponse. If the argument already has a Content-Length it would be returned as is, otherwise a new response would be constructed that uses chunked encoding. The tricky bit is in writing the IdealSource->IdealSource transformation for the body.

Not sure when I'll get around to do this. Volunteers are welcome. Or let me know if this becomes a pressing issue ;)

kevinresol commented 7 years ago

was trying to implement OutgoingResponse.chunked(). It turns out that nodejs uses chunked encoding by default, meaning that one doesn't need to set content-length nor transfer-encoding header. Simply write() to the ServerResponse object and end() it, nodejs will take care of the rest (adda transfer-encoding: chunked header and sends body in chunked style).

So if we transform the body into "chunked style" and send through nodejs, it will be shown "as-is" on the receiver side.

So I mean this should probably be handled at container level

back2dos commented 7 years ago

So I mean this should probably be handled at container level

Yes and no. First, there should be a standalone functionality that is of type IncomingRequestHeader->OutgoingReponse->OutgoingResponse that is able to fix a response so that makes sure the content-length, transfer-encoding and connection headers fit with one another and what the client supports (e.g. support for chunked responses must be announced by the client IIRC, otherwise connection: closed must be used).

bablukid commented 4 years ago

same problem here, tink_http ( PHP7 target ) throws the same error when acessing Google Geocoding API ( i.e "https://maps.googleapis.com/maps/api/geocode/json?address=Place%20de%20l%27%C3%A9toile%20Paris" )

Error#500: Chunked encoding is not supported and the content-length header is required. @ tink.http.clients.SocketClient.request:74

0b1kn00b commented 4 years ago

Wait, Why are both these issues closed?

back2dos commented 4 years ago

Which ones? ^^

0b1kn00b commented 4 years ago

Regarding SocketClient not supporting chunked responses. Got bogged down with the Chunked implementation thus far.

kevinresol commented 4 years ago

chunked encoding is not implemented in the SocketClient right now, and this issue is an umbrella covering that and all other chunk-related things.