Changeset 25046
- Timestamp:
- 08/17/2013 01:19:04 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-http.php
r25044 r25046 196 196 } 197 197 198 return $this->_dispatch_request($url, $r); 198 $response = $this->_dispatch_request($url, $r); 199 200 // Append cookies that were used in this request to the response 201 if ( ! empty( $r['cookies'] ) ) { 202 $cookies_set = wp_list_pluck( $response['cookies'], 'name' ); 203 foreach ( $r['cookies'] as $cookie ) { 204 if ( ! in_array( $cookie->name, $cookies_set ) && $cookie->test( $url ) ) { 205 $response['cookies'][] = $cookie; 206 } 207 } 208 } 209 210 return $response; 199 211 } 200 212 … … 638 650 if ( in_array( $response['response']['code'], array( 302, 303 ) ) ) 639 651 $args['method'] = 'GET'; 652 } 653 654 // Include valid cookies in the redirect process 655 if ( ! empty( $response['cookies'] ) ) { 656 foreach ( $response['cookies'] as $cookie ) { 657 if ( $cookie->test( $redirect_location ) ) 658 $args['cookies'][] = $cookie; 659 } 640 660 } 641 661 -
trunk/tests/data/WPHTTP-testcase-redirection-script.php
r25002 r25046 97 97 } 98 98 99 if ( isset( $_GET['cookie-test'] ) ) { 100 if ( 'test-cookie' != $_GET['cookie-test'] ) { 101 setcookie( 'api_test_cookie', 'value', time() + 365*24*60*60, '/core/tests/1.0/', 'api.wordpress.org' ); 102 setcookie( 'api_test_cookie_minimal', 'value' ); 103 setcookie( 'api_test_cookie_wrong_host', 'value', time() + 365*24*60*60, '/', 'example.com' ); 104 setcookie( 'api_test_wildcard_domain', 'value', time() + 365*24*60*60, '/', '.wordpress.org' ); 105 setcookie( 'api_test_cookie_expired', 'value', time() - 365*24*60*60, '/', '.wordpress.org' ); 106 header( "Location: $url?cookie-test=test-cookie" ); 107 exit; 108 } 109 110 if ( empty( $_COOKIE['api_test_cookie'] ) || 'value' != $_COOKIE['api_test_cookie'] ) 111 die( 'FAIL_NO_COOKIE' ); 112 if ( empty( $_COOKIE['api_test_cookie_minimal'] ) ) 113 die( 'FAIL_NO_MINIMAL' ); 114 if ( isset( $_COOKIE['api_test_cookie_wrong_host'] ) ) 115 die( 'FAIL_WRONG_HOST' ); 116 if ( empty( $_COOKIE['api_test_wildcard_domain'] ) ) 117 die( 'FAIL_NO_WILDCARD' ); 118 if ( isset( $_COOKIE['api_test_cookie_expired'] ) ) 119 die( 'FAIL_EXPIRED_COOKIE' ); 120 121 echo 'PASS'; 122 exit; 123 } 124 125 99 126 $rt = isset($_GET['rt']) ? $_GET['rt'] : 5; 100 127 $r = isset($_GET['r']) ? $_GET['r'] : 0; -
trunk/tests/tests/http/base.php
r25002 r25046 260 260 } 261 261 262 /** 263 * Test HTTP Cookie handling 264 * 265 * @ticket 21182 266 */ 267 function test_cookie_handling() { 268 $url = 'http://api.wordpress.org/core/tests/1.0/redirection.php?cookie-test=1'; 269 270 $res = wp_remote_get( $url ); 271 $this->assertEquals( 'PASS', wp_remote_retrieve_body( $res ) ); 272 } 262 273 }
Note: See TracChangeset
for help on using the changeset viewer.