kigkonsult/http-message

Psr http-message server-side message, response and stream implementation

v1.1 2021-06-15 19:49 UTC

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
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

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