unit icon indicating copy to clipboard operation
unit copied to clipboard

Chunked: Support Chunked Transfer Encoding for client requests (RFC 9112 6.1)

Open robjr opened this issue 5 years ago • 13 comments

Hi guys, I'm facing this issue where unit returns 411 content-length required when the request doesn't specify the content-length, but it actually specifies Transfer-Encoding: Chunked.

    const formData = new FormData();
    formData.append('file', request.get('any.com/img.png'));
    await axios.post('svc.com/media', formData, { headers: formData.getHeaders() });

It is streaming a file from one end to another and it works locally, but whenever it goes through unit, it returns 411. Is there any configuration to enable transfer-encoding?

robjr avatar Jul 20 '20 04:07 robjr

Unit doesn't support chunked transfer encoding in requests for the moment. So, the only options right now is to specify the Content-Length.

VBart avatar Jul 20 '20 10:07 VBart

Good question - is there any configuration to change the Transfer-Encoding?

mafin avatar Mar 25 '21 12:03 mafin

@mafin It needs to be changed on the client. There's no way to control client's request Transfer-Encoding from the server side.

VBart avatar Mar 25 '21 14:03 VBart

Ouch, we just ran into this issue with Axway API Gateway ...

saper avatar Jul 07 '22 14:07 saper

Hi @saper thanks for reaching out? What do you mean with that? Can you explain that? Thanks Timo

tippexs avatar Jul 07 '22 20:07 tippexs

Hi @saper thanks for reaching out? What do you mean with that? Can you explain that? Thanks Timo

We started using unit for some REST services and now someone put Axway API manager in front of them - the result - unit always sends 411 Length Required, because API manager ALWAYS transforms requests with Content-Length into chunked encoding.

We also could not easily tell unit to dump all requests and responses received, hard to trace the down (debug mode prints lots of syscall and thread info but no actual requests).

saper avatar Jul 08 '22 21:07 saper

Thanks for the extra context - that's really helpful. In this case, I suspect the Axway behavior is due to it's transformation features for things like JSON/XML conversion. It's a shame that it does the same even when no transformation occurs.

We strive to be RFC compliant, and updated the issue title to reflect that. For now, this is on the backlog, but no ETA just yet.

lcrilly avatar Jul 12 '22 08:07 lcrilly