Changeset 25044
- Timestamp:
- 08/17/2013 12:33:39 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-http.php
r25016 r25044 159 159 160 160 if ( ! is_array( $r['headers'] ) ) { 161 $processedHeaders = WP_Http::processHeaders( $r['headers'] );161 $processedHeaders = WP_Http::processHeaders( $r['headers'], $url ); 162 162 $r['headers'] = $processedHeaders['headers']; 163 163 } … … 350 350 * 351 351 * @param string|array $headers 352 * @param string $url The URL that was requested 352 353 * @return array Processed string headers. If duplicate headers are encountered, 353 354 * Then a numbered array is returned as the value of that header-key. 354 355 */ 355 public static function processHeaders( $headers) {356 public static function processHeaders( $headers, $url ) { 356 357 // split headers, one per array element 357 358 if ( is_string($headers) ) { … … 401 402 } 402 403 if ( 'set-cookie' == $key ) 403 $cookies[] = new WP_Http_Cookie( $value );404 $cookies[] = new WP_Http_Cookie( $value, $url ); 404 405 } 405 406 … … 858 859 error_reporting($error_reporting); 859 860 860 $arrHeaders = WP_Http::processHeaders( $process['headers'] );861 $arrHeaders = WP_Http::processHeaders( $process['headers'], $url ); 861 862 862 863 $response = array( … … 1052 1053 $processedHeaders = array(); 1053 1054 if ( isset( $meta['wrapper_data']['headers'] ) ) 1054 $processedHeaders = WP_Http::processHeaders( $meta['wrapper_data']['headers']);1055 $processedHeaders = WP_Http::processHeaders( $meta['wrapper_data']['headers'], $url ); 1055 1056 else 1056 $processedHeaders = WP_Http::processHeaders( $meta['wrapper_data']);1057 $processedHeaders = WP_Http::processHeaders( $meta['wrapper_data'], $url ); 1057 1058 1058 1059 $response = array( … … 1302 1303 1303 1304 $theResponse = curl_exec( $handle ); 1304 $theHeaders = WP_Http::processHeaders( $this->headers );1305 $theHeaders = WP_Http::processHeaders( $this->headers, $url ); 1305 1306 $theBody = $this->body; 1306 1307 … … 1668 1669 * <li>Path (optional)</li> 1669 1670 * <li>Domain (optional)</li> 1671 * <li>Port (optional)</li> 1670 1672 * </ol> 1671 1673 * … … 1674 1676 * 1675 1677 * @param string|array $data Raw cookie data. 1676 */ 1677 function __construct( $data ) { 1678 * @param string $requested_url The URL which the cookie was set on, used for default 'domain' and 'port' values 1679 */ 1680 function __construct( $data, $requested_url = '' ) { 1681 $arrURL = @parse_url( $requested_url ); 1682 if ( isset( $arrURL['host'] ) ) 1683 $this->domain = $arrURL['host']; 1684 $this->path = isset( $arrURL['path'] ) ? $arrURL['path'] : '/'; 1685 if ( '/' != substr( $this->path, -1 ) ) 1686 $this->path = dirname( $this->path ) . '/'; 1687 1678 1688 if ( is_string( $data ) ) { 1679 1689 // Assume it's a header string direct from a previous request … … 1704 1714 1705 1715 // Set properties based directly on parameters 1706 $this->name = $data['name'];1707 $this->value = isset( $data['value'] ) ? $data['value'] : '';1708 $this->path = isset( $data['path'] ) ? $data['path'] : '';1709 $this->domain = isset( $data['domain'] ) ? $data['domain'] : '';1716 foreach ( array( 'name', 'value', 'path', 'domain', 'port' ) as $field ) { 1717 if ( isset( $data[ $field ] ) ) 1718 $this->$field = $data[ $field ]; 1719 } 1710 1720 1711 1721 if ( isset( $data['expires'] ) ) … … 1728 1738 */ 1729 1739 function test( $url ) { 1740 if ( is_null( $this->name ) ) 1741 return false; 1742 1730 1743 // Expires - if expired then nothing else matters 1731 1744 if ( isset( $this->expires ) && time() > $this->expires ) … … 1734 1747 // Get details on the URL we're thinking about sending to 1735 1748 $url = parse_url( $url ); 1736 $url['port'] = isset( $url['port'] ) ? $url['port'] : 80;1749 $url['port'] = isset( $url['port'] ) ? $url['port'] : ( 'https' == $url['scheme'] ? 443 : 80 ); 1737 1750 $url['path'] = isset( $url['path'] ) ? $url['path'] : '/'; 1738 1751 1739 1752 // Values to use for comparison against the URL 1740 1753 $path = isset( $this->path ) ? $this->path : '/'; 1741 $port = isset( $this->port ) ? $this->port : 80;1754 $port = isset( $this->port ) ? $this->port : null; 1742 1755 $domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] ); 1743 1756 if ( false === stripos( $domain, '.' ) ) … … 1750 1763 1751 1764 // Port - supports "port-lists" in the format: "80,8000,8080" 1752 if ( ! in_array( $url['port'], explode( ',', $port) ) )1765 if ( !empty( $port ) && !in_array( $url['port'], explode( ',', $port) ) ) 1753 1766 return false; 1754 1767
Note: See TracChangeset
for help on using the changeset viewer.