kigkonsult / http-message
Psr http-message server-side message, response and stream implementation
Fund package maintenance!
Other
Requires
- php: >=7.0
- fig/http-message-util: ^1.1.2
- psr/http-message: ^1.0.1
Requires (Dev)
- phpstan/phpstan: >=0.9.3
- phpunit/phpunit: ^6.5.11
This package is auto-updated.
Last update: 2024-11-16 03:47:23 UTC
README
The Kigkonsult\Http\Message package provide PSR server-side
Message class
Stream class
Response class
Message class
- implements Psr\Http\Message\MessageInterface
- constructor args: body, headers, protocolVersion
Stream class
- implements Psr\Http\Message\StreamInterface
- constructor args: content, streamWrapper/resource, mode
- with a (static) factory methods
factoryFromString( content [, streamWrapper [, mode ]] )
factoryFromResource( resource )
Response class
- extends Message
- implements
- constructor args: body, status, headers
The Response class has an added property:
rawBody
- response body (type mixed) before serialization/encoding
in parallel with
(Psr\Http\Message\)ServerRequest::parsedBody
(Psr\Http\Message\)ServerRequest::body
with corresponding methods:
getRawBody()
- Return rawBody
isRawBodyEmpty()
- Return bool true on empty rawBody
withRawBody()
- Return new instance with rawBody
and two rawBody/body methods
getResponseBody()
- Return rawBody if not empty else body
isBodyEmpty()
- Return bool true if (serialized/encoded) body is empty
Two statusCode methods are added:
assertStatusCode()
- (static) validates statusCode, throws InvalidArgumentException on error
isBodyLessResponse()
- Return bool true on statusCode 1xx, 204 or 304
Installation
Composer, from the Command Line:
composer require kigkonsult/http-master:dev-master
Composer, in your composer.json
:
{ "require": { "kigkonsult/http-master": "dev-master" } }
Composer, acquire access
<?php use Kigkonsult\Http\Message\Stream; use Kigkonsult\Http\Message\Message; use Kigkonsult\Http\Message\Response; ... include 'vendor/autoload.php';
Otherwise , download and acquire..
<?php use Kigkonsult\Http\Message\Stream; use Kigkonsult\Http\Message\Message; use Kigkonsult\Http\Message\Response; ... include 'pathToSource/http-master/autoload.php';
Support
For support use github.com http-master. Non-emergence support issues are, unless sponsored, fixed in due time.
Sponsorship
Donation using paypal.me/kigkonsult are appreciated. For invoice, please e-mail.
License
This project is licensed under the LGPLv3 License