File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -122,7 +122,12 @@ Request.prototype._createReqRes = function () {
122
122
123
123
for ( var param in this . params ) {
124
124
if ( HEADER_EXPR . test ( param ) || param === 'CONTENT_LENGTH' || param === 'CONTENT_TYPE' ) {
125
- var name = param . slice ( 5 ) . replace ( UNDERSCORE_EXPR , '-' ) ;
125
+ var name = param . replace ( HEADER_EXPR , '' ) . replace ( UNDERSCORE_EXPR , '-' ) ;
126
+
127
+ // Ignore HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH
128
+ if ( HEADER_EXPR . test ( param ) && ( name . toLowerCase ( ) === 'content-type' || name . toLowerCase ( ) === 'content-length' ) )
129
+ continue ;
130
+
126
131
var value = this . params [ param ] ;
127
132
raw . push ( name , value ) ;
128
133
this . _req . _addHeaderLine ( name , value , dest ) ;
Original file line number Diff line number Diff line change @@ -194,14 +194,18 @@ describe('echo Server', function setup() {
194
194
195
195
it ( 'should answer with correct request header names' , function checkResponse ( done ) {
196
196
var hdr1 = 'test1' ,
197
- hdr2 = 'test2' ;
197
+ hdr2 = 'test2' ,
198
+ cl = '23' ,
199
+ ct = 'text/plain' ;
198
200
199
201
request ( {
200
202
uri : 'http://localhost:' + port ,
201
203
method : 'GET' ,
202
204
headers : {
203
- 'x_testhdr' : hdr1 , // XXX: Using underscores because fcgi-handler
204
- 'x_test_hdr' : hdr2 // passes hyphens in CGI params
205
+ 'x_testhdr' : hdr1 , // XXX: Using underscores because fcgi-handler
206
+ 'x_test_hdr' : hdr2 , // passes hyphens in CGI params
207
+ 'content-length' : cl ,
208
+ 'content-type' : 'text/plain'
205
209
}
206
210
} , function ( err , res , body ) {
207
211
expect ( res . statusCode ) . to . be . equal ( 200 ) ;
@@ -210,6 +214,8 @@ describe('echo Server', function setup() {
210
214
var echo = JSON . parse ( body ) ;
211
215
expect ( echo ) . to . have . deep . property ( 'headers.x-testhdr' , hdr1 ) ;
212
216
expect ( echo ) . to . have . deep . property ( 'headers.x-test-hdr' , hdr2 ) ;
217
+ expect ( echo ) . to . have . deep . property ( 'headers.content-length' , cl ) ;
218
+ expect ( echo ) . to . have . deep . property ( 'headers.content-type' , ct ) ;
213
219
214
220
done ( err ) ;
215
221
} ) ;
You can’t perform that action at this time.
0 commit comments