fyre/message

A HTTP message library.

v3.0.3 2024-06-25 05:46 UTC

This package is auto-updated.

Last update: 2024-06-25 05:46:36 UTC


README

FyreMessage

FyreMessage is a free, open-souce immutable HTTP message library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/message

In PHP:

use Fyre\Http\Message;

Message Creation

  • $options is an array containing the message options.
    • body is a string representing the message body, and will default to "".
    • headers is an array containing headers to set, and will default to [].
    • protocolVersion is a string representing the protocol version, and will default to "1.1".
$message = new Message($options);

Methods

Append Body

Append data to the message body.

  • $data is a string representing the data to append.
$newMessage = $message->appendBody($data);

Append Header

Append a value to a message Header.

  • $name is a string representing the Header name.
  • $value is a string representing the Header value.
$newMessage = $message->appendHeader($name, $value);

Get Body

Get the message body.

$body = $message->getBody();

Get Header

Get a message Header.

  • $name is a string representing the Header name.
$header = $message->getHeader($name);

Get Headers

Get the message headers.

$headers = $message->getHeaders();

Get Header Value

Get a message Header value.

  • $name is a string representing the Header name.
$value = $message->getHeaderValue($name);

Get Protocol Version

Get the protocol version.

$version = $message->getProtocolVersion();

Has Header

Determine if the message has a Header.

  • $name is a string representing the Header name.
$hasHeader = $message->hasHeader($name);

Prepend Header

Prepend a value to a message Header.

  • $name is a string representing the Header name.
  • $value is a string representing the Header value.
$newMessage = $message->prependHeader($name, $value);

Remove Header

Remove a Header.

  • $name is a string representing the Header name.
$newMessage = $message->removeHeader($name);

Set Body

Set the message body.

  • $data is a string representing the message body.
$newMessage = $message->setBody($data);

Set Header

Set a message Header.

  • $name is a string representing the Header name.
  • $value is a string representing the Header value.
$newMessage = $message->setHeader($name, $value);

Set Protocol Version

Set the protocol version.

  • $version is a string representing the protocol version.
$newMessage = $message->setProtocolVersion($version);