Commit Graph

249 Commits

Author SHA1 Message Date
Dion Hulse
35a0240fb2 WP_HTTP: Map internal Requests hooks to WordPress actions.
This change introduces a `requests-{$hook}` action which can be used to hook into Requests hooks, and restores the `http_api_curl` action.

Props rmccue.
Fixes #37843.

Built from https://develop.svn.wordpress.org/trunk@39212


git-svn-id: http://core.svn.wordpress.org/trunk@39152 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-11-13 10:36:29 +00:00
Dion Hulse
7ac6b18d89 HTTP: Call mbstring_binary_safe_encoding() before making a request with Requests to avoid issues with mbstring.func_overload.
Props SergeyBiryukov.
Fixes #38226.

Built from https://develop.svn.wordpress.org/trunk@38894


git-svn-id: http://core.svn.wordpress.org/trunk@38837 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-25 00:45:29 +00:00
Dion Hulse
d317fa487f HTTP: Update Requests to master (0048f3c) which fixes a number of outstanding issues.
Fixes #38070, #37733 by reverting part of [38429] and using the fix in Requests.
Fixes #37992 allowing for connecting to SSL resources on ports other than 443.
Fixes #37991 by not sending default ports in the `Host:` header.
Fixes #37839 to match and decode Chunked responses correctly.
Fixes #38232 allowing a SSL connection to ignore the hostname of the certificate when verification is disabled.

Built from https://develop.svn.wordpress.org/trunk@38727


git-svn-id: http://core.svn.wordpress.org/trunk@38670 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-05 03:24:37 +00:00
Scott Taylor
a3ffebce30 Bootstrap: do not go gentle into that good night r38411, r38412, and parts of r38389.
See #36335.

Built from https://develop.svn.wordpress.org/trunk@38470


git-svn-id: http://core.svn.wordpress.org/trunk@38411 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-31 16:31:29 +00:00
Scott Taylor
9383bf8f74 General: use get_bloginfo( 'version' ) instead of global $wp_version in several locations - excluding those locations which reload version.php mid-flight.
See #37699.

Built from https://develop.svn.wordpress.org/trunk@38459


git-svn-id: http://core.svn.wordpress.org/trunk@38400 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-31 05:49:37 +00:00
Dion Hulse
30270d851f HTTP: Accept non-string values in cookies, fixing a regression since 4.5.
Props swissspidy.
Fixes #37768 for trunk.

Built from https://develop.svn.wordpress.org/trunk@38430


git-svn-id: http://core.svn.wordpress.org/trunk@38371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-29 02:42:45 +00:00
Dion Hulse
e45ebb28f2 HTTP: Handle an edgecase within the URI parsing library included in Requests, where if a double slash exists at the start of the path the URL is passed to cURL malformed.
Props flixos90 for initial patch.
Fixes #37733 for trunk.

Built from https://develop.svn.wordpress.org/trunk@38429


git-svn-id: http://core.svn.wordpress.org/trunk@38370 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-29 02:33:34 +00:00
Scott Taylor
390ceba6c7 Bootstrap: after r38409 and r38410, revert r38402 which reverted r38399.
This fixes the paths in `wp-vendor/` that were including `src`. I want to drop this in so we can find out what else will break.

See #36335.

Built from https://develop.svn.wordpress.org/trunk@38411


git-svn-id: http://core.svn.wordpress.org/trunk@38352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 22:32:37 +00:00
Dion Hulse
0e31a46161 Bootstrap: Revert [38399] as it's broken /build/ and subsequently core.svn.wordpress.org.
The generated classmaps reference `/src/` files and operates in the assumption that the base directory is one level above `wp-settings.php`, which it isn't after our build processes are run.

See #36335

Built from https://develop.svn.wordpress.org/trunk@38402


git-svn-id: http://core.svn.wordpress.org/trunk@38343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 14:37:32 +00:00
Scott Taylor
6a529648cf Bootstrap: Autoload classes using a Composer-generated PHP 5.2-compatible Autoloader.
* `wp-admin` and `wp-includes` are scanned for classes to autoload
* Several 3rd-party and Ryan McCue-shaped libraries are excluded when the classmap is generated, see `composer.json`: `autoload.exclude-from-classmap`
* `wp-vendor/autoload_52.php` is included at the top of `wp-settings.php` - no changes need to be made to unit tests to include the autoloader
* An avalanche of `require()` and `require_once()` calls that loaded class files have been removed from the codebase.

The following files have been added to `svn:ignore` - they are not 5.2-compatible and fail during pre-commit:
* src/wp-vendor/autoload.php
* src/wp-vendor/composer/autoload_real.php
* src/wp-vendor/composer/autoload_static.php
* src/wp-vendor/composer/ClassLoader.php

We favor these files instead:
* src/wp-vendor/autoload_52.php
* src/wp-vendor/composer/autoload_real_52.php
* src/wp-vendor/composer/ClassLoader52.php

