trii/http-headers

This package is abandoned and no longer maintained. No replacement package was suggested.

WTHeaders is a qvalue? Don't worry, we got that for you!

Installs: 111

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 1

Language:HTML

dev-master 2015-05-13 14:34 UTC

This package is not auto-updated.

Last update: 2022-02-01 12:47:04 UTC


README

Build Status

Accept: text/feedback, application/pull-requests

SHOULD be interpreted as "This is a work in progress. Early feedback and pull requests are accepted"

HTTP is hard and you're probably dealing with headers the wrong way. Do you know what Accept-Encoding: identity means? What about a qvalue? How about this nonsense:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,application/json

We didn't think so but guess what? You don't have to! That is right, http-headers can parse this for you and just let you know if the requestor accepts what you want to give them and even ask which one they prefer.

Check out how easy this is!

use Trii\HTTPHeaders;

$accept = new HTTPHeaders\Accept('audio/*; q=0.2, audio/basic');

var_dump($accept->isAccepted('audio/mpeg'));
// bool(true)

var_dump($accept->getPreferredType());
// string(11) "audio/basic"

Awesome right?!?