Skip to content

Commit

Permalink
Tweaked the headers test to be apache independent and actually work.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaubourg committed Dec 11, 2010
1 parent 9d3a4a2 commit 0b0889c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
27 changes: 12 additions & 15 deletions test/data/headers.request.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?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 = 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;

$headers = apache_request_headers();
}

}

foreach( explode( "_" , $_GET[ "keys" ] ) as $key ) {
echo "$key: $headers[$key]\n";
echo "$key: " . $headers[ str_replace( " " , "-" , ucwords( strtolower( str_replace( "-" , " " , $key ) ) ) ) ] . "\n";
}
10 changes: 5 additions & 5 deletions test/unit/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,16 @@ test(".ajax() - headers" , function() {
stop();

var requestHeaders = {
Simple: "value",
"Something-Else": "other value",
Other: "something else"
siMPle: "value",
"SometHing-elsE": "other value",
OthEr: "something else"
},
list = [],
i,
sync = 2;

for( i in requestHeaders ) {
list.push( i.toLowerCase() );
list.push( i );
}

list = list.join( "_" );
Expand All @@ -305,7 +305,7 @@ test(".ajax() - headers" , function() {
success: function( data ) {
var tmp = [];
for ( i in requestHeaders ) {
tmp.push( i.toLowerCase() , ": " , requestHeaders[ i ] , "\n" );
tmp.push( i , ": " , requestHeaders[ i ] , "\n" );
}
tmp = tmp.join( "" );

Expand Down

0 comments on commit 0b0889c

Please sign in to comment.