$value ) {
if ( stripos($key, 'http') === 0 ) {
$key = strtolower(substr($key, 5));
echo "$key:$value\n";
}
}
exit;
}
if ( isset($_GET['multiple-headers']) ) {
header("HeaderName: One", false);
header("HeaderName: Two", false);
header("HeaderName: Three", false);
exit;
}
if ( isset( $_GET['post-redirect-to-method'] ) ) {
$method = $_SERVER['REQUEST_METHOD'];
$response_code = isset( $_GET['response_code'] ) ? $_GET['response_code'] : 301;
if ( 'POST' == $method && ! isset( $_GET['redirection-performed'] ) ) {
header( "Location: $url?post-redirect-to-method=1&redirection-performed=1", true, $response_code );
exit;
}
echo $method;
exit;
}
if ( isset( $_GET['location-with-200'] ) ) {
if ( ! isset( $_GET['redirection-performed'] ) ) {
header( "HTTP/1.1 200 OK" );
header( "Location: $url?location-with-200=1&redirection-performed", true, 200 );
echo 'PASS';
exit;
}
// Redirection was followed.
echo 'FAIL';
exit;
}
if ( isset( $_GET['print-pass'] ) ) {
echo 'PASS';
exit;
}
if ( isset( $_GET['multiple-location-headers'] ) ) {
if ( ! isset( $_GET['redirected'] ) ) {
header( "Location: $url?multiple-location-headers=1&redirected=one", false );
header( "Location: $url?multiple-location-headers=1&redirected=two", false );
exit;
}
if ( 'two' != $_GET['redirected'] )
echo 'FAIL';
else
echo 'PASS';
exit;
}
if ( isset( $_GET['cookie-test'] ) ) {
if ( 'test-cookie' != $_GET['cookie-test'] ) {
setcookie( 'api_test_cookie', 'value', time() + 365*24*60*60, '/core/tests/1.0/', 'api.wordpress.org' );
setcookie( 'api_test_cookie_minimal', 'value' );
setcookie( 'api_test_cookie_wrong_host', 'value', time() + 365*24*60*60, '/', 'example.com' );
setcookie( 'api_test_wildcard_domain', 'value', time() + 365*24*60*60, '/', '.wordpress.org' );
setcookie( 'api_test_cookie_expired', 'value', time() - 365*24*60*60, '/', '.wordpress.org' );
header( "Location: $url?cookie-test=test-cookie" );
exit;
}
if ( empty( $_COOKIE['api_test_cookie'] ) || 'value' != $_COOKIE['api_test_cookie'] )
die( 'FAIL_NO_COOKIE' );
if ( empty( $_COOKIE['api_test_cookie_minimal'] ) )
die( 'FAIL_NO_MINIMAL' );
if ( isset( $_COOKIE['api_test_cookie_wrong_host'] ) )
die( 'FAIL_WRONG_HOST' );
if ( empty( $_COOKIE['api_test_wildcard_domain'] ) )
die( 'FAIL_NO_WILDCARD' );
if ( isset( $_COOKIE['api_test_cookie_expired'] ) )
die( 'FAIL_EXPIRED_COOKIE' );
echo 'PASS';
exit;
}
$rt = isset($_GET['rt']) ? $_GET['rt'] : 5;
$r = isset($_GET['r']) ? $_GET['r'] : 0;
if ( $r < $rt ) {
$code = isset($_GET['code']) ? (int)$_GET['code'] : 302;
header("Location: $url?rt=" . $rt . "&r=" . ($r+1), true, $code);
echo "Redirect $r of $rt";
exit;
}
echo "Redirect $r of $rt is FINAL.
";
echo "GET['rt'] = Total times to redirect. Defaults to 5.
";
echo "GET['r'] = Current redirection. Defaults to 0.
";
echo "View Source";