asispts / http-accept Goto Github PK
View Code? Open in Web Editor NEWPHP Parser to deal with HTTP Accept, Accept-Language, Accept-Encoding, and Content-Type headers
License: Apache License 2.0
PHP Parser to deal with HTTP Accept, Accept-Language, Accept-Encoding, and Content-Type headers
License: Apache License 2.0
I need to parse the Content-Type header with parameters. Using the Accept parser works fine, but it feels a bit wrong, since Content-Type has only a subset of the semantics (can only have one, and no q
parameter or scoring).
I wonder if you'd be open to a slight refactor to extract the basic parsing functionality into a separate class perhaps, and build the more specialised Accept parsing on top of that?
Currently you have to do:
$count = $mediaList->count();
$mediaTypes = [];
for ($i = 0; $i < $count; $i++) {
$mediaTypes[] = $mediaList->preferredMedia($i);
}
It'd be nice to be able to do:
$mediaTypes = $mediaList->all();
Currently parameters are not parsed into key/value pairs, they're just stored as an array of strings:
$mediaList = (new AcceptParser())->parse('*/*; one=value; two=value');
print_r($mediaList->preferedMedia(0)->parameters());
Array
(
[0] => one=value,
[1] => two=value
)
Is there any reason they're not parsed into key/value pairs, ie:
Array
(
[one] => value,
[two] => value
)
Package pattisahusiwa/coding-standard is abandoned, you should avoid using it. Use asispts/ptscs instead.
Package pattisahusiwa/coding-standard
has been replaced by asispts/ptscs
. However, asispts/ptscs
requires PHP version 7.2 or higher.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.