Removed non-standard (and not that useful) xhr emulation methods & reworked the headers test as a consequence.
This commit is contained in:
parent
317888464d
commit
9b9d270e3d
3 changed files with 55 additions and 37 deletions
21
test/data/headers.request.php
Normal file
21
test/data/headers.request.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
if (!function_exists('apache_request_headers')) {
|
||||
function apache_request_headers() {
|
||||
foreach($_SERVER as $key=>$value) {
|
||||
if (substr($key,0,5)=="HTTP_") {
|
||||
$key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5)))));
|
||||
$out[$key]=$value;
|
||||
}else{
|
||||
$out[$key]=$value;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
|
||||
$headers = apache_request_headers();
|
||||
|
||||
foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
|
||||
echo "$key: $headers[$key]\n";
|
||||
}
|
|
@ -281,10 +281,39 @@ test("jQuery.ajax() - error callbacks", function() {
|
|||
test(".ajax() - headers" , function() {
|
||||
|
||||
// No multiple line headers in IE
|
||||
expect( jQuery.browser.msie ? 2 : 4 );
|
||||
expect( jQuery.browser.msie ? 3 : 5 );
|
||||
|
||||
stop();
|
||||
|
||||
var requestHeaders = {
|
||||
Simple: "value",
|
||||
"Something-Else": "other value",
|
||||
Other: "something else"
|
||||
},
|
||||
list = [],
|
||||
i,
|
||||
sync = 2;
|
||||
|
||||
for( i in requestHeaders ) {
|
||||
list.push( i.toLowerCase() );
|
||||
}
|
||||
|
||||
list = list.join( "_" );
|
||||
|
||||
jQuery.ajax(url("data/headers.request.php?keys="+list), {
|
||||
headers: requestHeaders,
|
||||
success: function( data ) {
|
||||
var tmp = [];
|
||||
for ( i in requestHeaders ) {
|
||||
tmp.push( i.toLowerCase() , ": " , requestHeaders[ i ] , "\n" );
|
||||
}
|
||||
tmp = tmp.join( "" );
|
||||
|
||||
equals( data , tmp , "Headers were sent" );
|
||||
if ( ! --sync ) start();
|
||||
}
|
||||
});
|
||||
|
||||
jQuery.ajax({
|
||||
url: url("data/headers.php"),
|
||||
success: function( _1 , _2 , xhr ){
|
||||
|
@ -297,11 +326,11 @@ test(".ajax() - headers" , function() {
|
|||
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" );
|
||||
}
|
||||
start();
|
||||
if ( ! --sync ) start();
|
||||
},
|
||||
error: function(){ ok(false, "error"); }
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
test(".ajax() - hash", function() {
|
||||
|
@ -1813,23 +1842,6 @@ test("jQuery.ajax - Etag support", function() {
|
|||
});
|
||||
});
|
||||
|
||||
test("jQuery ajax - headers", function() {
|
||||
|
||||
stop();
|
||||
|
||||
jQuery.ajax(url("data/css.php?wait=1&id=headers"), {
|
||||
headers: {
|
||||
testKey: "testValue"
|
||||
},
|
||||
beforeSend: function( xhr ) {
|
||||
equals( xhr.getRequestHeader("testKey") , "testValue" , "Headers properly set" );
|
||||
setTimeout( start , 13 );
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test("jQuery ajax - failing cross-domain", function() {
|
||||
|
||||
expect( 2 );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue