You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Davis Ford <df...@axeda.com> on 2011/12/09 03:53:30 UTC
Best way to put max byte limit on file uploads?
It seems there are several different possible approaches to this with CXF. The goal is to set a max byte count limit on uploads.
I took a look here: http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Readinglargeattachments
They show how to configure <jaxrs:properties> with
<entry key="attachment-memory-threshold" value="404800"/>
<entry key="attachment-max-size" value="404800"/>
I tried using these values on the port in question, but they seemed to have no effect. I could post massive files that exceeded the limit.
So, there are Interceptors, Filters, and MessageBodyReaders -- I suppose this task could be done in any of those.
I'm just wondering if there is some out-of-the-box support for this functionality already, and if not, what would the recommended path be?
Thanks in advance!
Davis
Re: Best way to put max byte limit on file uploads?
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 12/12/11 15:51, Davis Ford wrote:
> Hi Sergey, quick follow-up... I did add a RequestHandler filter, but it isn't clear to me the proper way to get at the "Content-Length" header. I know I'm posting it, b/c I'm using curl -v as a client, which shows prints the full request with the -v option. I thought that all the HTTP headers would be available off the Message map, but this doesn't seem to be the case. Is there a better way to get at the headers?
>
> @Override
> public Response handleRequest(Message m, ClassResourceInfo resourceClass)
> {
> if(m.containsKey("Content-Length")) { // returns false }
try injecting JAX-RS HttpHeaders and use it getMediaType method, though
the context injection in custom filters may not work well in 2.2.x
Please add LoggingInInterceptor - it will show if Content-Type available
or not
Cheers, Sergey
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Friday, December 09, 2011 11:23 AM
> To: users@cxf.apache.org
> Subject: Re: Best way to put max byte limit on file uploads?
>
>
> On 09/12/11 14:09, Davis Ford wrote:
>> Unfortunately, it is an older version: 2.2.12 -- should I expect that behavior in the old version? Any specific advice on the best way to implement this given these constraints?
>>
> May be a primitive solution could be to check Content-Length if it is available, from within custom RequestHandler filter ?
>
>
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
RE: Best way to put max byte limit on file uploads?
Posted by Davis Ford <df...@axeda.com>.
Hi Sergey, quick follow-up... I did add a RequestHandler filter, but it isn't clear to me the proper way to get at the "Content-Length" header. I know I'm posting it, b/c I'm using curl -v as a client, which shows prints the full request with the -v option. I thought that all the HTTP headers would be available off the Message map, but this doesn't seem to be the case. Is there a better way to get at the headers?
@Override
public Response handleRequest(Message m, ClassResourceInfo resourceClass)
{
if(m.containsKey("Content-Length")) { // returns false }
-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
Sent: Friday, December 09, 2011 11:23 AM
To: users@cxf.apache.org
Subject: Re: Best way to put max byte limit on file uploads?
On 09/12/11 14:09, Davis Ford wrote:
> Unfortunately, it is an older version: 2.2.12 -- should I expect that behavior in the old version? Any specific advice on the best way to implement this given these constraints?
>
May be a primitive solution could be to check Content-Length if it is available, from within custom RequestHandler filter ?
Re: Best way to put max byte limit on file uploads?
Posted by Sergey Beryozkin <sb...@gmail.com>.
On 09/12/11 14:09, Davis Ford wrote:
> Unfortunately, it is an older version: 2.2.12 -- should I expect that behavior in the old version? Any specific advice on the best way to implement this given these constraints?
>
May be a primitive solution could be to check Content-Length if it is
available, from within custom RequestHandler filter ?
Cheers, Sergey
> Thanks,
> Davis
>
> -----Original Message-----
> From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
> Sent: Friday, December 09, 2011 9:07 AM
> To: users@cxf.apache.org
> Subject: Re: Best way to put max byte limit on file uploads?
>
> On 09/12/11 02:53, Davis Ford wrote:
>> It seems there are several different possible approaches to this with CXF. The goal is to set a max byte count limit on uploads.
>>
>> I took a look here:
>> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Rea
>> dinglargeattachments
>>
>> They show how to configure<jaxrs:properties> with
>>
>> <entry key="attachment-memory-threshold" value="404800"/>
>>
>> <entry key="attachment-max-size" value="404800"/>
>>
>> I tried using these values on the port in question, but they seemed to have no effect. I could post massive files that exceeded the limit.
>>
>
> Is it CXF 2.5.0 that you work with ? We have a test confirming the property is used. Is it a multipart/form-data request ?
>
> thanks, Sergey
>
>>
>> Thanks in advance!
>>
>> Davis
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
RE: Best way to put max byte limit on file uploads?
Posted by Davis Ford <df...@axeda.com>.
Unfortunately, it is an older version: 2.2.12 -- should I expect that behavior in the old version? Any specific advice on the best way to implement this given these constraints?
Thanks,
Davis
-----Original Message-----
From: Sergey Beryozkin [mailto:sberyozkin@gmail.com]
Sent: Friday, December 09, 2011 9:07 AM
To: users@cxf.apache.org
Subject: Re: Best way to put max byte limit on file uploads?
On 09/12/11 02:53, Davis Ford wrote:
> It seems there are several different possible approaches to this with CXF. The goal is to set a max byte count limit on uploads.
>
> I took a look here:
> http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Rea
> dinglargeattachments
>
> They show how to configure<jaxrs:properties> with
>
> <entry key="attachment-memory-threshold" value="404800"/>
>
> <entry key="attachment-max-size" value="404800"/>
>
> I tried using these values on the port in question, but they seemed to have no effect. I could post massive files that exceeded the limit.
>
Is it CXF 2.5.0 that you work with ? We have a test confirming the property is used. Is it a multipart/form-data request ?
thanks, Sergey
>
> Thanks in advance!
>
> Davis
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
Re: Best way to put max byte limit on file uploads?
Posted by Sergey Beryozkin <sb...@gmail.com>.
On 09/12/11 02:53, Davis Ford wrote:
> It seems there are several different possible approaches to this with CXF. The goal is to set a max byte count limit on uploads.
>
> I took a look here: http://cxf.apache.org/docs/jax-rs-multiparts.html#JAX-RSMultiparts-Readinglargeattachments
>
> They show how to configure<jaxrs:properties> with
>
> <entry key="attachment-memory-threshold" value="404800"/>
>
> <entry key="attachment-max-size" value="404800"/>
>
> I tried using these values on the port in question, but they seemed to have no effect. I could post massive files that exceeded the limit.
>
> So, there are Interceptors, Filters, and MessageBodyReaders -- I suppose this task could be done in any of those.
>
> I'm just wondering if there is some out-of-the-box support for this functionality already, and if not, what would the recommended path be?
Is it CXF 2.5.0 that you work with ? We have a test confirming the
property is used. Is it a multipart/form-data request ?
thanks, Sergey
>
> Thanks in advance!
>
> Davis
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com