Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Return immediately if request is not json #13

Merged
merged 1 commit into from
Apr 24, 2017

Conversation

fracz
Copy link
Contributor

@fracz fracz commented Apr 24, 2017

Fetching the contents before this checkick if the request is json may result in OutOfMemory excpetion if the request is multipart and contains big files.

Sample exception excerpt:

OutOfMemoryException in Request.php line 1564:
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 67108888 bytes)
in Request.php line 1564
at file_get_contents() in Request.php line 1564
at Request->getContent() in JsonRequestTransformerListener.php line 30
at JsonRequestTransformerListener->onKernelRequest() in WrappedListener.php line 106

Checking if request contains json content type headers before fetching the contents prevents this error.

Fetching the contents before this check may result in OutOfMemory excpetion if the request is multipart with files.
@fracz
Copy link
Contributor Author

fracz commented Apr 24, 2017

These fails are not introduced by this PR... Something in PHPUnit has changed. https://travis-ci.org/qandidate-labs/symfony-json-request-transformer/jobs/225105494

@othillo
Copy link
Member

othillo commented Apr 24, 2017

@fracz the build fails because Travis CI uses PHPUnit 6. This PR should fix it: #14

@asm89 asm89 merged commit 176c37b into qandidate-labs:master Apr 24, 2017
@othillo
Copy link
Member

othillo commented Apr 24, 2017

thank you, @fracz !

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants