@@ -31,7 +31,7 @@ use Narrowspark\Http\Message\Util\InteractsWithAcceptLanguage;
31
31
$request = new Request();
32
32
$request = $request->withHeader('Accept-Language', 'zh, en-us; q=0.8, en; q=0.6');
33
33
34
- return InteractsWithAcceptLanguage::getLanguages($request); // ['zh', 'en', 'en_US']
34
+ return InteractsWithAcceptLanguage::getLanguages($request); // => ['zh', 'en', 'en_US']
35
35
36
36
```
37
37
@@ -46,7 +46,7 @@ use Narrowspark\Http\Message\Util\InteractsWithAuthorization;
46
46
$request = new Request();
47
47
$request = $request->withHeader('Authorization', 'Basic QWxhZGRpbjpPcGVuU2VzYW1l');
48
48
49
- return InteractsWithAuthorization::getAuthorization($request); // ['Basic', 'QWxhZGRpbjpPcGVuU2VzYW1l']
49
+ return InteractsWithAuthorization::getAuthorization($request); // => ['Basic', 'QWxhZGRpbjpPcGVuU2VzYW1l']
50
50
51
51
```
52
52
@@ -61,18 +61,58 @@ use Narrowspark\Http\Message\Util\InteractsWithContentTypes;
61
61
$request = new Request();
62
62
$request = $request->withHeader('Content-Type', 'application/json, */*');
63
63
64
- return InteractsWithContentTypes::isJson($request); // true
64
+ return InteractsWithContentTypes::isJson($request); // => true
65
65
66
66
$request = $request->withHeader('X-Pjax', 'true');
67
67
68
- return InteractsWithContentTypes::isPjax($request); // true
68
+ return InteractsWithContentTypes::isPjax($request); // => true
69
69
70
70
$request = $request->withHeader('X-Requested-With', 'XMLHttpRequest');
71
71
72
- return InteractsWithContentTypes::isAjax($request); // true
72
+ return InteractsWithContentTypes::isAjax($request); // => true
73
73
74
74
```
75
75
76
+ Here's an example using the HeaderUtils class:
77
+ ``` php
78
+ <?php
79
+ declare(strict_types=1);
80
+
81
+ use Narrowspark\Http\Message\Util\HeaderUtils;
82
+
83
+ return HeaderUtils::split("da, en-gb;q=0.8", ",;"); // => array(array('da'), array('en-gb', 'q=0.8'))
84
+
85
+ or
86
+
87
+ return HeaderUtils::combine(array(array("foo", "abc"), array("bar"))); // => array("foo" => "abc", "bar" => true)
88
+
89
+ or
90
+
91
+ return HeaderUtils::toString(array("foo" => "abc", "bar" => true, "baz" => "a b c"), ","); // => 'foo=abc, bar, baz="a b c"'
92
+
93
+ or
94
+
95
+ return HeaderUtils::quote('foo bar'); // => "foo bar"
96
+
97
+ or
98
+
99
+ return HeaderUtils::unquote('"foo bar"'); // => foo bar
100
+ ```
101
+
102
+ Here's an example using the InteractsWithDisposition class:
103
+ ``` php
104
+ <?php
105
+ declare(strict_types=1);
106
+
107
+ use Narrowspark\Http\Message\Util\InteractsWithDisposition;
108
+
109
+ $response = new Response();
110
+
111
+ $response = InteractsWithDisposition::makeDisposition($response, InteractsWithDisposition::DISPOSITION_ATTACHMENT, 'foo.html');
112
+
113
+ return $response->getHeaderLine('Content-Disposition'); // => attachment; filename=foo.html
114
+ ```
115
+
76
116
Testing
77
117
------------
78
118
0 commit comments