mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUACAMOLE-1298: Do not enforce request size limits on file uploads handled as streams.
This commit is contained in:
@@ -21,10 +21,16 @@ package org.apache.guacamole.rest;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import javax.ws.rs.container.ContainerRequestContext;
|
import javax.ws.rs.container.ContainerRequestContext;
|
||||||
import javax.ws.rs.container.ContainerRequestFilter;
|
import javax.ws.rs.container.ContainerRequestFilter;
|
||||||
|
import javax.ws.rs.container.ResourceInfo;
|
||||||
|
import javax.ws.rs.core.Context;
|
||||||
import javax.ws.rs.ext.Provider;
|
import javax.ws.rs.ext.Provider;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
import org.apache.guacamole.environment.Environment;
|
import org.apache.guacamole.environment.Environment;
|
||||||
@@ -37,6 +43,14 @@ import org.apache.guacamole.properties.LongGuacamoleProperty;
|
|||||||
@Provider
|
@Provider
|
||||||
public class RequestSizeFilter implements ContainerRequestFilter {
|
public class RequestSizeFilter implements ContainerRequestFilter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Informs the RequestSizeFilter to NOT enforce its request size limits on
|
||||||
|
* requests serviced by the annotated method.
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public static @interface DoNotLimit {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default maximum number of bytes to accept within the entity body of
|
* The default maximum number of bytes to accept within the entity body of
|
||||||
* any particular REST request.
|
* any particular REST request.
|
||||||
@@ -61,6 +75,12 @@ public class RequestSizeFilter implements ContainerRequestFilter {
|
|||||||
@Inject
|
@Inject
|
||||||
private Environment environment;
|
private Environment environment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information describing the resource that was requested.
|
||||||
|
*/
|
||||||
|
@Context
|
||||||
|
private ResourceInfo resourceInfo;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filter(ContainerRequestContext context) throws IOException {
|
public void filter(ContainerRequestContext context) throws IOException {
|
||||||
|
|
||||||
@@ -74,7 +94,7 @@ public class RequestSizeFilter implements ContainerRequestFilter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ignore request size if limit is disabled
|
// Ignore request size if limit is disabled
|
||||||
if (maxRequestSize == 0)
|
if (maxRequestSize == 0 || resourceInfo.getResourceMethod().isAnnotationPresent(DoNotLimit.class))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Restrict maximum size of requests which have an input stream
|
// Restrict maximum size of requests which have an input stream
|
||||||
|
@@ -31,6 +31,7 @@ import javax.ws.rs.core.Response;
|
|||||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||||
import javax.ws.rs.core.StreamingOutput;
|
import javax.ws.rs.core.StreamingOutput;
|
||||||
import org.apache.guacamole.GuacamoleException;
|
import org.apache.guacamole.GuacamoleException;
|
||||||
|
import org.apache.guacamole.rest.RequestSizeFilter;
|
||||||
import org.apache.guacamole.tunnel.StreamInterceptingTunnel;
|
import org.apache.guacamole.tunnel.StreamInterceptingTunnel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,6 +128,7 @@ public class StreamResource {
|
|||||||
*/
|
*/
|
||||||
@POST
|
@POST
|
||||||
@Consumes(MediaType.WILDCARD)
|
@Consumes(MediaType.WILDCARD)
|
||||||
|
@RequestSizeFilter.DoNotLimit
|
||||||
public void setStreamContents(InputStream data) throws GuacamoleException {
|
public void setStreamContents(InputStream data) throws GuacamoleException {
|
||||||
|
|
||||||
// Send input over stream
|
// Send input over stream
|
||||||
|
Reference in New Issue
Block a user