When new PHP classes are added to the codebase, simply run `composer install` or `composer update` from the project root to update the autoloader.

The future is now.

See #36335.

Built from https://develop.svn.wordpress.org/trunk@38399


git-svn-id: http://core.svn.wordpress.org/trunk@38340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-08-27 09:15:29 +00:00
Dominik Schilling
e64c675fc5 HTTP API: Set $use_authentication property of Requests_Proxy_HTTP to true when proxy authentication is required.
Props francescobagnoli for initial patch.
Fixes #37494.
Built from https://develop.svn.wordpress.org/trunk@38173


git-svn-id: http://core.svn.wordpress.org/trunk@38114 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-31 18:20:29 +00:00
Dominik Schilling
7e49f103be HTTP API: All non-GET/HEAD requests should put the arguments in the form body.
Requests defaults to _GET/query for HEAD/GET/DELETE and _POST/body for POST/PUT/OPTIONS/PATCH. For backward compatibility `WP_HTTP` needs to force `data_format` to 'body' for all non-GET/HEAD requests.

Props dd32.
Fixes #37456.
Built from https://develop.svn.wordpress.org/trunk@38165


git-svn-id: http://core.svn.wordpress.org/trunk@38106 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-27 15:52:28 +00:00
Dominik Schilling
b2607f8d78 HTTP API: Normalize cookies before passing them to Requests.
Requests has its own cookie object in form of `Requests_Cookie`. Therefore we have to convert `WP_Http_Cookie` objects to `Requests_Cookie`.
This introduces `WP_Http_Cookie::get_attributes()` to retrieve cookie attributes of a `WP_Http_Cookie` object and `WP_Http::normalize_cookies()` to convert the cookie objects.

Fixes #37437.
Built from https://develop.svn.wordpress.org/trunk@38164


git-svn-id: http://core.svn.wordpress.org/trunk@38105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-27 15:32:27 +00:00
Dominik Schilling
67de1f07d3 HTTP API: Pass proxy settings to Requests.
`WP_HTTP_Proxy()` is used directly in `WP_Http_Curl()` and `WP_Http_Streams()`. Since `WP_Http::request()` doesn't use them anymore we have to move the proxy handling into `WP_Http::request()` so the proxy data can be passed to `Requests::request()`.

Props rmccue.
See #33055.
Fixes #37107.
Built from https://develop.svn.wordpress.org/trunk@38054


git-svn-id: http://core.svn.wordpress.org/trunk@37995 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-13 15:51:28 +00:00
John Blackbourn
7e7dfdea55 HTTP API: Remove duplicate documentation for the http_api_debug hook.
Fixes #37081

Built from https://develop.svn.wordpress.org/trunk@38043


git-svn-id: http://core.svn.wordpress.org/trunk@37984 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-13 10:23:43 +00:00
Ryan McCue
ff6a4875a8 HTTP API: Switch back to returning an array.
The array-compatibility object we started returning in r37428 unfortunately isn't enough like an array. In particular, `is_array()` checks fail, despite the object implementing ArrayAccess. Mea culpa.

This moves the WP_HTTP_Response object to a new http_response key in the array, and changes the value back to an actual array.

Fixes #37097.
See #33055.

Built from https://develop.svn.wordpress.org/trunk@37989


git-svn-id: http://core.svn.wordpress.org/trunk@37930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-06 17:51:30 +00:00
Peter Wilson
47d26cd9fb DOCS: Replace HTTP links with HTTPS.
Replaces unsecure links in documentation and translator comments with their secure versions.

Props johnpgreen, netweb

Fixes #36993

Built from https://develop.svn.wordpress.org/trunk@37674


git-svn-id: http://core.svn.wordpress.org/trunk@37640 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-10 04:50:33 +00:00
Drew Jaynes
fe3129f470 Docs: Standardize filter docs in wp-includes/class-http.php to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

Built from https://develop.svn.wordpress.org/trunk@37514


git-svn-id: http://core.svn.wordpress.org/trunk@37482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:43:27 +00:00
Ryan McCue
6da21bc4f4 HTTP API: Pass array-like object to http_api_debug.
This was mistakingly passing the Requests_Response object, which caused fatal errors with debugging tools.

See #33055.

Built from https://develop.svn.wordpress.org/trunk@37436


git-svn-id: http://core.svn.wordpress.org/trunk@37402 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-16 06:12:29 +00:00
Ryan McCue
dee1d583a7 HTTP API: Add browser compatibility hook for 3xx redirects.
WordPress erroneously follows browser-style behaviour with 3xx redirects, where a POST to 302 becomes a GET. Requests instead follows the specification and keeps the same method. Requests also exposes a hook to allow changing the behaviour.

[37428] used the wrong method of adding this hook, now corrected.

See #33055.

Built from https://develop.svn.wordpress.org/trunk@37429


