Skip to content

buzzvshttp-2

MIT 11 2 1,919
5.6 thousand (month) Nov 11 2011 1.2.1(2 years ago)
887 6 - MIT
Sep 25 2013 131.6 thousand (month) 1.0.0(17 days ago)

Buzz is a lightweight PHP library for issuing HTTP requests. It is built on top of the PHP curl extension and is designed to be easy to use and flexible.

While buzz isn't as feature rich as other clients it still supports http2 and is relatively easy to use.

Pure Ruby, framework and transport agnostic, implementation of HTTP/2 protocol and HPACK header compression with support for:

  • Binary framing parsing and encoding
  • Stream multiplexing and prioritization
  • Connection and stream flow control
  • Header compression and server push
  • Connection and stream management
  • And more... see API docs

Protocol specifications:

  • Hypertext Transfer Protocol Version 2 (RFC 7540)
  • HPACK: Header Compression for HTTP/2 (RFC 7541)

Highlights


http2uses-curl
http2

Example Use


use Buzz\Client\Curl;
use Buzz\Message\Request;
use Buzz\Message\Response;

$client = new Curl();
// GET request
$request = new Request('GET', 'http://httpbin.org/get');
$response = new Response();
$client->send($request, $response);
echo $response->getContent();

//POST request
$request = new Request('POST', '/api/resource', 'http://example.com');
$request->setContent(json_encode(['name' => 'John Doe']));
// we can also add headers or cookies:
$request->addHeader('Content-Type: application/json');
$request->addHeader('Cookie: name=foobar');
$response = new Response();
$client->send($request, $response);
echo $response->getContent();

// Buzz also supports http2 (see the 2.0 parameter)
$response = $client->sendRequest(
  new Request('GET', 'https://http2.golang.org/serverpush', [], null, '2.0')
);
require 'http/2'

# GET request
client = HTTP2::Client.new
response = client.get("https://httpbin.org/get")
puts response.body

# POST reuqest
data = { name: "value" }
response = client.post("https://www.example.com", data)

Alternatives / Similar


Was this page helpful?