|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2016 the original author or authors. |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -52,6 +52,7 @@ import org.springframework.web.util.NestedServletException; |
|
|
|
* Manipulated input streams could lead to unwanted code execution on the server |
|
|
|
* Manipulated input streams could lead to unwanted code execution on the server |
|
|
|
* during the deserialization step. As a consequence, do not expose HTTP invoker |
|
|
|
* during the deserialization step. As a consequence, do not expose HTTP invoker |
|
|
|
* endpoints to untrusted clients but rather just between your own services.</b> |
|
|
|
* endpoints to untrusted clients but rather just between your own services.</b> |
|
|
|
|
|
|
|
* In general, we strongly recommend any other message format (e.g. JSON) instead. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @author Juergen Hoeller |
|
|
|
* @since 1.1 |
|
|
|
* @since 1.1 |
|
|
|
@ -60,8 +61,7 @@ import org.springframework.web.util.NestedServletException; |
|
|
|
* @see org.springframework.remoting.rmi.RmiServiceExporter |
|
|
|
* @see org.springframework.remoting.rmi.RmiServiceExporter |
|
|
|
* @see org.springframework.remoting.caucho.HessianServiceExporter |
|
|
|
* @see org.springframework.remoting.caucho.HessianServiceExporter |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class HttpInvokerServiceExporter extends RemoteInvocationSerializingExporter |
|
|
|
public class HttpInvokerServiceExporter extends RemoteInvocationSerializingExporter implements HttpRequestHandler { |
|
|
|
implements HttpRequestHandler { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Reads a remote invocation from the request, executes it, |
|
|
|
* Reads a remote invocation from the request, executes it, |
|
|
|
@ -86,10 +86,8 @@ public class HttpInvokerServiceExporter extends RemoteInvocationSerializingExpor |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Read a RemoteInvocation from the given HTTP request. |
|
|
|
* Read a RemoteInvocation from the given HTTP request. |
|
|
|
* <p>Delegates to |
|
|
|
* <p>Delegates to {@link #readRemoteInvocation(HttpServletRequest, InputStream)} with |
|
|
|
* {@link #readRemoteInvocation(javax.servlet.http.HttpServletRequest, java.io.InputStream)} |
|
|
|
* the {@link HttpServletRequest#getInputStream() servlet request's input stream}. |
|
|
|
* with the |
|
|
|
|
|
|
|
* {@link javax.servlet.ServletRequest#getInputStream() servlet request's input stream}. |
|
|
|
|
|
|
|
* @param request current HTTP request |
|
|
|
* @param request current HTTP request |
|
|
|
* @return the RemoteInvocation object |
|
|
|
* @return the RemoteInvocation object |
|
|
|
* @throws IOException in case of I/O failure |
|
|
|
* @throws IOException in case of I/O failure |
|
|
|
@ -205,12 +203,10 @@ public class HttpInvokerServiceExporter extends RemoteInvocationSerializingExpor |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Decorate an {@code OutputStream} to guard against {@code flush()} calls, |
|
|
|
* Decorate an {@code OutputStream} to guard against {@code flush()} calls, |
|
|
|
* which are turned into no-ops. |
|
|
|
* which are turned into no-ops. |
|
|
|
* |
|
|
|
|
|
|
|
* <p>Because {@link ObjectOutputStream#close()} will in fact flush/drain |
|
|
|
* <p>Because {@link ObjectOutputStream#close()} will in fact flush/drain |
|
|
|
* the underlying stream twice, this {@link FilterOutputStream} will |
|
|
|
* the underlying stream twice, this {@link FilterOutputStream} will |
|
|
|
* guard against individual flush calls. Multiple flush calls can lead |
|
|
|
* guard against individual flush calls. Multiple flush calls can lead |
|
|
|
* to performance issues, since writes aren't gathered as they should be. |
|
|
|
* to performance issues, since writes aren't gathered as they should be. |
|
|
|
* |
|
|
|
|
|
|
|
* @see <a href="https://jira.spring.io/browse/SPR-14040">SPR-14040</a> |
|
|
|
* @see <a href="https://jira.spring.io/browse/SPR-14040">SPR-14040</a> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static class FlushGuardedOutputStream extends FilterOutputStream { |
|
|
|
private static class FlushGuardedOutputStream extends FilterOutputStream { |
|
|
|
|