public function testParseMultiple() { $content = '--------------------------eb2d2b296b73a011' . "\r\n" . 'Content-Disposition: form-data; name="foo"' . "\r\n\r\n" . 'bar' . "\r\n" . '--------------------------eb2d2b296b73a011' . "\r\n" . 'Content-Disposition: form-data; name="alice"' . "\r\n\r\n" . 'bob' . "\r\n" . '--------------------------eb2d2b296b73a011--' . "\r\n"; $this->parser->setBoundary('------------------------eb2d2b296b73a011'); $result = $this->parser->parse($content); $this->assertEquals([['headers' => ['content-disposition' => ['form-data; name="foo"'], 'content-type' => ['text/plain']], 'body' => 'bar'], ['headers' => ['content-disposition' => ['form-data; name="alice"'], 'content-type' => ['text/plain']], 'body' => 'bob']], $result); }
/** * Give me your Content-Type, and i give you a parser. * * @param $contentType * @return MultipartParser|null */ public function getParserForContentType($contentType) { if (0 !== stripos($contentType, 'multipart/')) { return null; } list($mime, $boundary) = $this->parseContentType($contentType); $parser = new MultipartParser(); $parser->setBoundary($boundary); return $parser; }