List of usage examples for javax.servlet.http HttpServletRequest getInputStream
public ServletInputStream getInputStream() throws IOException;
From source file:org.zalando.logbook.servlet.example.ExampleController.java
@RequestMapping(value = "/read-byte", produces = MediaType.TEXT_PLAIN_VALUE) public void readByte(final HttpServletRequest request, final HttpServletResponse response) throws IOException { final ServletInputStream input = request.getInputStream(); final ServletOutputStream output = response.getOutputStream(); while (true) { final int read = input.read(); if (read == -1) { break; }//ww w . j a va 2 s .com output.write(read); } }
From source file:org.zalando.logbook.servlet.example.ExampleController.java
@RequestMapping(value = "/read-bytes", produces = MediaType.TEXT_PLAIN_VALUE) public void readBytes(final HttpServletRequest request, final HttpServletResponse response) throws IOException { final ServletInputStream input = request.getInputStream(); final ServletOutputStream output = response.getOutputStream(); final byte[] buffer = new byte[1]; while (true) { final int read = input.read(buffer); if (read == -1) { break; }/* w ww. j a va 2s. c om*/ output.write(buffer); } }
From source file:cz.sohlich.workstack.security.StatelessLoginFilter.java
@Override public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException, IOException, ServletException { final User user = new ObjectMapper().readValue(request.getInputStream(), User.class); final UsernamePasswordAuthenticationToken loginToken = new UsernamePasswordAuthenticationToken( user.getUsername(), user.getPassword()); return getAuthenticationManager().authenticate(loginToken); }
From source file:ee.ria.xroad.proxy.testsuite.testcases.ServerProxyConnectionAborted2.java
@Override public AbstractHandler getServerProxyHandler() { return new AbstractHandler() { @Override/* w w w.j av a2 s . c om*/ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { // Read all of the request. IOUtils.readLines(request.getInputStream()); response.setContentType("text/xml"); response.setContentLength(1000); response.getOutputStream().close(); response.flushBuffer(); baseRequest.setHandled(true); } }; }
From source file:ee.ria.xroad.proxy.testsuite.testcases.ServerProxyConnectionAborted3.java
@Override public AbstractHandler getServerProxyHandler() { return new AbstractHandler() { @Override/*ww w . j ava 2 s . c om*/ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { // Read all of the request. IOUtils.readLines(request.getInputStream()); response.setContentType("multipart/mixed; boundary=foobar"); response.setContentLength(1000); response.getOutputStream().close(); response.flushBuffer(); baseRequest.setHandled(true); } }; }
From source file:ee.ria.xroad.proxy.testsuite.testcases.ServerProxyNoBoundary.java
@Override public AbstractHandler getServerProxyHandler() { return new AbstractHandler() { @Override/* ww w . ja v a 2 s . c o m*/ public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { // Read all of the request. IOUtils.readLines(request.getInputStream()); response.setContentType("multipart/mixed"); response.setContentLength(1000); response.setHeader(HEADER_HASH_ALGO_ID, DEFAULT_DIGEST_ALGORITHM_ID); baseRequest.setHandled(true); } }; }
From source file:ai.nitro.bot4j.integration.alexa.receive.webhook.impl.AlexaWebhookImpl.java
@Override public String post(final HttpServletRequest req, final HttpServletResponse res) throws IOException { String result = ""; try {/* w ww . j a va 2 s.co m*/ final byte[] serializedSpeechletRequest = IOUtils.toByteArray(req.getInputStream()); SpeechletRequestSignatureVerifier.checkRequestSignature(serializedSpeechletRequest, req.getHeader(Sdk.SIGNATURE_REQUEST_HEADER), req.getHeader(Sdk.SIGNATURE_CERTIFICATE_CHAIN_URL_REQUEST_HEADER)); final byte[] outputBytes = alexaReceiveHandler.handleSpeechletRequest(serializedSpeechletRequest); result = new String(outputBytes); } catch (final IOException e) { //LOG.warn(e.getMessage(), e); } catch (final SecurityException e) { final int statusCode = HttpServletResponse.SC_BAD_REQUEST; //LOG.error("Exception occurred in doPost, returning status code {}", statusCode, e); res.sendError(statusCode, e.getMessage()); } return result; }
From source file:com.eternity.common.communication.servlet.AsyncDispatch.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doRequest(request, response, request.getInputStream()); }
From source file:com.ns.cm.ProvisionServlet.java
@Override protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { InputStream is = request.getInputStream(); byte[] bytes = readAll(is); String sJson = new String(bytes, "utf-8"); // json is utf-8 PrintWriter out = response.getWriter(); String a = "Reached doPut <BR> Data submitted: <BR>"; out.println(a);//from w ww .j ava 2 s . c o m out.println(sJson); response.setContentType("text/html"); response.setStatus(HttpServletResponse.SC_OK); }
From source file:br.gov.jfrj.siga.wf.servlet.UploadServlet.java
/** * Escreve o input stream (para debug)/* w w w. j a v a 2 s. c om*/ * * @param request * @throws IOException */ public void printInput(HttpServletRequest request) throws IOException { InputStream inputStream = request.getInputStream(); StringBuffer buffer = new StringBuffer(); int read; while ((read = inputStream.read()) != -1) { buffer.append((char) read); } log.debug(buffer.toString()); }