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

Aperta
#2,803 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@NghiaTranUIT ci sta già lavorando.

Dal 28/10/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

✅ 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)
Lingua principale
Nessun dato sulla lingua
Stelle
7.1k
Fork
238
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di ProxymanApp/Proxyman

Tutte le issue di ProxymanApp/Proxyman

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.