Simplified headers tests: removed multiline headers (support is far too servers & browsers dependant) and made all the tests in a single request.
This commit is contained in:
parent
0b0889ceaa
commit
974637d639
3 changed files with 24 additions and 46 deletions
|
@ -1,5 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
header( "Multiple-Line: Hello\n World" );
|
header( "Sample-Header: Hello World" );
|
||||||
header( "Multiple-Multiple-Line: Hello\n Beautiful\n\t World" );
|
|
||||||
header( "Single-Line: Hello World" );
|
$headers = array();
|
||||||
|
|
||||||
|
foreach( $_SERVER as $key => $value ) {
|
||||||
|
|
||||||
|
if ( substr( $key , 0 , 5 ) == "HTTP_" ) {
|
||||||
|
|
||||||
|
$key = str_replace( "_" , "-" , substr( $key , 5) );
|
||||||
|
$headers[ $key ] = $value;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
|
||||||
|
echo "$key: " . $headers[ strtoupper( $key ) ] . "\n";
|
||||||
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
$headers = array();
|
|
||||||
|
|
||||||
foreach( $_SERVER as $key => $value ) {
|
|
||||||
|
|
||||||
if ( substr( $key , 0 , 5 ) == "HTTP_" ) {
|
|
||||||
|
|
||||||
$key = str_replace( " " , "-" , ucwords( strtolower( str_replace( "_" , " " , substr( $key , 5) ) ) ) );
|
|
||||||
$headers[ $key ] = $value;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
|
|
||||||
echo "$key: " . $headers[ str_replace( " " , "-" , ucwords( strtolower( str_replace( "-" , " " , $key ) ) ) ) ] . "\n";
|
|
||||||
}
|
|
|
@ -280,8 +280,7 @@ test("jQuery.ajax() - error callbacks", function() {
|
||||||
|
|
||||||
test(".ajax() - headers" , function() {
|
test(".ajax() - headers" , function() {
|
||||||
|
|
||||||
// No multiple line headers in IE
|
expect( 2 );
|
||||||
expect( jQuery.browser.msie ? 3 : 5 );
|
|
||||||
|
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
|
@ -291,18 +290,15 @@ test(".ajax() - headers" , function() {
|
||||||
OthEr: "something else"
|
OthEr: "something else"
|
||||||
},
|
},
|
||||||
list = [],
|
list = [],
|
||||||
i,
|
i;
|
||||||
sync = 2;
|
|
||||||
|
|
||||||
for( i in requestHeaders ) {
|
for( i in requestHeaders ) {
|
||||||
list.push( i );
|
list.push( i );
|
||||||
}
|
}
|
||||||
|
|
||||||
list = list.join( "_" );
|
jQuery.ajax(url("data/headers.php?keys="+list.join( "_" ) ), {
|
||||||
|
|
||||||
jQuery.ajax(url("data/headers.request.php?keys="+list), {
|
|
||||||
headers: requestHeaders,
|
headers: requestHeaders,
|
||||||
success: function( data ) {
|
success: function( data , _ , xhr ) {
|
||||||
var tmp = [];
|
var tmp = [];
|
||||||
for ( i in requestHeaders ) {
|
for ( i in requestHeaders ) {
|
||||||
tmp.push( i , ": " , requestHeaders[ i ] , "\n" );
|
tmp.push( i , ": " , requestHeaders[ i ] , "\n" );
|
||||||
|
@ -310,23 +306,8 @@ test(".ajax() - headers" , function() {
|
||||||
tmp = tmp.join( "" );
|
tmp = tmp.join( "" );
|
||||||
|
|
||||||
equals( data , tmp , "Headers were sent" );
|
equals( data , tmp , "Headers were sent" );
|
||||||
if ( ! --sync ) start();
|
equals( xhr.getResponseHeader( "Sample-Header" ) , "Hello World" , "Sample header received" );
|
||||||
}
|
start();
|
||||||
});
|
|
||||||
|
|
||||||
jQuery.ajax({
|
|
||||||
url: url("data/headers.php"),
|
|
||||||
success: function( _1 , _2 , xhr ){
|
|
||||||
ok(true, "success");
|
|
||||||
equals( xhr.getResponseHeader( "Single-Line" ) , "Hello World" , "Single line header" );
|
|
||||||
// No multiple line headers in IE
|
|
||||||
if ( ! jQuery.browser.msie ) {
|
|
||||||
// Each browser has its own unique way to deal with spaces after line breaks
|
|
||||||
// in multiple line headers, so we use regular expressions
|
|
||||||
ok( /^Hello\s+World$/.test( xhr.getResponseHeader( "Multiple-Line" ) ) , "Multiple line" );
|
|
||||||
ok( /^Hello\s+Beautiful\s+World$/.test( xhr.getResponseHeader( "Multiple-Multiple-Line" ) ) , "Multiple multiple line" );
|
|
||||||
}
|
|
||||||
if ( ! --sync ) start();
|
|
||||||
},
|
},
|
||||||
error: function(){ ok(false, "error"); }
|
error: function(){ ok(false, "error"); }
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue