Skip to content

Commit

Permalink
multipart form data is processed
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed May 6, 2019
1 parent 48015c8 commit c2afc42
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/EventListener/MultipartRequestListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function onKernelRequest(GetResponseEvent $event)
private function processRequest(Request $request)
{
$contentType = $request->headers->get('Content-Type');
if (0 === strpos($contentType, 'multipart/')) {
if (0 === strpos($contentType, 'multipart/') && false === strpos($contentType, 'multipart/form-data')) {

$streamedPart = HttpFoundation::convert($request);

Expand Down
31 changes: 31 additions & 0 deletions tests/EventListener/MultipartRequestListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,37 @@ public function setUp()
$this->event = new GetResponseEvent(new TestKernel(), $this->request, HttpKernelInterface::MASTER_REQUEST);
}

public function testFormDataIsNotTouched()
{
$this->listener = new MultipartRequestListener(false);

$this->request->headers->set('Content-Type', 'multipart/form-data; boundary=delimiter');
$this->request->headers->set('Other', 'value');
$this->setRequestContent(
$content = "--delimiter\r\n"
. "Header: value\r\n"
. "Content-Type: application/*\r\n"
. "\r\n"
. "Content\r\n"
. "--delimiter--\r\n"
);

$this->listener->onKernelRequest($this->event);

// headers not changed
self::assertEquals([
'content-type' => ['multipart/form-data; boundary=delimiter'],
'other' => ['value']
],
$this->request->headers->all()
);

self::assertFalse($this->request->attributes->has('related-parts'));

// request content not changed
self::assertEquals($content, $this->request->getContent());
}

public function testPrimaryNotInjectedAsMain()
{
$this->listener = new MultipartRequestListener(false);
Expand Down

0 comments on commit c2afc42

Please sign in to comment.