File tree 3 files changed +30
-29
lines changed
3 files changed +30
-29
lines changed Original file line number Diff line number Diff line change @@ -24,12 +24,10 @@ import {
24
24
waitForCompletedRequest ,
25
25
buildBodyReader ,
26
26
shouldKeepAlive ,
27
- dropDefaultHeaders ,
28
27
isHttp2 ,
29
28
isAbsoluteUrl ,
30
29
writeHead ,
31
30
encodeBodyBuffer ,
32
- validateHeader ,
33
31
getEffectivePort
34
32
} from '../../util/request-utils' ;
35
33
import {
@@ -39,13 +37,13 @@ import {
39
37
rawHeadersToObject ,
40
38
rawHeadersToObjectPreservingCase ,
41
39
flattenPairedRawHeaders ,
42
- findRawHeader ,
43
40
pairFlatRawHeaders ,
44
- findRawHeaderIndex
41
+ findRawHeaderIndex ,
42
+ dropDefaultHeaders ,
43
+ validateHeader
45
44
} from '../../util/header-utils' ;
46
45
import { streamToBuffer , asBuffer } from '../../util/buffer-utils' ;
47
46
import {
48
- isLocalhostAddress ,
49
47
isLocalPortActive ,
50
48
isSocketLoop ,
51
49
requireSocketResetSupport ,
Original file line number Diff line number Diff line change
1
+ import * as http from 'http' ;
2
+
1
3
import {
2
4
Headers ,
5
+ OngoingResponse ,
3
6
RawHeaders
4
7
} from "../types" ;
5
8
@@ -190,4 +193,28 @@ export function h1HeadersToH2(headers: RawHeaders): RawHeaders {
190
193
return headers . filter ( ( [ key ] ) =>
191
194
! HTTP2_ILLEGAL_HEADERS . includes ( key . toLowerCase ( ) )
192
195
) ;
196
+ }
197
+
198
+ // If the user explicitly specifies headers, we tell Node not to handle them,
199
+ // so the user-defined headers are the full set.
200
+ export function dropDefaultHeaders ( response : OngoingResponse ) {
201
+ // Drop the default headers, so only the headers we explicitly configure are included
202
+ [
203
+ 'connection' ,
204
+ 'content-length' ,
205
+ 'transfer-encoding' ,
206
+ 'date'
207
+ ] . forEach ( ( defaultHeader ) =>
208
+ response . removeHeader ( defaultHeader )
209
+ ) ;
210
+ }
211
+
212
+ export function validateHeader ( name : string , value : string | string [ ] ) : boolean {
213
+ try {
214
+ http . validateHeaderName ( name ) ;
215
+ http . validateHeaderValue ( name , value ) ;
216
+ return true ;
217
+ } catch ( e ) {
218
+ return false ;
219
+ }
193
220
}
Original file line number Diff line number Diff line change @@ -107,30 +107,6 @@ export const writeHead = (
107
107
}
108
108
} ;
109
109
110
- // If the user explicitly specifies headers, we tell Node not to handle them,
111
- // so the user-defined headers are the full set.
112
- export function dropDefaultHeaders ( response : OngoingResponse ) {
113
- // Drop the default headers, so only the headers we explicitly configure are included
114
- [
115
- 'connection' ,
116
- 'content-length' ,
117
- 'transfer-encoding' ,
118
- 'date'
119
- ] . forEach ( ( defaultHeader ) =>
120
- response . removeHeader ( defaultHeader )
121
- ) ;
122
- }
123
-
124
- export function validateHeader ( name : string , value : string | string [ ] ) : boolean {
125
- try {
126
- http . validateHeaderName ( name ) ;
127
- http . validateHeaderValue ( name , value ) ;
128
- return true ;
129
- } catch ( e ) {
130
- return false ;
131
- }
132
- }
133
-
134
110
export function isHttp2 (
135
111
message : | http . IncomingMessage
136
112
| http . ServerResponse
You can’t perform that action at this time.
0 commit comments