@@ -41,7 +41,7 @@ export async function sendResponse(
41
41
const hasContentLength = fetchResponse . headers . has ( "Content-Length" ) ;
42
42
43
43
if ( ( fetchResponse as any ) [ rawBodySymbol ] ) {
44
- writeHead ( fetchResponse , res ) ;
44
+ writeHead ( fetchResponse , res , req ) ;
45
45
res . end ( ( fetchResponse as any ) [ rawBodySymbol ] ) ;
46
46
return ;
47
47
}
@@ -52,7 +52,7 @@ export async function sendResponse(
52
52
if ( ! hasContentLength ) {
53
53
res . setHeader ( "Content-Length" , "0" ) ;
54
54
}
55
- writeHead ( fetchResponse , res ) ;
55
+ writeHead ( fetchResponse , res , req ) ;
56
56
res . end ( ) ;
57
57
return ;
58
58
}
@@ -71,7 +71,7 @@ export async function sendResponse(
71
71
}
72
72
if ( setImmediateFired ) {
73
73
if ( ! bufferWritten ) {
74
- writeHead ( fetchResponse , res ) ;
74
+ writeHead ( fetchResponse , res , req ) ;
75
75
for ( const chunk of chunks ) {
76
76
await writeAndAwait ( chunk , res , signal ) ;
77
77
if ( signal . aborted ) {
@@ -107,13 +107,17 @@ export async function sendResponse(
107
107
if ( ! hasContentLength ) {
108
108
res . setHeader ( "Content-Length" , buffer . length ) ;
109
109
}
110
- writeHead ( fetchResponse , res ) ;
110
+ writeHead ( fetchResponse , res , req ) ;
111
111
res . end ( buffer ) ;
112
112
}
113
113
114
- function writeHead ( fetchResponse : Response , nodeResponse : ServerResponse ) {
114
+ function writeHead (
115
+ fetchResponse : Response ,
116
+ nodeResponse : ServerResponse ,
117
+ nodeRequest : DecoratedRequest ,
118
+ ) {
115
119
nodeResponse . statusCode = fetchResponse . status ;
116
- if ( fetchResponse . statusText ) {
120
+ if ( nodeRequest . httpVersionMajor === 1 && fetchResponse . statusText ) {
117
121
nodeResponse . statusMessage = fetchResponse . statusText ;
118
122
}
119
123
@@ -134,7 +138,7 @@ async function writeAndAwait(
134
138
res : ServerResponse ,
135
139
signal : AbortSignal ,
136
140
) {
137
- const written = res . write ( chunk ) ;
141
+ const written = ( res . write as any ) ( chunk ) ;
138
142
if ( ! written ) {
139
143
await new Promise < void > ( ( resolve , reject ) => {
140
144
function cleanup ( ) {
0 commit comments