1 | <?php |
||
15 | abstract class AbstractHttpParser implements HttpParserInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $httpRaw; |
||
21 | |||
22 | /** |
||
23 | * @var HttpHeaderInterface |
||
24 | */ |
||
25 | protected $httpHeader; |
||
26 | |||
27 | /** |
||
28 | * @var HttpFieldCollection |
||
29 | */ |
||
30 | protected $httpFieldCollection; |
||
31 | |||
32 | /** |
||
33 | * HttpParser constructor. |
||
34 | * @param HttpFieldCollection $httpFieldCollection |
||
35 | */ |
||
36 | public function __construct(HttpFieldCollection $httpFieldCollection = null) |
||
40 | |||
41 | /** |
||
42 | * @param string $rawHttp |
||
43 | */ |
||
44 | public function parse(string $rawHttp) |
||
48 | |||
49 | /** |
||
50 | * @param string $headerFieldName |
||
51 | * @return string |
||
52 | * @throws HttpFieldNotFoundOnCollection |
||
53 | */ |
||
54 | public function get(string $headerFieldName): string |
||
59 | |||
60 | /** |
||
61 | * @return HttpHeaderInterface |
||
62 | */ |
||
63 | public function getHeader(): HttpHeaderInterface |
||
67 | |||
68 | /** |
||
69 | * @param string $rawHttp |
||
70 | */ |
||
71 | protected function process(string $rawHttp) |
||
76 | |||
77 | /** |
||
78 | * Split the http string |
||
79 | * @throws HttpParserBadFormatException |
||
80 | */ |
||
81 | protected function extract() |
||
95 | |||
96 | /** |
||
97 | * @param string $headerLine |
||
98 | * @throws HttpParserBadFormatException |
||
99 | */ |
||
100 | protected function addHeader(string $headerLine) |
||
107 | |||
108 | /** |
||
109 | * @param string $headerLine |
||
110 | */ |
||
111 | protected function addField(string $headerLine) |
||
116 | |||
117 | /** |
||
118 | * @param string $method |
||
119 | * @param string $path |
||
120 | * @param string $protocol |
||
121 | */ |
||
122 | abstract protected function setHttpHeader(string $method, string $path, string $protocol); |
||
123 | |||
124 | /** |
||
125 | * @param string $line |
||
126 | * @return array |
||
127 | */ |
||
128 | protected function splitRawLine(string $line): array |
||
138 | |||
139 | /** |
||
140 | * @param string $httpRaw |
||
141 | * @return HttpParserInterface |
||
142 | */ |
||
143 | protected function setHttpRaw(string $httpRaw): HttpParserInterface |
||
148 | } |