router-for-me/CLIProxyAPI · error

httpwire: request header exceeds %d bytes

Error message

httpwire: request header exceeds %d bytes

What it means

Error "httpwire: request header exceeds %d bytes" thrown in router-for-me/CLIProxyAPI.

Source

Thrown at internal/httpwire/ordered_conn.go:86

			if errConsume != nil {
				return consumed, errConsume
			}
			if completed {
				c.chunked = nil
			}
			if errWrite != nil {
				return consumed, errWrite
			}
			remaining = remaining[chunkBytes:]
			continue
		}

		previousHeaderLength := len(c.header)
		c.header = append(c.header, remaining...)
		headerEnd := bytes.Index(c.header, []byte("\r\n\r\n"))
		if headerEnd < 0 {
			if len(c.header) > maxBufferedRequestHeader {
				return consumed, fmt.Errorf("httpwire: request header exceeds %d bytes", maxBufferedRequestHeader)
			}
			return originalLength, nil
		}

		headerEnd += len("\r\n\r\n")
		header := c.header[:headerEnd]
		body := c.header[headerEnd:]
		c.header = nil
		currentHeaderBytes := min(len(remaining), max(0, headerEnd-previousHeaderLength))

		ordered, contentLength, chunked := orderRequestHeader(header, c.order)
		if _, errWrite := writeAll(c.Conn, ordered); errWrite != nil {
			// All caller bytes were accepted into the wrapper before the transformed
			// header write failed. Return the full input count with the terminal
			// connection error so callers do not replay an ambiguous partial header.
			return originalLength, errWrite
		}
		consumed += currentHeaderBytes

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Reduce the request header size below the stated byte limit.
  2. Check for runaway header generation (e.g. huge cookies or tokens).

When it happens

Trigger: Thrown at internal/httpwire/ordered_conn.go:86 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/194f6e8f77f5f354. Report an issue: GitHub.