Changeset 46690
- Timestamp:
- 11/10/2019 01:17:00 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-http.php
r46596 r46690 287 287 288 288 // If we are streaming to a file but no filename was given drop it in the WP temp dir 289 // and pick its name using the basename of the $url 289 // and pick its name using the basename of the $url. 290 290 if ( $parsed_args['stream'] ) { 291 291 if ( empty( $parsed_args['filename'] ) ) { … … 293 293 } 294 294 295 // Force some settings if we are streaming to a file and check for existence and perms of destination directory 295 // Force some settings if we are streaming to a file and check for existence 296 // and perms of destination directory. 296 297 $parsed_args['blocking'] = true; 297 298 if ( ! wp_is_writable( dirname( $parsed_args['filename'] ) ) ) { … … 313 314 } 314 315 315 // Setup arguments 316 // Setup arguments. 316 317 $headers = $parsed_args['headers']; 317 318 $data = $parsed_args['body']; … … 341 342 } 342 343 343 // Use byte limit, if we can 344 // Use byte limit, if we can. 344 345 if ( isset( $parsed_args['limit_response_size'] ) ) { 345 346 $options['max_bytes'] = $parsed_args['limit_response_size']; … … 351 352 } 352 353 353 // SSL certificate handling 354 // SSL certificate handling. 354 355 if ( ! $parsed_args['sslverify'] ) { 355 356 $options['verify'] = false; … … 387 388 } 388 389 389 // Avoid issues where mbstring.func_overload is enabled 390 // Avoid issues where mbstring.func_overload is enabled. 390 391 mbstring_binary_safe_encoding(); 391 392 … … 393 394 $requests_response = Requests::request( $url, $headers, $data, $type, $options ); 394 395 395 // Convert the response into an array 396 // Convert the response into an array. 396 397 $http_response = new WP_HTTP_Requests_Response( $requests_response, $parsed_args['filename'] ); 397 398 $response = $http_response->to_array(); … … 484 485 */ 485 486 public static function browser_redirect_compatibility( $location, $headers, $data, &$options, $original ) { 486 // Browser compat 487 // Browser compatibility. 487 488 if ( $original->status_code === 302 ) { 488 489 $options['type'] = Requests::GET; … … 495 496 * @since 4.7.5 496 497 * 497 * @throws Requests_Exception On unsuccessful URL validation 498 * @throws Requests_Exception On unsuccessful URL validation. 498 499 * @param string $location URL to redirect to. 499 500 */ … … 509 510 * @since 3.2.0 510 511 * 511 * @param array $args Request arguments 512 * @param string $url URL to Request 513 * 514 * @return string|false Class name for the first transport that claims to support the request. False if no transport claims to support the request. 512 * @param array $args Request arguments. 513 * @param string $url URL to Request. 514 * 515 * @return string|false Class name for the first transport that claims to support the request. 516 * False if no transport claims to support the request. 515 517 */ 516 518 public function _get_first_available_transport( $args, $url = null ) { … … 559 561 * @see WP_Http::request() 560 562 * 561 * @param string $url URL to Request 562 * @param array $args Request arguments 563 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error 563 * @param string $url URL to Request. 564 * @param array $args Request arguments. 565 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. 566 * A WP_Error instance upon error. 564 567 */ 565 568 private function _dispatch_request( $url, $args ) { … … 598 601 * @param string $url The request URL. 599 602 * @param string|array $args Optional. Override the defaults. 600 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error 603 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. 604 * A WP_Error instance upon error. 601 605 */ 602 606 public function post( $url, $args = array() ) { … … 615 619 * @param string $url The request URL. 616 620 * @param string|array $args Optional. Override the defaults. 617 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error 621 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. 622 * A WP_Error instance upon error. 618 623 */ 619 624 public function get( $url, $args = array() ) { … … 632 637 * @param string $url The request URL. 633 638 * @param string|array $args Optional. Override the defaults. 634 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error 639 * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. 640 * A WP_Error instance upon error. 635 641 */ 636 642 public function head( $url, $args = array() ) { … … 645 651 * @since 2.7.0 646 652 * 647 * @param string $strResponse The full response string 653 * @param string $strResponse The full response string. 648 654 * @return array Array with 'headers' and 'body' keys. 649 655 */ … … 660 666 * Transform header string into an array. 661 667 * 662 * If an array is given then it is assumed to be raw header data with numeric keys with the668 * If an array is given, then it is assumed to be raw header data with numeric keys with the 663 669 * headers as the values. No headers must be passed that were already processed. 664 670 * … … 666 672 * 667 673 * @param string|array $headers 668 * @param string $url The URL that was requested 674 * @param string $url The URL that was requested. 669 675 * @return array Processed string headers. If duplicate headers are encountered, 670 * Then a numbered array is returned as the value of that header-key.676 * then a numbered array is returned as the value of that header-key. 671 677 */ 672 678 public static function processHeaders( $headers, $url = '' ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid … … 732 738 } 733 739 734 // Cast the Response Code to an int 740 // Cast the Response Code to an int. 735 741 $response['code'] = intval( $response['code'] ); 736 742 … … 786 792 * @since 2.7.0 787 793 * 788 * @param string $body Body content 794 * @param string $body Body content. 789 795 * @return string Chunked decoded body on success or raw body on failure. 790 796 */ … … 919 925 * @since 3.4.0 920 926 * 921 * @param string $maybe_relative_path The URL which might be relative 922 * @param string $url The URL which $maybe_relative_path is relative to 927 * @param string $maybe_relative_path The URL which might be relative. 928 * @param string $url The URL which $maybe_relative_path is relative to. 923 929 * @return string An Absolute URL, in a failure condition where the URL cannot be parsed, the relative URL will be returned. 924 930 */ … … 945 951 $absolute_path = $url_parts['scheme'] . '://'; 946 952 947 // Schemeless URL's will make it this far, so we check for a host in the relative url and convert it to a protocol-url 953 // Schemeless URLs will make it this far, so we check for a host in the relative url 954 // and convert it to a protocol-url 948 955 if ( isset( $relative_url_parts['host'] ) ) { 949 956 $absolute_path .= $relative_url_parts['host']; … … 965 972 $path = $relative_url_parts['path']; 966 973 967 974 // Else it's a relative path. 968 975 } elseif ( ! empty( $relative_url_parts['path'] ) ) { 969 976 // Strip off any file components from the absolute path. … … 1053 1060 * an IP address. 1054 1061 * 1055 * @link http://home.deds.nl/~aeron/regex/ for IPv6 regex 1062 * @link http://home.deds.nl/~aeron/regex/ for IPv6 regex. 1056 1063 * 1057 1064 * @since 3.7.0 1058 1065 * 1059 * @param string $maybe_ip A suspected IP address 1066 * @param string $maybe_ip A suspected IP address. 1060 1067 * @return integer|bool Upon success, '4' or '6' to represent a IPv4 or IPv6 address, false upon failure 1061 1068 */
Note: See TracChangeset
for help on using the changeset viewer.