List of usage examples for javax.servlet ServletInputStream ServletInputStream
protected ServletInputStream()
From source file:hudson.plugins.jobConfigHistory.TUtils.java
static ServletInputStream createServletInputStreamFromMultiPartFormData(final String boundary) { final String body = "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"timestamp1\"\r\n\r\n" + "2014-02-05_10-42-37\r\n" + "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"timestamp2\"\r\n\r\n" + "2014-03-12_11-02-12\r\n" + "--" + boundary + "\r\n" + "Content-Disposition: form-data; name=\"name\"\r\n\r\n" + "foo\r\n" + "--" + boundary + "--\r\n"; final ByteArrayInputStream bodyByteStream = new ByteArrayInputStream(body.getBytes()); return new ServletInputStream() { @Override// w ww . ja va2 s . co m public int read() throws IOException { return bodyByteStream.read(); } }; }
From source file:appengine_commons.logger_filter.RequestWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { private TeeInputStream tee = new TeeInputStream(RequestWrapper.super.getInputStream(), bos); @Override//from w w w . j a v a 2s.com public int read() throws IOException { return tee.read(); } }; }
From source file:com.du.order.dist.log.RequestWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { @Override// www . j a va 2 s . com public boolean isFinished() { return false; } @Override public boolean isReady() { return false; } @Override public void setReadListener(ReadListener readListener) { } private TeeInputStream tee = new TeeInputStream(RequestWrapper.super.getInputStream(), bos); @Override public int read() throws IOException { return tee.read(); } }; }
From source file:com.arvato.thoroughly.filter.FilterRequestWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { final ByteArrayInputStream bais = new ByteArrayInputStream(body.getBytes(Charset.forName("UTF-8"))); return new ServletInputStream() { @Override/*from w w w.j av a2 s. c o m*/ public int read() throws IOException { return bais.read(); } @Override public boolean isFinished() { // TODO Auto-generated method stub return false; } @Override public boolean isReady() { // TODO Auto-generated method stub return false; } @Override public void setReadListener(ReadListener arg0) { // TODO Auto-generated method stub } }; }
From source file:eu.freme.broker.tools.loggingfilter.RequestWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { private TeeInputStream tee = new TeeInputStream(RequestWrapper.super.getInputStream(), bos); @Override/*w ww .ja v a2 s.c o m*/ public int read() throws IOException { return tee.read(); } @Override public void setReadListener(ReadListener listener) { } @Override public boolean isReady() { return true; } @Override public boolean isFinished() { return true; } }; }
From source file:org.impalaframework.extension.mvc.annotation.resolver.RequestBodyTest.java
private Object doRequestAttribute(String methodName, final String attributeName, final String value) throws Exception { MethodParameter methodParameter = new MethodParameter( ReflectionUtils.findMethod(AnnotatedClass.class, methodName, new Class[] { String.class }), 0); expect(nativeRequest.getNativeRequest()).andReturn(request); expect(request.getInputStream()).andReturn(new ServletInputStream() { @Override/*from ww w . j av a 2 s .c o m*/ public int read() throws IOException { return -1; } }); replayMocks(); Object arg = resolver.resolveArgument(methodParameter, nativeRequest); verifyMocks(); return arg; }
From source file:net.gplatform.sudoor.server.security.model.MultipleReadRequestWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { prepareInputStream();//from w w w. j a v a 2 s. c om final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bContent); ServletInputStream inputStream = new ServletInputStream() { public int read() throws IOException { return byteArrayInputStream.read(); } }; return inputStream; }
From source file:com.intuit.autumn.web.InputStreamHttpServletRequestWrapper.java
/** * Return wrapped intput stream//from ww w .j ava 2 s .c o m * * @return invalid response stream * @throws IOException unintended exception */ @Override public ServletInputStream getInputStream() throws IOException { final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body); return new ServletInputStream() { @Override public boolean isFinished() { return byteArrayInputStream.available() == 0; } @Override public boolean isReady() { return true; } @Override public void setReadListener(ReadListener readListener) { throw new UnsupportedOperationException("Not implemented"); } @Override public int read() throws IOException { return byteArrayInputStream.read(); } }; }
From source file:com.atolcd.alfresco.RequestWrapper.java
/** * Override of the getInputStream() method. * //from ww w. jav a 2 s . c o m * Return a new inputStream created from the stringRequest rather than * return the current inputStream, which may have been already read. */ @Override public ServletInputStream getInputStream() throws IOException { ServletInputStream inputStream; if (!this.stringRequest.isEmpty()) { final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(stringRequest.getBytes()); inputStream = new ServletInputStream() { @Override public int read() throws IOException { try { return byteArrayInputStream.read(); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.debug(e.getMessage(), e); } return 0; } } }; } else inputStream = this.getRequest().getInputStream(); return inputStream; }
From source file:com.zk.common.waf.request.WafRequestWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { String bizBindMsg = ""; ServletInputStream stream = null;//from w ww . j a v a 2 s. c o m try { stream = request.getInputStream(); bizBindMsg = IOUtils.toString(stream, "UTF-8"); } catch (IOException e) { e.printStackTrace(); } byte[] buffer = null; try { buffer = bizBindMsg.toString().getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } final ByteArrayInputStream bais = new ByteArrayInputStream(buffer); ServletInputStream newStream = new ServletInputStream() { @Override public int read() throws IOException { return bais.read(); } }; return newStream; }