List of usage examples for javax.servlet.http HttpServletRequest getInputStream
public ServletInputStream getInputStream() throws IOException;
From source file:info.jtrac.web.RestMultiActionController.java
private String getContent(HttpServletRequest request) throws Exception { InputStream is = request.getInputStream(); int ch;/*from w w w .j av a 2s . c o m*/ ByteArrayOutputStream baos = new ByteArrayOutputStream(); while ((ch = is.read()) != -1) { baos.write((byte) ch); } return new String(baos.toByteArray()); }
From source file:com.zextras.zimbradrive.UploadFileHttpHandler.java
private String getFormPartsBoundary(HttpServletRequest httpServletRequest) throws IOException { try (InputStream userRequestInputStream = httpServletRequest.getInputStream()) { String firstLineOfBodyForm = readFirstLineOf(userRequestInputStream); return firstLineOfBodyForm.substring(2, firstLineOfBodyForm.length()); }//from w w w. j a va 2 s. co m }
From source file:com.monarchapis.driver.servlet.ApiRequest.java
public ApiRequest(HttpServletRequest request) throws IOException { super(request); this.body = IOUtils.toByteArray(request.getInputStream()); requestId = StringUtils.replace(UUID.randomUUID().toString(), "-", ""); }
From source file:jmu.edu.cn.util.JsonMapper.java
public <T> T fromJson(HttpServletRequest request, Class<T> pojoClass) throws IOException { ServletInputStream inputStream = request.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int index = inputStream.read(buf); while (index > 0) { baos.write(buf, 0, index);/*from w w w . j av a 2 s .c o m*/ index = inputStream.read(buf); } return mapper.readValue(baos.toByteArray(), pojoClass); }
From source file:it.unitn.disi.smatch.webapi.server.controllers.AbstractController.java
protected JSONObject getJSONRaw(HttpServletRequest request) throws IOException, JSONException { InputStream in = request.getInputStream(); int len = 0;/*from ww w . ja v a 2 s . co m*/ byte[] b = new byte[KB]; StringBuffer buff = new StringBuffer(); while ((len = in.read(b)) > 0) { buff.append(new String(b, 0, len)); } logger.debug("REQUEST: " + request.getMethod() + " " + request.getRequestURI() + "\n" + buff.toString()); return new JSONObject(buff.toString()); }
From source file:org.motechproject.mobile.web.ivr.intellivr.IntellIVRController.java
private String getContent(HttpServletRequest request) throws Exception { InputStream in = request.getInputStream(); int len = 4096; byte[] buffer = new byte[len]; int off = 0;/*from ww w . j a va2 s . c om*/ int read = 0; while ((read = in.read(buffer, off, len)) != -1) { off += read; len -= off; } return new String(buffer, 0, off); }
From source file:de.topicmapslab.majortom.server.http.web.AbstractMajorToMController.java
protected String extractBodyContent(HttpServletRequest req) throws IOException, UnsupportedEncodingException { InputStream is = req.getInputStream(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); int c = 0;//from w ww . j av a 2 s .c o m // read query while ((c = is.read()) != -1) { bos.write(c); } // save query String res = new String(bos.toByteArray(), "UTF-8"); // clean up is.close(); bos.close(); return res; }
From source file:org.openxdata.server.servlet.FormDownloadServlet.java
/** * Reads text data from an http request stream. * * @param request the http request stream. * @return the text data./* w w w.j a v a 2 s . com*/ * @throws java.io.IOException */ private String getRequestAsString(HttpServletRequest request) throws IOException { InputStream input = request.getInputStream(); return IOUtils.toString(input, "UTF-8"); }
From source file:com.mec.Security.JWTLoginFilter.java
@Override public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) throws AuthenticationException, IOException, ServletException { //System.out.println("JWTLoginFilter - attemptAuthentication"); AccountCredentials creds = new ObjectMapper().readValue(req.getInputStream(), AccountCredentials.class);//no permite inner class return getAuthenticationManager().authenticate(new UsernamePasswordAuthenticationToken(creds.getUsername(), creds.getPassword(), Collections.emptyList())); }
From source file:se.inera.certificate.proxy.mappings.remote.RemoteDispatcher.java
private HttpResponse makePutRequest(HttpServletRequest request, HttpPut put) throws IOException { addHeaders(request, put);//from w ww . ja v a 2 s. com put.setEntity(new InputStreamEntity(request.getInputStream(), -1)); return makeRequest(put); }