Hono version
4.13.13 (08a023c on main)
Runtime and version
Node.js 24.11.1
Reproduction
import { Hono } from 'hono'
import { methodOverride } from 'hono/method-override'
const app = new Hono()
app.use('/posts', methodOverride({ app }))
app.delete('/posts', async (c) => {
const body = await c.req.text()
return c.json({
body,
actualBytes: new TextEncoder().encode(body).length,
contentLength: c.req.header('content-length'),
})
})
const response = await app.request('/posts', {
method: 'POST',
body: '_method=DELETE&message=Hello',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': '28',
},
})
console.log(await response.json())
// { body: 'message=Hello', actualBytes: 13, contentLength: '28' }
Expected behavior
Removing _method changes the body length. The rewritten request should discard the old Content-Length, as the multipart branch already does.
Actual behavior
The URLencoded branch retains the incoming length. Forwarding this rewritten body and its headers with Node's fetch fails with UND_ERR_REQ_CONTENT_LENGTH_MISMATCH. A local HTTP echo server reproduces the failure; removing the stale header lets fetch calculate the correct length of 13 bytes.
Custom form field names have the same problem. Requests without an override field are unaffected.
Hono version
4.13.13 (
08a023conmain)Runtime and version
Node.js 24.11.1
Reproduction
Expected behavior
Removing
_methodchanges the body length. The rewritten request should discard the oldContent-Length, as the multipart branch already does.Actual behavior
The URLencoded branch retains the incoming length. Forwarding this rewritten body and its headers with Node's
fetchfails withUND_ERR_REQ_CONTENT_LENGTH_MISMATCH. A local HTTP echo server reproduces the failure; removing the stale header letsfetchcalculate the correct length of 13 bytes.Custom form field names have the same problem. Requests without an override field are unaffected.