[Seaside] [Pharo-users] Bad Request ZnEntityTooLarge
Bernhard Pieber
bernhard at pieber.com
Fri Jan 20 06:04:15 UTC 2017
Thank you for your answer, Sven.
That’s a bummer. If I understand you correctly, currently there is no hook in Seaside to catch lower level server exceptions (like ZnEntityTooLarge) to show a nice looking error page, e.g. „You are trying to upload a file that’s too large. Don’t do that!“ Really? :-/
Cheers,
Bernhard
> Am 19.01.2017 um 14:29 schrieb Sven Van Caekenberghe <sven at stfx.eu>:
>
> Hi Bernard,
>
> Your analysis is correct.
>
> Most Seaside adaptors, including ZnZincServerAdaptor, are implemented so that the incoming (Zn) request is read from the wire, then converted to Seaside WA* objects, processed, the result converted from WA* objects to an outgoing (Zn) response and put on the wire.
>
> Zn has some built-in resource protection measures, including a limit on how large entities (bodies) can be. The error of crossing such a limit is raised in the very first step, outside the scope of your Seaside handling code.
>
> At first sight, I would not immediately know how this can be solved.
>
> Note that in order to know how much is coming in, you have to read it, but you have to stop in time. Note also that the content-length header could be absent or wrong (a malicious request).
>
> I can't remember where we currently stand on a streaming Zn Seaside adaptor, there were some experiments in the past IIRC. That could be a solution, because then the entity/body is not read until further down the line, if we can get it to work. The current one only seems to do streaming for responses.
>
> Sven
>
>> On 19 Jan 2017, at 13:32, Bernhard Pieber <bernhard at pieber.com> wrote:
>>
>> I have a Seaside application which includes a file upload feature.
>>
>> renderContentOn: html
>> …
>> html fileUpload
>> callback: [ :file | self receiveFile: file ].
>> html submitButton: 'Upload‘ ]
>> …
>>
>> In receiveFile: I just save the uploaded file on the file system.
>>
>> When I upload a file larger than 16 MB an error page is shown with the error message:
>> Bad Request ZnEntityTooLarge
>>
>> I found that by using ZnConstants>>maximumEntitySize: I can increase this limit. However, I want to catch this in the image and show an error message to the user.
>>
>> I tried wrapping receiveFile: and renderContentOn: with an on:do: exception handler for ZnEntityTooLarge. However, neither works. It seems that the error happens before renderContentOn: is even called. I searched the mailing lists but did not come up with an answer.
>>
>> How can I achieve this in Seaside? Any help would be much appreciated.
>>
>> Cheers,
>> Bernhard
>> _______________________________________________
>> seaside mailing list
>> seaside at lists.squeakfoundation.org
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
More information about the seaside
mailing list