git-svn-id: http://core.svn.wordpress.org/trunk@37395 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-13 05:11:27 +00:00
Ryan McCue
37f6e6813a HTTP API: Replace internals with Requests library.
Requests is a library very similar to WP_HTTP, with a high level of unit test coverage, and has a common lineage and development team. It also supports parallel requests.

See #33055.

Built from https://develop.svn.wordpress.org/trunk@37428


git-svn-id: http://core.svn.wordpress.org/trunk@37394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-13 04:42:28 +00:00
Drew Jaynes
fe3b007fdd Docs: Remove inline @see tags from function, class, and method references in inline docs.
Known functions, classes, and methods are now auto-linked in Code Reference pages following #meta1483.

Note: Hook references are still linked via inline `@see` tags due to the unlikelihood of reliably matching for known hooks based on a RegEx pattern.

See #32246.

Built from https://develop.svn.wordpress.org/trunk@37342


git-svn-id: http://core.svn.wordpress.org/trunk@37308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-02 04:00:28 +00:00
John Blackbourn
5edba14d1a HTTP API: Add the missing 1xx HTTP response codes as constants of the WP_Http class, and add tests to ensure all available response codes are covered.
Fixes #36294

Built from https://develop.svn.wordpress.org/trunk@36749


git-svn-id: http://core.svn.wordpress.org/trunk@36716 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-28 01:46:26 +00:00
Eric Lewis
22467e840f Networks and sites: Replace "blog" usage with "site" in docs.
Multisite functions use the term "blog" to refer to what we now call a "site," e.g. `get_current_blog_id()`. These functions are here to stay because of our commitment to backwards compatibility. What we can do is set the documentation straight.

See #35417.

Built from https://develop.svn.wordpress.org/trunk@36416


git-svn-id: http://core.svn.wordpress.org/trunk@36383 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-28 03:35:27 +00:00
Drew Jaynes
42caba7134 Docs: Update the @access tag value for WP_Http::_get_first_available_transport() from private to public.
When the method was introduced in [17914], the name was underscore-prefixed as is core style for private-use, though it was also introduced with a `public` access modifier for the declaration. Due to core's committment to backward-compatibility, the access modifier overrules in this case, meaning that while the method is underscore-prefixed and was originally-intentioned to be private, it is and always will be a public method, and the documentation should reflect that.

Props Frozzare.
Fixes #35289.

Built from https://develop.svn.wordpress.org/trunk@36367


git-svn-id: http://core.svn.wordpress.org/trunk@36334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-20 18:46:26 +00:00
Joe Hoyle
0f9b770b6c Add response status code aliases on WP_Http for convenience.
These provide a more descriptive way to set response codes elsewhere,
so it's readable and less chance for the wrong response code to be
used such as 401 vs 403.

Props rmccue for the idea.
Fixes #35426.

Built from https://develop.svn.wordpress.org/trunk@36294


git-svn-id: http://core.svn.wordpress.org/trunk@36261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-14 03:16:27 +00:00
John Blackbourn
0003a004db Docs: Miscellaneous docblock code quality tweaks.
See #32246

Built from https://develop.svn.wordpress.org/trunk@36074


git-svn-id: http://core.svn.wordpress.org/trunk@36039 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-23 07:53:26 +00:00
Drew Jaynes
0404082b18 Docs: Syntax fixes for deprecating WP_Http::parse_url().
See #32246.

Built from https://develop.svn.wordpress.org/trunk@35375


git-svn-id: http://core.svn.wordpress.org/trunk@35339 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-23 15:43:24 +00:00
Dion Hulse
7912c647ae WP_HTTP: Promote the WP_HTTP::parse_url() method to a more generic wp_parse_url() function.
Fixes #34408

Built from https://develop.svn.wordpress.org/trunk@35369


git-svn-id: http://core.svn.wordpress.org/trunk@35333 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-23 05:54:25 +00:00
Scott Taylor
5acee30d9d Docs: object != class
See [33893] et al.

Built from https://develop.svn.wordpress.org/trunk@34585


git-svn-id: http://core.svn.wordpress.org/trunk@34549 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-26 07:04:28 +00:00
Drew Jaynes
4c7a4bfb25 Docs: Improve the summary and description for the pre_http_request filter docs to better illustrate expected values.
The filter explicitly expects one of three passed value types:

*  An array containing 'headers', 'body', 'response', 'cookies', and 'filename' elements
*  A `WP_Error` instance
*  Boolean false (to avoid short-circuiting the response)

Props johnbillion.
Fixes #33995.

Built from https://develop.svn.wordpress.org/trunk@34509


git-svn-id: http://core.svn.wordpress.org/trunk@34473 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 18:52:25 +00:00
John Blackbourn
fdb8400379 Place the filter docblock for http_api_transports immediately above the filter.
See #33413
Props dd32

Built from https://develop.svn.wordpress.org/trunk@34174


git-svn-id: http://core.svn.wordpress.org/trunk@34142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 08:12:25 +00:00
Scott Taylor
3a0db2a22f Fix the case-sensitivity of some HTTP class usage.
See #33413.

