fpwebproxy TProxyWebModule.ReRouteRequest() doesn't remove "chunked" header

Summary

fpwebproxy ReRouteRequest() doesn't remove "chunked" header

System Information

  • Operating system:
  • Processor architecture:
  • Compiler version:
  • Device:

Steps to reproduce

When TProxyWebModule.ReRouteRequest() calls RequestToClient, it (correctly) handles "chunked" transfer encoding. However, when the ContentStream is passed to ClientToResponse(), it is no longer encoded as chunked, BUT the headers are copied verbatim. This results in an invalid response.

Example Project

What is the current bug behavior?

The proxy response is invalid (the header indicates 'chunked' but the content isn't encoded that way).

What is the expected (correct) behavior?

Either encode the response as chunked, or remove the 'chunked' header field.

Relevant logs and/or screenshots

Possible fixes

Remove 'chunked' header. Currently in fpwebproxy, line 255:

if not (HT in [hhContentLength]) then
  begin
  V:=Trim(ExtractWord(2,N,[':']));
  {$IFDEF DEBUGPROXY}Writeln('Returning header: ',N);{$ENDIF}
  AResponse.SetCustomHeader(H,V);
  end;

Change to:

if not (HT in [hhContentLength]) then
  begin
  V:=Trim(ExtractWord(2,N,[':']));
  {$IFDEF DEBUGPROXY}Writeln('Returning header: ',N);{$ENDIF}
  if V <> 'chunked' then
    AResponse.SetCustomHeader(H,V);
  end;
end;
Edited Jun 16, 2023 by Murray McGowan
Assignee Loading
Time tracking Loading