Pacific Northwest Drupal Summit 2012

All the drops gather here.
Seattle, October 20-21, 2012

Issuing HTTP Requests in Drupal 8

Speaker(s): 
Track: 
Development and Code
Experience Level: 
Intermediate
Advanced

This session will go over how to Issue HTTP requests in Drupal 8 with the assumption that this issue gets accepted in core: Adopt Guzzle library to replace drupal_http_request(). Even if this doesn't get accepted in core, using a library like Guzzle in comparison to writing your own cURL implementation is a good idea.

Guzzle is a PHP HTTP client & framework for building RESTful web service clients and it's built following PSR-0. In comparison to drupal_http_request() Guzzle offers a lot of advantages because it allows you to truly reap the benefits of the HTTP/1.1 spec, making persistent connection management and sending requests in parallel easier. Guzzle also has some nice additions to it as well, such as:
Non Blocking Requests: Open connection; write to it; do not wait to read, instead close connection. This is very useful for things like fixing performance issues with poor mans cron, building css/js aggregates in the background, building image cache presets in the background and doing general batch jobs in the background. https://github.com/guzzle/guzzle/blob/master/src/Guzzle/Http/Plugin/Asyn...
Callbacks: Run custom code once that connection is done. If issuing parallel http requests, processing the returned data while other streams are being downloaded will improve the scripts performance. http://guzzlephp.org/guide/http/creating_plugins.html
Testing: Guzzle provides several tools that will enable you to easily unit test your web service clients. See http://guzzlephp.org/guide/service/testing_clients.html

See http://guzzlephp.org/guide/plugins.html for more awesomeness