pagemill / accept
解析 HTTP Accept 头并确定首选的内容类型
v2.0.1
2022-02-10 19:46 UTC
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-09-11 01:47:26 UTC
README
解析 Accept 头并根据 RFC 2616 确定客户端首选的内容类型。
// content types with which the web service can respond $valid_content_types = [ "application/json", "text/xml" ]; $accept = new \PageMill\Accept\Accept(); $content_type = $accept->determine($valid_content_types); // If Accept did not find an acceptable content type, the determine method // will return null. The server should respond to the client with a 406. if ($content_type === null) { // Respond with 406 Not Acceptable http_response_code(406); exit(); }