Hypertext Transfer Protocol (HTTP) utilities for PHP

v2.0.0 2016-07-21 15:05 UTC

This package is not auto-updated.

Last update: 2020-08-02 17:44:01 UTC


README

Hypertext Transfer Protocol (HTTP) utilities for PHP

Requirements

  • PHP 5.3.0+

Installation

  1. Include the library via Composer [?]:

    $ composer require delight-im/http
    
  2. Include the Composer autoloader:

    require __DIR__ . '/vendor/autoload.php';

Usage

Response headers

  • Retrieving a header (with optional value prefix)

    \Delight\Http\ResponseHeader::get('Content-type')
    // or
    \Delight\Http\ResponseHeader::get('Content-type', 'text/')
  • Setting a header (overwriting other headers with the same name)

    \Delight\Http\ResponseHeader::set('X-Frame-Options', 'SAMEORIGIN')
  • Adding a header (preserving other headers with the same name)

    \Delight\Http\ResponseHeader::add('X-Frame-Options', 'SAMEORIGIN')
  • Removing a header (with optional value prefix)

    \Delight\Http\ResponseHeader::get('X-Powered-By')
    // or
    \Delight\Http\ResponseHeader::get('X-Powered-By', 'PHP')
  • Retrieving and removing a header at once (with optional value prefix)

    \Delight\Http\ResponseHeader::take('Set-Cookie')
    // or
    \Delight\Http\ResponseHeader::take('Set-Cookie', 'mysession=')

Contributing

All contributions are welcome! If you wish to contribute, please create an issue first so that your feature, problem or question can be discussed.

License

This project is licensed under the terms of the MIT License.