Built from https://develop.svn.wordpress.org/trunk@34123


git-svn-id: http://core.svn.wordpress.org/trunk@34091 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-14 17:37:25 +00:00
Drew Jaynes
853fd32e88 Docs: Add a missing file header for wp-includes/class-http.php.
Also clarifies the class DocBlock summary for `WP_Http` to more clearly describe its purpose.

See #33413. See #33701.

Built from https://develop.svn.wordpress.org/trunk@33880


git-svn-id: http://core.svn.wordpress.org/trunk@33849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-03 03:39:21 +00:00
Scott Taylor
7c8c216bec HTTP: move classes into their own files, http.php loads the new files, so this is 100% BC if someone is loading http.php directly. New files created using svn cp.
`class-http.php` requires functions from `http.php`, so loading it by itself wouldn't have worked.

Creates: 
`class-wp-http-cookie.php` 
`class-wp-http-curl.php` 
`class-wp-http-encoding.php` 
`class-wp-http-proxy.php` 
`class-wp-http-streams.php` 
`http-functions.php` 

`WP_Http` remains in `class-http.php`.

`http.php` contains only top-level code. Class files only contain classes. Functions file only contains functions.

See #33413.

Built from https://develop.svn.wordpress.org/trunk@33748


git-svn-id: http://core.svn.wordpress.org/trunk@33716 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-26 03:55:21 +00:00
Scott Taylor
a0e373ef80 For doc block types, favor bool over the few remaining booleans
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32964


git-svn-id: http://core.svn.wordpress.org/trunk@32935 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-27 01:03:25 +00:00
Dion Hulse
6657e42c7d WP_HTTP: ensure that the temporary file is created within the temporary directly when stream is specified without a filename parameter.
Fixes #32549

Built from https://develop.svn.wordpress.org/trunk@32712


git-svn-id: http://core.svn.wordpress.org/trunk@32682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-09 03:55:27 +00:00
Scott Taylor
19a3aacc94 Add @static* annotations where they are missing.
Initialize all static vars that are not, most to `null`.

See #32444.

Built from https://develop.svn.wordpress.org/trunk@32650


git-svn-id: http://core.svn.wordpress.org/trunk@32620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-29 15:43:29 +00:00
Scott Taylor
082bfab426 Clean up @global doc blocks/imports for class-wp-customizer-*.php and friends.
See #32444.

Built from https://develop.svn.wordpress.org/trunk@32542


git-svn-id: http://core.svn.wordpress.org/trunk@32512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-22 05:06:25 +00:00
Scott Taylor
d577c673e2 self should be used for accessing local static members.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@31683


git-svn-id: http://core.svn.wordpress.org/trunk@31664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-09 02:22:26 +00:00
Scott Taylor
0ec87e4584 There are a few functions that have the ability to return false instead of a string, so the return value should be checked before being passed to functions that expect string.
These are trivial, but they clear out some Scrutinizer issues.

See #30799.

Built from https://develop.svn.wordpress.org/trunk@31681


git-svn-id: http://core.svn.wordpress.org/trunk@31662 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-09 02:11:28 +00:00
Dion Hulse
65e7885c01 HTTP API: Fix an issue where the limit_response_size parameter wasn't working properly with large documents and the cURL transport.
Fixes #31172

Built from https://develop.svn.wordpress.org/trunk@31290


git-svn-id: http://core.svn.wordpress.org/trunk@31271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-29 03:58:23 +00:00
Scott Taylor
0a511680f4 Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value. Constructors do not have meaningful return values, anything that is returned from here is discarded.
See #30799.

Built from https://develop.svn.wordpress.org/trunk@31126


git-svn-id: http://core.svn.wordpress.org/trunk@31107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-10 06:54:23 +00:00
Scott Taylor
60b0cd7943 The keyword elseif should be used instead of else if so that all control keywords look like single words.
This was a mess, is now standardized across the codebase, except for a few 3rd-party libs. 

See #30799.

Built from https://develop.svn.wordpress.org/trunk@31090


git-svn-id: http://core.svn.wordpress.org/trunk@31071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 07:05:25 +00:00
Drew Jaynes
0cbaa88027 Fix a typo in the DocBlock for WP_Http_Curl::$bytes_written_total introduced in [29968].
Props kpdesign.
See #26726.

Built from https://develop.svn.wordpress.org/trunk@30767


