mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-QA to HEAD (4.2) (including moving test classes into separate folders)
51903 to 54309 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@54310 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package org.alfresco.rest.api;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
public class PublicApiHttpServletRequest extends HttpServletRequestWrapper
|
||||
{
|
||||
public PublicApiHttpServletRequest(HttpServletRequest request) throws IOException
|
||||
{
|
||||
super(getWrappedHttpServletRequest(request));
|
||||
}
|
||||
|
||||
public void resetInputStream() throws IOException
|
||||
{
|
||||
ServletInputStream stream = getInputStream();
|
||||
stream.reset();
|
||||
}
|
||||
|
||||
private static HttpServletRequest getWrappedHttpServletRequest(HttpServletRequest request) throws IOException
|
||||
{
|
||||
final PublicApiServletInputStream sis = new PublicApiServletInputStream(request.getInputStream());
|
||||
HttpServletRequestWrapper wrapper = new HttpServletRequestWrapper(request)
|
||||
{
|
||||
public ServletInputStream getInputStream() throws java.io.IOException
|
||||
{
|
||||
return sis;
|
||||
}
|
||||
};
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private static class PublicApiServletInputStream extends ServletInputStream
|
||||
{
|
||||
private BufferedInputStream in;
|
||||
|
||||
PublicApiServletInputStream(InputStream in)
|
||||
{
|
||||
this.in = new BufferedInputStream(in);
|
||||
this.in.mark(8096);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
{
|
||||
return in.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException
|
||||
{
|
||||
in.reset();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user