Browse Source

Client prototype

master
J. King 4 years ago
parent
commit
1dfba28a66
  1. 4
      composer.json
  2. 103
      composer.lock
  3. 31
      lib/HttpClient.php

4
composer.json

@ -19,7 +19,9 @@
"ext-intl": "*",
"ralouphie/mimey": "^2.1",
"psr/http-message": "^1.0",
"mensbeam/mimesniff": "^0.2.0"
"mensbeam/mimesniff": "^0.2.0",
"psr/http-factory": "^1.0",
"psr/http-client": "^1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.3"

103
composer.lock

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "07fe7f69bf2ed4719a7cf36df9df3644",
"content-hash": "2d0bef53f4eaeeba37004efdea63426e",
"packages": [
{
"name": "mensbeam/mimesniff",
@ -52,6 +52,107 @@
],
"time": "2020-04-19T16:07:41+00:00"
},
{
"name": "psr/http-client",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-client.git",
"reference": "496a823ef742b632934724bf769560c2a5c7c44e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/496a823ef742b632934724bf769560c2a5c7c44e",
"reference": "496a823ef742b632934724bf769560c2a5c7c44e",
"shasum": ""
},
"require": {
"php": "^7.0",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP clients",
"homepage": "https://github.com/php-fig/http-client",
"keywords": [
"http",
"http-client",
"psr",
"psr-18"
],
"time": "2018-10-30T23:29:13+00:00"
},
{
"name": "psr/http-factory",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
"shasum": ""
},
"require": {
"php": ">=7.0.0",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"time": "2019-04-30T12:38:16+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",

31
lib/HttpClient.php

@ -0,0 +1,31 @@
<?php
/** @license MIT
* Copyright 2018 J. King et al.
* See LICENSE and AUTHORS files for details */
declare(strict_types=1);
namespace MensBeam\Lax;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\RequestFactoryInterface;
use Psr\Http\Client\ClientInterface;
class HttpClient implements RequestFactoryInterface, ClientInterface {
public const ACCEPT_FEED = "application/atom+xml, application/rss+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, */*;q=0.1";
/** @var string $userAgent The User-Agent to identify as */
public $userAgent = "";
/** @var int $maxRedirects The number of redirects after which Lax should give up */
public $maxRedirects = 10;
/** @var \Psr\Http\Message\RequestFactoryInterface */
protected $requestFactory = null;
/** @var \Psr\Http\Client\ClientInterface */
protected $client = null;
public function __construct(ClientInterface $clientImplementation, RequestFactoryInterface $requestFactory) {
$this->client = $clientImplementation;
$this->requestFactory = $requestFactory;
}
}
Loading…
Cancel
Save