Skip to content

httpfulvshttp-2

MIT 89 4 1,738
4.7 thousand (month) Apr 14 2012 1.0.0(2 months ago)
887 6 - MIT
Sep 25 2013 131.6 thousand (month) 1.0.0(17 days ago)

Httpful is a simple Http Client library for PHP 7.2+. There is an emphasis of readability, simplicity, and flexibility – basically provide the features and flexibility to get the job done and make those features really easy to use.

Features

  • Readable HTTP Method Support (GET, PUT, POST, DELETE, HEAD, PATCH and OPTIONS)
  • Custom Headers
  • Automatic "Smart" Parsing
  • Automatic Payload Serialization
  • Basic Auth
  • Client Side Certificate Auth
  • Request "Templates"

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


http2

Example Use


require 'vendor/autoload.php';

use Httpful\Request;

// make GET request
$response = \Httpful\Request::get("http://httpbin.org/get")
    ->send();
echo $response->body;

// make POST request
$data = array('name' => 'Bob', 'age' => 35);
$response = \Httpful\Request::post("http://httpbin.org/post")
    ->sendsJson()
    ->body(json_encode($data))
    ->send();
echo $response->body;

// add headers or cookies
$response = \Httpful\Request::get("http://httpbin.org/headers")
    ->addHeader("API-KEY", "mykey")
    ->addHeader("Cookie", "foo=bar")
    ->send();
echo $response->body;
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?