File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 */
1616final class MultipartParser
1717{
18- /**
19- * @var string
20- */
21- protected $ buffer = '' ;
22-
23- /**
24- * @var string
25- */
26- protected $ boundary ;
27-
2818 /**
2919 * @var ServerRequestInterface
3020 */
3121 protected $ request ;
3222
33- /**
34- * @var HttpBodyStream
35- */
36- protected $ body ;
37-
38- /**
39- * @var callable
40- */
41- protected $ onDataCallable ;
42-
4323 /**
4424 * @var int|null
4525 */
@@ -58,23 +38,21 @@ private function __construct(ServerRequestInterface $request)
5838
5939 private function parse ()
6040 {
61- $ this ->buffer = (string )$ this ->request ->getBody ();
62-
6341 $ contentType = $ this ->request ->getHeaderLine ('content-type ' );
6442 if (!preg_match ('/boundary="?(.*)"?$/ ' , $ contentType , $ matches )) {
6543 return $ this ->request ;
6644 }
6745
68- $ this ->boundary = $ matches [1 ];
69- $ this ->parseBuffer ();
46+ $ this ->parseBuffer ($ matches [1 ], (string )$ this ->request ->getBody ());
7047
7148 return $ this ->request ;
7249 }
7350
74- private function parseBuffer ()
51+ private function parseBuffer ($ boundary , $ buffer )
7552 {
76- $ chunks = explode ('-- ' . $ this ->boundary , $ this ->buffer );
77- $ this ->buffer = array_pop ($ chunks );
53+ $ chunks = explode ('-- ' . $ boundary , $ buffer );
54+ array_pop ($ chunks );
55+
7856 foreach ($ chunks as $ chunk ) {
7957 $ chunk = $ this ->stripTrailingEOL ($ chunk );
8058 $ this ->parseChunk ($ chunk );
You can’t perform that action at this time.
0 commit comments