git-svn-id: http://core.svn.wordpress.org/trunk@30757 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-07 05:16:24 +00:00
Scott Taylor
e619abda6e Improve various @param docs for src/wp-includes/*.
See #30224.

Built from https://develop.svn.wordpress.org/trunk@30681


git-svn-id: http://core.svn.wordpress.org/trunk@30671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-01 01:34:24 +00:00
Drew Jaynes
9dcb6daec2 4.1 Docs Audit: Fix some line-wrapping in the DocBlock for WP_Http::parse_url().
See #30469.

Built from https://develop.svn.wordpress.org/trunk@30604


git-svn-id: http://core.svn.wordpress.org/trunk@30594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-28 09:14:23 +00:00
Drew Jaynes
8f6188ae53 Ensure inline code is markdown-escaped as such, and that code snippets in descriptions are properly indented.
Affects DocBlocks for the following core elements:
* Two arguments in `_walk_bookmarks()`
* A code snippet in the class header for `WP_Roles`
* A code snippet in the class header for `WP_HTTP_Proxy`
* Inline code fixes in the summary and a parameter description for `WP_oEmbed::discover()`
* An argument description in `_WP_Editors::parse_settings()`
* Inline code fixes in the summary and a parameter description the `embed_oembed_discover` hook.

Props rarst.
See #30473.

Built from https://develop.svn.wordpress.org/trunk@30536


git-svn-id: http://core.svn.wordpress.org/trunk@30525 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-24 04:42:22 +00:00
Drew Jaynes
f8657d5890 Remove redundant and erroneous @uses tag from most core inline documentation.
Per our inline documentation standards, no further use of the `@uses` tag is recommended as used and used-by relationships can be derived through other means. This removes most uses of the tag in core documentation, with remaining tags to be converted to `@global` or `@see` as they apply.

Fixes #30191.

Built from https://develop.svn.wordpress.org/trunk@30105


git-svn-id: http://core.svn.wordpress.org/trunk@30105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-30 01:05:24 +00:00
Dion Hulse
2e30f3d891 HTTP API: Support both the 'limit_response_size' and 'stream' parameters at the same time, allowing a partial file download.
Fixes #26726

Built from https://develop.svn.wordpress.org/trunk@29968


git-svn-id: http://core.svn.wordpress.org/trunk@29714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-20 07:32:21 +00:00
Dion Hulse
659a6b3838 Add some unit tests for WP_HTTP::parse_url() to cover the <PHP 5.4.7 compatibility alterations.
These unit tests cover the expected vehaviour of certain combinations of URL's, but makes no attempt to test invalid URL structures, as PHP's behavious for invalid URL's is undefined (Some will be treated as paths, others fail, and it varies between PHP 5.4.7+ and <5.4.7).
This change also makes WP_HTTP::parse_url() protected in order to allow unit testing.
See #28001, #29886

Built from https://develop.svn.wordpress.org/trunk@29864


git-svn-id: http://core.svn.wordpress.org/trunk@29624 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-09 03:01:18 +00:00
Dion Hulse
dbb6750bb2 Handle deficiencies in PHP's parse_url in older versions of PHP (<5.4.7) in WP_HTTP::make_absolute_url().
In older versions of PHP:
- parse_url() will fail to parse a url where the scheme break (://) is present in a relative URL's path
- parse_url() will include the hostname of a schemeless URL in the path component

This handles those two types of URL's by correcting the response from parse_url().

Fixes #28001, #29886

Built from https://develop.svn.wordpress.org/trunk@29861


git-svn-id: http://core.svn.wordpress.org/trunk@29621 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-09 01:11:18 +00:00
Dion Hulse
98ff88518a Avoid a PHP Notice when requesting a url without a path component (http://example.com) in the Streams HTTP component.
Props barrykooij for inital patch; Fixes #27668

Built from https://develop.svn.wordpress.org/trunk@29853


git-svn-id: http://core.svn.wordpress.org/trunk@29616 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-08 06:44:19 +00:00
Dion Hulse
f09c515ad9 When making a HTTP request to a non-standard port, include the port in the Host header for the Streams HTTP transport. This bring parity to the cURL transport and respects the HTTP RFC.
Props kamelkev for the initial patch; Fixes #28982

Built from https://develop.svn.wordpress.org/trunk@29852


git-svn-id: http://core.svn.wordpress.org/trunk@29615 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-08 06:15:18 +00:00
Dion Hulse
78f4cd2c58 Correctly support Schemeless URLs in WP_HTTP::make_absolute_url() by respecting the 'host' field if present in the relative url.
Fixes #29886

Built from https://develop.svn.wordpress.org/trunk@29851


git-svn-id: http://core.svn.wordpress.org/trunk@29614 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-08 05:58:19 +00:00
Dion Hulse
9962cefbec Correctly handle url's containing url's in WP_HTTP::make_absolute_url().
A valid relative URL could be mistaken for an absolute url if it contained a :// in any position of the url.
Fixes #28001

Built from https://develop.svn.wordpress.org/trunk@29850


git-svn-id: http://core.svn.wordpress.org/trunk@29613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-08 05:38:18 +00:00
Dion Hulse
88b635245a Always cast the 'code' server response to an int, this provides consistency between both of the HTTP transports.
Previously cURL would return an int and Streams a numeric string.
Fixes #28887

Built from https://develop.svn.wordpress.org/trunk@29849


git-svn-id: http://core.svn.wordpress.org/trunk@29612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-08 05:21:19 +00:00
Dion Hulse
88ceaba2d2 Return the correct server response for the 'message' response field from the server.
Previously this would use the generic message corresponding to the response code, which isn't always accurate. Since we're already parsing the headers, we can simply return that directly (This also has the benefit that it's the same code for both Streams and Curl header handling).
Fixes #28919

Built from https://develop.svn.wordpress.org/trunk@29848


git-svn-id: http://core.svn.wordpress.org/trunk@29611 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-08 05:19:20 +00:00
Mark Jaquith
e1f2b3b9e2 Use HTTPS URLs for trac.wordpress.org (and use core.trac.wordpress.org)
see #27115
Built from https://develop.svn.wordpress.org/trunk@29789


git-svn-id: http://core.svn.wordpress.org/trunk@29561 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-29 13:37:16 +00:00
Mark Jaquith
0d3b83551f Use HTTPS URLs for core.trac.wordpress.org
see #27115
Built from https://develop.svn.wordpress.org/trunk@29788


git-svn-id: http://core.svn.wordpress.org/trunk@29560 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-29 13:28:16 +00:00
Sergey Biryukov
3cdc7b1679 Avoid PHP notices when checking for local requests in in WP_Http.
props markoheijnen.
fixes #29392.
Built from https://develop.svn.wordpress.org/trunk@29661


git-svn-id: http://core.svn.wordpress.org/trunk@29435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-02 02:06:17 +00:00
Drew Jaynes
d33c807723 Fix some documentation typos in various core files.
Props vlajos.
Fixes #29199.

Built from https://develop.svn.wordpress.org/trunk@29479


git-svn-id: http://core.svn.wordpress.org/trunk@29257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-13 03:56:17 +00:00
Drew Jaynes
61b8ba8461 Convert documentation for default arguments in WP_Http::request() to a hash notation.
Also update corresponding docs for functions that leverage its arguments.

See #28298.

Built from https://develop.svn.wordpress.org/trunk@29230


git-svn-id: http://core.svn.wordpress.org/trunk@29014 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-18 22:01:15 +00:00
Drew Jaynes
f35e168f39 Fix syntax for single- and multi-line comments in wp-includes/class-http.php.
See #28943 and #28931.

Built from https://develop.svn.wordpress.org/trunk@29229


git-svn-id: http://core.svn.wordpress.org/trunk@29013 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-18 21:47:15 +00:00
John Blackbourn
4b31a9143a Update some inline docs for the WP_Http class. Fixes #28943.
Built from https://develop.svn.wordpress.org/trunk@29223


git-svn-id: http://core.svn.wordpress.org/trunk@29007 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-18 18:15:15 +00:00
Drew Jaynes
cf17bd6e5e Convert default arguments documentation for WP_Http_Cookie::__construct() into a hash notation.
Props coffee2code for the initial patch.
See #28841.

Built from https://develop.svn.wordpress.org/trunk@29107


git-svn-id: http://core.svn.wordpress.org/trunk@28893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-11 22:50:15 +00:00
Sergey Biryukov
4d9286ad21 Avoid a PHP notice and warning on language selection screen.
props meekyhwang.
fixes #28648.
Built from https://develop.svn.wordpress.org/trunk@28865


git-svn-id: http://core.svn.wordpress.org/trunk@28665 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-27 00:25:15 +00:00
Scott Taylor
d6e5fcab4d Add access modifier to methods of HTTP classes. There are no new private or protected methods, so no need for __call().
See #27881, #22234.

Built from https://develop.svn.wordpress.org/trunk@28506


git-svn-id: http://core.svn.wordpress.org/trunk@28332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-19 05:34:15 +00:00
Scott Taylor
5bd852c262 In WP_Http_Curl::request(), $theResponse is unused. There are other curl_exec() calls that do not return as well.
See #27882.

Built from https://develop.svn.wordpress.org/trunk@28317


git-svn-id: http://core.svn.wordpress.org/trunk@28145 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-06 18:26:14 +00:00
Drew Jaynes
7b73dd328e Fix a typo in the PHPDoc description for the WP_Http_Curl->max_body_length property.
Props eightface.
Fixes #27681.

Built from https://develop.svn.wordpress.org/trunk@27952


git-svn-id: http://core.svn.wordpress.org/trunk@27782 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-04-05 05:48:18 +00:00
Andrew Nacin
755018876c Add context to an internal HTTP API hook.
props kovshenin.
fixes #27021.

Built from https://develop.svn.wordpress.org/trunk@27475


git-svn-id: http://core.svn.wordpress.org/trunk@27319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-08 21:54:15 +00:00
Drew Jaynes
cb8951b0b3 Remove all @package and @subpackage PHPDoc tags not at the file- or class-levels in core.
See #27200.

Built from https://develop.svn.wordpress.org/trunk@27262


git-svn-id: http://core.svn.wordpress.org/trunk@27119 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-25 17:14:14 +00:00
Drew Jaynes
9172107539 Inline documentation for hooks in wp-includes/class-http.php.
Props kraftbj for the initial patches. Props kpdesign, DrewAPicture.
Fixes #26049.

Built from https://develop.svn.wordpress.org/trunk@27049


git-svn-id: http://core.svn.wordpress.org/trunk@26923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-28 08:25:11 +00:00
Drew Jaynes
cd8cedc40d First there were two, and now there are three -- in the @since versions that came before and that shall be. And so it will be, says nacin.
Props JustinSainton, SergeyBiryukov, DrewAPicture.
Fixes #26713.

Built from https://develop.svn.wordpress.org/trunk@26868


git-svn-id: http://core.svn.wordpress.org/trunk@26754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-24 18:57:12 +00:00
Andrew Nacin
70fd806759 Revert r25824:25875 from the core.svn.wordpress.org repository.
These commits were accidentally re-synced commits from develop.svn.wordpress.org due to a race condition. Thankfully, the history of this repository matters fairly little. It also happened only for trunk.


git-svn-id: http://core.svn.wordpress.org/trunk@25876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-25 02:29:52 +00:00
Andrew Nacin
8ae8e01b67 Remove the old wp_auto_updates_maybe_update cron event. Schedule the new wp_maybe_auto_update event at 7 a.m. and 7 p.m. in the site's timezone.
see #27704.

Built from https://develop.svn.wordpress.org/trunk@25825


git-svn-id: http://core.svn.wordpress.org/trunk@25825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-24 22:53:14 +00:00
Ryan Boren
b87d4b77e5 Pinking shears
Built from https://develop.svn.wordpress.org/trunk@25880


git-svn-id: http://core.svn.wordpress.org/trunk@25792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-23 14:38:10 +00:00
Andrew Nacin
d35284e08a Use sentence case.
Built from https://develop.svn.wordpress.org/trunk@25654


git-svn-id: http://core.svn.wordpress.org/trunk@25571 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-02 17:40:10 +00:00
Dion Hulse
ef9b9664e1 WP_HTTP: Fix a typo in the naming of WP_HTTP_Streams::verify_ssl_certificate(). Props SergeyBiryukov See #25007
Built from https://develop.svn.wordpress.org/trunk@25473


git-svn-id: http://core.svn.wordpress.org/trunk@25394 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-18 01:51:10 +00:00
Dion Hulse
c93eb27bb2 Switch WP_HTTP over to using the mbstring.func_overload helper functions. This change moves the check from within the Streaming-handling function to wrap the individual request, this fixes it for both cURL and Streams and any future changes to the transports which use strlen() on binary data. See #25259 See #16057
Built from https://develop.svn.wordpress.org/trunk@25348


git-svn-id: http://core.svn.wordpress.org/trunk@25310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-11 08:13:10 +00:00
Dion Hulse
3514c7d1c4 WP_HTTP: Correct the @since, and, @deprecated PHPDoc tags to reflect the class history. See #25007
Built from https://develop.svn.wordpress.org/trunk@25309


git-svn-id: http://core.svn.wordpress.org/trunk@25271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-09 08:10:10 +00:00
Dion Hulse
f66f154ced WP_HTTP: When streaming to file, ensure that fwrite() suceeds and correctly writes the file to disk. Fixes #16057
Built from https://develop.svn.wordpress.org/trunk@25303


git-svn-id: http://core.svn.wordpress.org/trunk@25265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-09 01:18:08 +00:00
Dion Hulse
19054801bf WP_HTTP: Re-enable curl, it was accidentally left out of [25224]. See #25007 See #16606
Built from https://develop.svn.wordpress.org/trunk@25225


git-svn-id: http://core.svn.wordpress.org/trunk@25195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-04 04:50:08 +00:00
Dion Hulse
3ac572867e WP_HTTP: Replacing the Fsockopen & Streams Transports with a new Streams transport which fully supports HTTPS communication.
This changeset also bundles ca-bundle.crt from the Mozilla project to allow for us to verify SSL certificates on hosts which have an incomplete, outdated, or invalid local SSL configuration.
Props rmccue for major assistance getting this this far. See #25007 for discussion, also Fixes #16606 

Built from https://develop.svn.wordpress.org/trunk@25224


git-svn-id: http://core.svn.wordpress.org/trunk@25194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-04 04:49:12 +00:00
Dion Hulse
bb74078a2b WP_HTTP: Add a filter for the available HTTP Transports to allow plugins to alter the order which HTTP Transports are tried, or to add their own.
Built from https://develop.svn.wordpress.org/trunk@25222


git-svn-id: http://core.svn.wordpress.org/trunk@25193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-03 08:39:09 +00:00
Dion Hulse
98104779a3 WP_HTTP: Clean up some comments style and remove outdated information.
The change to the proxy block here is for consistency, WP_HTTP_Proxy::block_request() is never called before parse_url() has successfully operated on the URL, and in the event we cannot read the URL, it shouldn't be requested.

Built from https://develop.svn.wordpress.org/trunk@25221


git-svn-id: http://core.svn.wordpress.org/trunk@25192 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-03 08:37:10 +00:00
Dion Hulse
994033258e WP_HTTP: Make the new 2nd parameter to WP_HTP::processHeaders() as optional. See #21182. Fixes #25179
Built from https://develop.svn.wordpress.org/trunk@25176


git-svn-id: http://core.svn.wordpress.org/trunk@25149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-30 02:11:09 +00:00
Dion Hulse
f17254a835 WP_HTTP: Fix a variable typo in [25153] See #23463
Built from https://develop.svn.wordpress.org/trunk@25155


git-svn-id: http://core.svn.wordpress.org/trunk@25134 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-28 07:30:08 +00:00
Dion Hulse
5a9ccf9bee WP_HTTP: Update the documentation regarding HTTP/1.1 support. Props leewillis77 Fixes #25074
Built from https://develop.svn.wordpress.org/trunk@25154


git-svn-id: http://core.svn.wordpress.org/trunk@25133 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-28 06:55:09 +00:00
Dion Hulse
122c3953d1 WP_HTTP: Improve WP_HTTP::chunkTransferDecode() to properly handle binary data and chunked responses which include data in the page that looks like a chunked response.
This also fixes a case where the gzip'd data would become corrupt after chunked decoding as \r\n was replaced with \n in the data stream. Fixes #23463 

Built from https://develop.svn.wordpress.org/trunk@25153


git-svn-id: http://core.svn.wordpress.org/trunk@25132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-28 06:53:09 +00:00
Dion Hulse
1aecc6c957 WP_HTTP: When requesting a document with HTTP/1.1 include the 'Connection: Close' header (unless a Connection header is already specified) to prevent the connection being held open and hanging the request process. See #23463
Built from https://develop.svn.wordpress.org/trunk@25150


git-svn-id: http://core.svn.wordpress.org/trunk@25129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-28 04:59:09 +00:00
Dion Hulse
f8e3be14fe WP_HTTP: More relaxed host matching for WP_PROXY_BYPASS_HOSTS and WP_ACCESSIBLE_HOSTS, allowing for subdomains in wildcards to include dashes (and anything else which [\w.] didn't catch). Fixes #24201
Built from https://develop.svn.wordpress.org/trunk@25149


git-svn-id: http://core.svn.wordpress.org/trunk@25128 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-28 04:54:09 +00:00
Sergey Biryukov
db2a73a3f7 Avoid a fatal error in WP_Http::request() if $response is a WP_Error instance. props dllh, nacin. fixes #24987.
Built from https://develop.svn.wordpress.org/trunk@25114


git-svn-id: http://core.svn.wordpress.org/trunk@25095 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-24 03:11:10 +00:00
Dion Hulse
e91dcf8fac WP_HTTP: Curl: When using Stream-to-file on servers using mbstring.func_overload ensure that the file is written out correctly. Props DrProtocols. See #25061 for trunk
Built from https://develop.svn.wordpress.org/trunk@25051


git-svn-id: http://core.svn.wordpress.org/trunk@25038 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-18 08:18:10 +00:00
Dion Hulse
ef3b20c949 WP_HTTP: Cookies: When following redirects, include the request cookies in the redirected requests. Fixes #24987
Built from https://develop.svn.wordpress.org/trunk@25046


git-svn-id: http://core.svn.wordpress.org/trunk@25033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-17 01:20:09 +00:00
Dion Hulse
cd0642bdc7 WP_HTTP: Cookies: Fill the defaults for the Cookie object based on the current requested URL. Fixes #21182
Built from https://develop.svn.wordpress.org/trunk@25044


git-svn-id: http://core.svn.wordpress.org/trunk@25031 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-17 00:34:10 +00:00
Dion Hulse
da016d59b4 WP_HTTP: Allow name => value pairs to be passed in to the 'cookie' parameter, simplifies plugin code when needing to specify basic cookies. Fixes #21999
Built from https://develop.svn.wordpress.org/trunk@25016


git-svn-id: http://core.svn.wordpress.org/trunk@25008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-08 02:44:09 +00:00
Andrew Nacin
8c7adaa7bd Introduce wp_safe_remote_request(). Also wp_safe_remote_head(), wp_safe_remote_get(), wp_safe_remote_post().
Reverts [24482].

see #24646.



git-svn-id: http://core.svn.wordpress.org/trunk@24894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-30 15:37:01 +00:00
Dion Hulse
94b2ed9164 WP_HTTP: PHPDoc updates for WP_Http::handle_redirects(). Props DrewAPicture. Fixes #16889
git-svn-id: http://core.svn.wordpress.org/trunk@24890 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-30 06:47:03 +00:00
Dion Hulse
ac424c08ca WP_HTTP: When multiple location headers are specified, use the last specified location url as the redirect location. Fixes #16890
git-svn-id: http://core.svn.wordpress.org/trunk@24846 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-29 02:11:46 +00:00