Ticket #17588: 17588.unit-tests.diff
File 17588.unit-tests.diff, 1.8 KB (added by , 12 years ago) |
---|
-
tests/http/base.php
128 128 } 129 129 130 130 /** 131 * @ticket 17588 132 */ 133 function test_redirections_method() { 134 $methods = array( 135 301 => 'POST', 136 307 => 'POST', 137 302 => 'GET', 138 303 => 'GET', 139 ); 140 141 foreach ( $methods as $code => $expected_method ) { 142 $url = add_query_arg( array( 143 'method-check' => 'true', 144 'code' => $code, 145 'rt' => 2, 146 ), $this->redirection_script ); 147 148 $res = wp_remote_request( $url, array( 'method' => 'POST' ) ); 149 $this->assertEquals( $expected_method, wp_remote_retrieve_header( $res, 'requestmethod' ), 'With code: ' . $code ); 150 } 151 } 152 153 /** 131 154 * Do not redirect on non 3xx status codes 132 155 * 133 156 * @ticket 16889 -
data/WPHTTP-testcase-redirection-script.php
51 51 exit; 52 52 } 53 53 54 if ( isset( $_GET['method-check'] ) ) 55 header( "requestmethod: " . $_SERVER['REQUEST_METHOD'] ); 56 54 57 $rt = isset($_GET['rt']) ? $_GET['rt'] : 5; 55 58 $r = isset($_GET['r']) ? $_GET['r'] : 0; 56 59 57 /*if ( $r === 0 ) {58 header("Location: http://tools.dd32.id.au/redirect/?r=1" );59 exit;60 }*/61 62 60 if ( $r < $rt ) { 63 61 $code = isset($_GET['code']) ? (int)$_GET['code'] : 302; 64 header("Location: $url?rt=" . $rt . "&r=" . ($r+1), true, $code); 62 63 $args = array( 64 'code' => $code, 65 'rt' => $rt, 66 'r' => $r+1, 67 ); 68 69 if ( isset( $_GET['method-check'] ) ) 70 $args['method-check'] = 'true'; 71 72 $url = $url . '?' . http_build_query( $args ); 73 header( "Location: $url", true, $code ); 65 74 echo "Redirect $r of $rt"; 66 75 exit; 67 76 }