timoklimmer / powerproxy-aoai

Monitors and processes traffic to and from Azure OpenAI endpoints.
MIT License
83 stars 23 forks source link

[Bug] Streaming proxy response breaks clients by `Content-Length` and `Transfer-Encoding: chunked` headers together #53

Closed sergey124 closed 4 months ago

sergey124 commented 4 months ago

Streaming proxy response has both Content-Length and Transfer-Encoding: chunked headers, which breaks some clients, and is not compliant with RFC.

Steps to reproduce

  1. Make streaming request to proxy with PTU endpoint

Expected behavior

Actual behavior

Justificaiton

Standard requires us to not send Content-Length in case of non-identity Transfer-Encoding, like "chunked", "compress", "deflate", or "gzip":

"Messages MUST NOT include both a Content-Length header field and a non-identity transfer-coding." (RFC 2616, Section 4.4, point 3) New RFC, Section 3.3.2 is not instructing to ignore this violation, so it would be great to remove the Content-Length, otherwise clients might break.