WordPress.org

Make WordPress Core

Ticket #40142: 40142_2.patch

File 40142_2.patch, 5.1 KB (added by sgarza, 2 years ago)

Revision to original patch(comments and formatting)

  • wp-includes/class-http.php

     
    605605         * @param string|array $args Optional. Override the defaults.
    606606         * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
    607607         */
    608         public function head($url, $args = array()) {
     608        public function head( $url, $args = array() ) {
    609609                $defaults = array('method' => 'HEAD');
    610610                $r = wp_parse_args( $args, $defaults );
    611611                return $this->request($url, $r);
    612612        }
     613 
     614  /**
     615         * Uses the PUT HTTP method.
     616         *
     617         * Used for sending data that is expected to be in the body.
     618         *
     619         * @access public
     620         * @since 2.7.0
     621         *
     622         * @param string $url The request URL.
     623         * @param string|array $args Optional. Override the defaults.
     624         * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
     625         */
     626        public function put( $url, $args = array() ) {
     627                $defaults = array( 'method' => 'PUT' );
     628                $r = wp_parse_args( $args, $defaults );
     629                return $this->request($url, $r);
     630        }
     631 
     632  /**
     633         * Uses the DELETE HTTP method.
     634         *
     635         * Used for sending data that is expected to be in the body.
     636         *
     637         * @access public
     638         * @since 2.7.0
     639         *
     640         * @param string $url The request URL.
     641         * @param string|array $args Optional. Override the defaults.
     642         * @return array|WP_Error Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error
     643         */
     644        public function delete( $url, $args = array() ) {
     645                $defaults = array( 'method' => 'DELETE' );
     646                $r = wp_parse_args( $args, $defaults );
     647                return $this->request($url, $r);
     648        }
    613649
    614650        /**
    615651         * Parses the responses and splits the parts into headers and body.
  • wp-includes/http.php

     
    113113}
    114114
    115115/**
     116 * Retrieve the raw response from a safe HTTP request using the PUT method.
     117 *
     118 * This function is ideal when the HTTP request is being made to an arbitrary
     119 * URL. The URL is validated to avoid redirection and request forgery attacks.
     120 *
     121 * @since 3.6.0
     122 *
     123 * @see wp_remote_request() For more information on the response array format.
     124 * @see WP_Http::request() For default arguments information.
     125 *
     126 * @param string $url Site URL to retrieve.
     127 * @param array $args Optional. Request arguments. Default empty array.
     128 * @return WP_Error|array The response or WP_Error on failure.
     129 */
     130function wp_safe_remote_put( $url, $args = array() ) {
     131        $args['reject_unsafe_urls'] = true;
     132        $http = _wp_http_get_object();
     133        return $http->put( $url, $args );
     134}
     135
     136/**
     137 * Retrieve the raw response from a safe HTTP request using the DELETE method.
     138 *
     139 * This function is ideal when the HTTP request is being made to an arbitrary
     140 * URL. The URL is validated to avoid redirection and request forgery attacks.
     141 *
     142 * @since 3.6.0
     143 *
     144 * @see wp_remote_request() For more information on the response array format.
     145 * @see WP_Http::request() For default arguments information.
     146 *
     147 * @param string $url Site URL to retrieve.
     148 * @param array $args Optional. Request arguments. Default empty array.
     149 * @return WP_Error|array The response or WP_Error on failure.
     150 */
     151function wp_safe_remote_delete( $url, $args = array() ) {
     152        $args['reject_unsafe_urls'] = true;
     153        $http = _wp_http_get_object();
     154        return $http->delete( $url, $args );
     155}
     156
     157/**
    116158 * Retrieve the raw response from the HTTP request.
    117159 *
    118160 * The array structure is a little complex:
     
    139181 *  - Default 'GET'  for wp_remote_get()
    140182 *  - Default 'POST' for wp_remote_post()
    141183 *  - Default 'HEAD' for wp_remote_head()
     184 *  - Default 'PUT'  for wp_remote_put()
     185 *  - Default 'DELETE' for wp_remote_delete()
    142186 *
    143187 * @since 2.7.0
    144188 *
     
    205249}
    206250
    207251/**
     252 * Retrieve the raw response from the HTTP request using the PUT method.
     253 *
     254 * @since 2.7.0
     255 *
     256 * @see wp_remote_request() For more information on the response array format.
     257 * @see WP_Http::request() For default arguments information.
     258 *
     259 * @param string $url  Site URL to retrieve.
     260 * @param array  $args Optional. Request arguments. Default empty array.
     261 * @return WP_Error|array The response or WP_Error on failure.
     262 */
     263function wp_remote_put( $url, $args = array() ) {
     264        $http = _wp_http_get_object();
     265        return $http->put( $url, $args );
     266}
     267
     268/**
     269 * Retrieve the raw response from the HTTP request using the DELETE method.
     270 *
     271 * @since 2.7.0
     272 *
     273 * @see wp_remote_request() For more information on the response array format.
     274 * @see WP_Http::request() For default arguments information.
     275 *
     276 * @param string $url  Site URL to retrieve.
     277 * @param array  $args Optional. Request arguments. Default empty array.
     278 * @return WP_Error|array The response or WP_Error on failure.
     279 */
     280function wp_remote_delete( $url, $args = array() ) {
     281        $http = _wp_http_get_object();
     282        return $http->delete( $url, $args );
     283}
     284
     285/**
    208286 * Retrieve only the headers from the raw response.
    209287 *
    210288 * @since 2.7.0