timoklimmer / powerproxy-aoai

Monitors and processes traffic to and from Azure OpenAI endpoints.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sergey124 opened this issue · comments

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

  • Send response with Transfer-Encoding: chunked without Content-Length

Actual behavior

  • Response contains both Transfer-Encoding: chunked and Content-Length , causing error in API client:

Error invoking remote method 'send-http-request': Error: Parse Error: Content-Length can't be present with Transfer-Encoding
image

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.