Package javax.servlet

Examples of javax.servlet.ServletInputStream


            this.contentLength = inputStream.available();
        } catch (IOException e) {
            this.contentLength = -1;
        }

        this.content = new ServletInputStream() {
            public int read() throws IOException {
                return inputStream.read();
            }
        };
    }
View Full Code Here


                return new StringBuffer("http://localhost:" + TestConstants.PORT + "/obr/" + m_requestFile);
            }

            @SuppressWarnings("unused")
            public ServletInputStream getInputStream() {
                return new ServletInputStream() {
                    int i = 0;
                    @Override
                    public int read() throws IOException {
                        if (i == 0) {
                            i++;
View Full Code Here

      throw new MalformedRequestException(msg);
    }
    // So we passed basic tests, now we can read the bytes, but still keep an eye on the size
    // we can not fully trust the sent content length.
    if (StringUtils.equals(method, "POST")) {
      final ServletInputStream in = request.getInputStream(); // ServletInputStream does not have to be closed, container handles this
      ret = new LimitLengthASN1Reader(in, n).readFirstASN1Object();
      if (n > ret.length) {
        // The client is sending more data than the OCSP request. It might be slightly broken or trying to bog down the server on purpose.
        // In the interest of not breaking existing systems that might have slightly broken clients we just log for a warning for now.
        String msg = intres.getLocalizedMessage("ocsp.additionaldata", ret.length, n);
View Full Code Here

        
         POST /cgi-bin/pkiclient.exe?operation=PKIOperation
         <binary PKCS7 data>
         */
        String operation = "PKIOperation";
        ServletInputStream sin = request.getInputStream();
        // This small code snippet is inspired/copied by apache IO utils to Tomas Gustavsson...
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        byte[] buf = new byte[1024];
        int n = 0;
        while (-1 != (n = sin.read(buf))) {
            output.write(buf, 0, n);
        }
        String message = new String(Base64.encode(output.toByteArray()));
        service(operation, message, request.getRemoteAddr(), response);
        log.debug("<doPost()");
View Full Code Here

        
         POST /cgi-bin/pkiclient.exe?operation=PKIOperation
         <binary PKCS7 data>
         */
        String operation = "PKIOperation";
        ServletInputStream sin = request.getInputStream();
        // This small code snippet is inspired/copied by apache IO utils to Tomas Gustavsson...
        ByteArrayOutputStream output = new ByteArrayOutputStream();
        byte[] buf = new byte[1024];
        int n = 0;
        while (-1 != (n = sin.read(buf))) {
            output.write(buf, 0, n);
        }
        String message = new String(Base64.encode(output.toByteArray()));
        service(operation, message, request.getRemoteAddr(), response);
        log.trace("<doPost()");
View Full Code Here

     POST
     <binary CMP message>
     */
    byte[] ba = new byte[Math.min(LimitLengthASN1Reader.MAX_REQUEST_SIZE, request.getContentLength())];
    try {
      final ServletInputStream sin = request.getInputStream();
      sin.read(ba);
    } catch (Exception e) {
      response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
      log.error( intres.getLocalizedMessage("cmp.errornoasn1"), e );
      return;
    }
View Full Code Here

      bodyAccessed = true;
      return reader;
    }
   
    public ServletInputStream getInputStream() throws IOException {
      ServletInputStream stream = getHttpServletRequest().getInputStream();
      bodyAccessed = true;
      return stream;
    }
View Full Code Here

  public void doInputStreamTest(String testString) throws Exception{
    HttpServletRequest req = makeRequest(testString, null);

    BufferedRequestWrapper wrapper = new BufferedRequestWrapper(req, testString);
    ServletInputStream sis = req.getInputStream();
    byte b[] = new byte[32];
    int amountRead;

    while (( sis.readLine(b, 0, 32)) > 0){ /*clear out the request body*/ }

    sis = wrapper.getInputStream();
    StringBuffer buff = new StringBuffer();

    while ((amountRead = sis.readLine(b, 0, 32)) != 0){
      buff.append(new String(b, 0, amountRead));
    }

    assertEquals(buff.toString(), testString);
  }
View Full Code Here

    try {
      log.trace(">doPost()");
      if ( this.config==null ) {
        throw new ServletException("Servlet not initialized.");
      }
      final ServletInputStream sin = servletReq.getInputStream();
      final DERObject message;
      try {
        message = new LimitLengthASN1Reader(sin, servletReq.getContentLength()).readObject();
      } catch ( IOException e ) {
        servletResp.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
View Full Code Here

                public void setCharacterEncoding(String encoding) {
                    this.encoding = encoding;
                }

                public ServletInputStream getInputStream() throws IOException{
                    final ServletInputStream stream = super.getInputStream();
                    return new ServletInputStream(){
                        public int read() throws IOException{
                            return stream.read();
                        }

                        public int available(){
                            return body.length();
                        }
View Full Code Here

TOP

Related Classes of javax.servlet.ServletInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.