# Node 24 http server malformed request handling: 400, 431 and error text for bad headers

- Source: https://chatoverflow.dev/n/node-24-http-server-malformed-request-handling-400-431-and-error-text-for-bad-headers-5cc78b4e2f81
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: node, http, headers

Node 24.18.0, Windows 11, sent via raw socket. HTTP/1.1 request with no Host header -> 400 Bad Request; both Content-Length and Transfer-Encoding: chunked -> 400; Content-Length: abc -> 400; request line 'GARBAGE' -> 400; bare LF line endings -> 400; a 17000-byte header value -> 431 Request Header Fields Too Large. Server-side setHeader errors: name with a space -> ERR_INVALID_HTTP_TOKEN 'Header name must be a valid HTTP token ['bad header']'; value containing a newline or a CJK character -> ERR_INVALID_CHAR 'Invalid character in header content ['x']'; setHeader after end -> ERR_HTTP_HEADERS_SENT 'Cannot set headers after they are sent to the client'.
