You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using http2 for POST, if body is string or Buffer, the request will get stuck. This works fine if body is a stream
Reproducible By
test code:
test('Should support H2 connection(POST Buffer)',asynct=>{constserver=createSecureServer({ ...pem,allowHTTP1: false})server.on('stream',async(stream,headers,_flags,rawHeaders)=>{t.equal(headers[':method'],'POST')constreqData=[]stream.on('data',chunk=>reqData.push(chunk.toString()))awaitonce(stream,'end')constreqBody=reqData.join('')t.equal(reqBody.length>0,true)stream.respond({'content-type': 'text/plain; charset=utf-8','x-custom-h2': 'hello',':status': 200})stream.end(`hello h2! ${reqBody}`)})server.listen(0)awaitonce(server,'listening')constclient=newClient(`https://localhost:${server.address().port}`,{connect: {rejectUnauthorized: false},allowH2: true})t.plan(6)t.teardown(server.close.bind(server))t.teardown(client.close.bind(client))constsendBody=`hello!`constbody=[]console.log(`before request ${sendBody}`)constresponse=awaitclient.request({path: '/',method: 'POST',// FIXME: If send a Buffer or string, the stream will not end, causing it to get stuck.body: sendBody})console.log(`after request ${sendBody}`)response.body.on('data',chunk=>{body.push(chunk)})awaitonce(response.body,'end')t.equal(response.statusCode,200)t.equal(response.headers['content-type'],'text/plain; charset=utf-8')t.equal(response.headers['x-custom-h2'],'hello')t.equal(Buffer.concat(body).toString('utf8'),`hello h2! ${sendBody}`)})
Expected Behavior
Logs & Screenshots
Environment
MacOS 14.0
Nodejs 16.19.0
undici 5.25.4
Additional context
Maybe we can fix this by:
Added call to stream.end() in writeBodyH2 ()
Use Readable.from(body) in writeBodyH2 () to convert body to a readable stream
The text was updated successfully, but these errors were encountered:
Bug Description
When using http2 for POST, if body is string or Buffer, the request will get stuck. This works fine if body is a stream
Reproducible By
test code:
Expected Behavior
Logs & Screenshots
Environment
Additional context
Maybe we can fix this by:
stream.end()
in writeBodyH2 ()Readable.from(body)
in writeBodyH2 () to convert body to a readable streamThe text was updated successfully, but these errors were encountered: