Skip to content

symfony-httpvshttp-2

MIT - 8 1,898
186.5 thousand (month) Apr 28 2019 v7.1.2(17 days ago)
887 6 - MIT
Sep 25 2013 131.6 thousand (month) 1.0.0(17 days ago)

Symfony-http is a PHP library that provides a set of classes for working with HTTP requests and responses. It is part of the Symfony CMS framework, but can also be used independently.

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


<?php
use Symfony\Component\HttpClient\HttpClient;

// create a client object: 
$client = HttpClient::create();
// sent GET request
$response = $client->request('GET', 'https://httpbin.org/get');


// or POST request
$response = $client->request('POST', 'https://httpbin.org/post', [
    'headers' => [
        'Content-Type' => 'application/json',
    ],
    'json' => [
        'name' => 'John Doe',
        'email' => 'john.doe@example.com',
    ],
]);

// print response data:
$statusCode = $response->getStatusCode();
$content = $response->getContent();
echo "Status Code: $statusCode\n";
echo "Content: $content\n";
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?