if ( !responseHeaders ) {
responseHeaders = {};
while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
- responseHeaders[ match[ 1 ].toLowerCase() ] = match[ 2 ];
+ responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
+ ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
+ .concat( match[ 2 ] );
}
}
- match = responseHeaders[ key.toLowerCase() ];
+ match = responseHeaders[ key.toLowerCase() + " " ];
}
- return match == null ? null : match;
+ return match == null ? null : match.join( ", " );
},
// Raw string
header( 'Sample-Header: Hello World' );
header( 'Empty-Header: ' );
header( 'Sample-Header2: Hello World 2' );
+ header( 'List-Header: Item 1' );
+ header( 'list-header: Item 2' );
+ header( 'constructor: prototype collision (constructor)' );
foreach ( explode( '|' , $req->query[ 'keys' ] ) as $key ) {
// Only echo if key exists in the header
resp.writeHead( 200, {
"Sample-Header": "Hello World",
"Empty-Header": "",
- "Sample-Header2": "Hello World 2"
+ "Sample-Header2": "Hello World 2",
+ "List-Header": "Item 1",
+ "list-header": "Item 2",
+ "constructor": "prototype collision (constructor)"
} );
req.query.keys.split( "|" ).forEach( function( key ) {
if ( req.headers[ key.toLowerCase() ] ) {
} );
} );
- ajaxTest( "jQuery.ajax() - headers", 5, function( assert ) {
+ ajaxTest( "jQuery.ajax() - headers", 8, function( assert ) {
return {
setup: function() {
jQuery( document ).ajaxSend( function( evt, xhr ) {
assert.strictEqual( emptyHeader, "", "Empty header received" );
}
assert.strictEqual( xhr.getResponseHeader( "Sample-Header2" ), "Hello World 2", "Second sample header received" );
+ assert.strictEqual( xhr.getResponseHeader( "List-Header" ), "Item 1, Item 2", "List header received" );
+ assert.strictEqual( xhr.getResponseHeader( "constructor" ), "prototype collision (constructor)", "constructor header received" );
+ assert.strictEqual( xhr.getResponseHeader( "__proto__" ), null, "Undefined __proto__ header not received" );
}
};
} );