HEAD response without Content-Length gets "Transfer-Encoding: chunked"

Open
#2,803 1 comment 0 reactions 1 assignee View on GitHub

@NghiaTranUIT is already working on this.

Since Oct 28, 2026.

Assessment

This issue has not been assessed yet.

Description

✅ Done bug

Description

When a server answers an HTTP/1.1 HEAD request without a Content-Length header (valid, since a HEAD response never has a body), Proxyman forwards the response with an added transfer-encoding: chunked header and then writes the chunked terminator 0\r\n\r\n onto the connection.

A HEAD response must not carry a body (RFC 9110 §9.3.2, RFC 9112 §6.3), so the client correctly reads only the headers and leaves those 5 bytes in the socket. When it reuses the keep-alive connection for its next request, it reads 0\r\n\r\n where the next status line should be and fails. Proxyman shows that next request as 999 Error, and the app reports a network error.

This affects any app using HEAD requests, e.g. Supabase/PostgREST count queries, which supabase-swift and supabase-kt send as HEAD. Whichever request follows the HEAD on the same connection fails randomly, but only while Proxyman is in the path.

Steps to Reproduce

  1. Use any HTTP/1.1 server whose HEAD response has no Content-Length. Ours is PostgREST 14.4 behind Kong 2.8.1 (a local Supabase stack on 127.0.0.1:54321).
  2. Through the Proxyman proxy (127.0.0.1:9090), send a HEAD request on a keep-alive connection, e.g. with this raw-socket script (Python 3, no libraries):
import socket
s = socket.create_connection(("127.0.0.1", 9090))
s.sendall((
    "HEAD http://127.0.0.1:54321/rest/v1/app_config?select=platform HTTP/1.1\r\n"
    "Host: 127.0.0.1:54321\r\n"
    "apikey: <anon key>\r\n"
    "Authorization: Bearer <anon key>\r\n"
    "Prefer: count=exact\r\n"
    "Connection: keep-alive\r\n\r\n").encode())
print(s.recv(65536))
  1. Compare the raw bytes with the same request sent directly to the server (127.0.0.1:54321, origin-form path).
  2. Send any second request on the same proxied connection. With a real HTTP client (OkHttp/Ktor on Android, URLSession on iOS), that second request fails.

Current Behavior

Through Proxyman, the HEAD response gains a header and a body:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Content-Range: 0-1/2
...
transfer-encoding: chunked        <- added by Proxyman

0\r\n\r\n                         <- added by Proxyman (a body on a HEAD response)

The next request on that connection fails immediately. Proxyman logs it as 999 Error with no response. The client sees a lost connection: Android (OkHttp/Ktor) gets a request failure, and iOS URLSession gets NSURLErrorNetworkConnectionLost (-1005). A retry on a fresh connection succeeds. It reproduces every time.

Expected Behavior

The HEAD response is forwarded exactly as the server sent it. Directly against the server it is:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Content-Range: 0-1/2
...

There is no Transfer-Encoding header and no bytes after the headers, so the next request on the connection works.

Environment

  • App version: Proxyman 26.3.0 (build 260300)
Dominant language
No language data
Stars
7.1k
Forks
238
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ProxymanApp/Proxyman

All issues in ProxymanApp/Proxyman

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.