Requests for PHP: Version 1.6

It’s been a while since I released Requests 1.5 two years ago (!), and I’m
trying to get back on top of managing all my projects. The code in Requests has
been sitting there working perfectly for a long time, so it’s about time to
release to a new version.

Announcing Requests 1.6! This release brings a chunk of changes,

  • Multiple request support – Send multiple HTTP requests with both
    fsockopen and cURL, transparently falling back to synchronous when
    not supported. Simply call Requests::request_multiple(), and servers with
    cURL installed will automatically upgrade to parallel requests.

  • Proxy support – HTTP proxies are now natively supported via a
    high-level API. Major props to Ozh for his fantastic work
    on this.

  • Verify host name for SSL requests – Requests is now the first and
    only PHP standalone HTTP library to fully verify SSL hostnames even with
    socket connections. This includes both SNI support and common name checking.

  • Cookie and session support – Adds built-in support for cookies
    (built entirely as a high-level API). To compliment cookies,
    sessions can be created with a base URL and default
    options, plus a shared cookie jar.

  • Opt-in exceptions on errors: You can now call $response->throw_for_status()
    and a Requests_Exception_HTTP exception will be thrown for non-2xx
    status codes.

  • PUT, DELETE, and PATCH requests are now all fully supported
    and fully tested.

  • Add Composer support – You can now install Requests via the
    rmccue/requests package on Composer

So, how do you upgrade? If you’re using Composer, you can bump your minimum
version to 1.6 and then update. (Note that you should remove minimum-stability
if you previously set it for Requests.) Otherwise, you can drop the new version
in over the top and it will work out of the box. (Version 1.6 is completely
backwards compatible with 1.5.)

What about installing for the first time? Just add this to your composer.json:

    "require": {
        "rmccue/requests": ">=1.6"

Alternatively, you can now install via PEAR:

$ pear channel-discover
$ pear install rmccue/Requests

Alternatively, head along to the
release page and
download a zip or tarball directly.

Along with 1.6, I’ve also created a
fancy new site, now powered by Jekyll. This
is hopefully a nicer place to read the documentation than on GitHub itself, and
should be especially handy to new users.

This release includes a lot of new changes, as is expected for such a long
release cycle (although hopefully a little shorter next time). One of the big
ones here is the significantly improved SSL support, which should guarantee
completely secure connections on all platforms. This involved a lot of learning
about how the internals of SSL certificates work, along with working with
OpenSSL. Getting them working in a compatible manner was also not particularly
easy; I spent about an hour tracking back through PHP’s source code to ensure
that stream_socket_client had the same level of availability as fsockopen
(it does) all the way back to PHP 5.2.0 (it did).

In all, 19 fantastic third-party contributors helped out with this release, and
I’d like to acknowledge those people here:

Feedback on this release would be much appreciated, as always. I look forward
to hearing from you and working with you to improve Requests even further!

Leave a Reply