Package javax.servlet.http

Examples of javax.servlet.http.HttpServletResponseWrapper


           
            //Will stream updated response
            final ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
           
            //Create a custom response wrapper to adding in the padding
            HttpServletResponseWrapper responseWrapper = new HttpServletResponseWrapper(httpResponse) {

                @Override
                public ServletOutputStream getOutputStream() throws IOException {
                    return new ServletOutputStream() {
                        @Override
View Full Code Here


        invocationContext = client.newInvocation("http://localhost/myservlet");

        request = invocationContext.getRequest();

        // http unit在这里有个可耻的错误,HH:mm:ss写成了hh:mm:ss,导致日期错误。
        response = new HttpServletResponseWrapper(invocationContext.getResponse()) {
            @Override
            public void setDateHeader(String name, long date) {
                super.setHeader(name, fmt.format(new Date(date)));
            }
        };
View Full Code Here

  public void testReloadCacheCall()
      throws Exception {
    when(mockRequest.getRequestURI()).thenReturn(ReloadCacheRequestHandler.ENDPOINT_URI);

    final ThreadLocal<Integer> status = new ThreadLocal<Integer>();
    final HttpServletResponse response = new HttpServletResponseWrapper(mockResponse) {
      @Override
      public void setStatus(final int sc) {
        status.set(sc);
      }
    };
View Full Code Here

  public void testReloadModelCall()
      throws Exception {
    when(mockRequest.getRequestURI()).thenReturn(ReloadModelRequestHandler.ENDPOINT_URI);

    final ThreadLocal<Integer> status = new ThreadLocal<Integer>();
    final HttpServletResponse response = new HttpServletResponseWrapper(mockResponse) {
      @Override
      public void setStatus(final int sc) {
        status.set(sc);
      }
    };
View Full Code Here

    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    final CountingOutputStream countingStream = new CountingOutputStream(new GZIPOutputStream(new BufferedOutputStream(
        baos)));
    // final GZIPOutputStream gzout = new GZIPOutputStream(new BufferedOutputStream(baos));
    // Perform gzip operation in-memory before sending response
    final HttpServletResponseWrapper wrappedResponse = new RedirectedStreamServletResponseWrapper(countingStream,
        response);
    chain.doFilter(req, wrappedResponse);
    // close underlying stream
    countingStream.close();
    response.setContentLength(countingStream.getCount());
View Full Code Here

        super.doFilter(request, response);
      }
    };
    this.filter.doFilter(this.request, this.response, this.chain);
    assertThat(this.chain.getRequest(), equalTo((ServletRequest) this.request));
    HttpServletResponseWrapper wrapper = (HttpServletResponseWrapper) this.chain
        .getResponse();
    assertThat(wrapper.getResponse(), equalTo((ServletResponse) this.response));
    assertTrue(this.response.isCommitted());
    assertThat(wrapper.getStatus(), equalTo(401));
    // The real response has to be 401 as well...
    assertThat(this.response.getStatus(), equalTo(401));
    assertThat(this.response.getForwardedUrl(), equalTo("/error"));
  }
View Full Code Here

      chain.doFilter( request, wrapResponse( (HttpServletResponse) response ) );
   }
  
   private static ServletResponse wrapResponse(HttpServletResponse response)
   {
      return new HttpServletResponseWrapper(response)
      {
         @Override
         public void sendRedirect(String url) throws IOException
         {
            if ( Contexts.isEventContextActive() )
View Full Code Here

         PortletApplicationContext applicationContext = application.getContext();
         ServletContext servletContext = applicationContext.getServletContext();

         //
         HttpServletRequestWrapper realReq = req.getRealRequest();
         HttpServletResponseWrapper realResp = resp.getRealResponse();

         //
         DispatchedHttpServletRequest direq;
         DispatchedHttpServletResponse diresp;
         if (req instanceof ActionRequest)
View Full Code Here

   protected PortletResponseImpl(PortletInvocation invocation, PortletRequestImpl preq)
   {
      this.invocation = invocation;
      this.preq = preq;
      this.realResp = new HttpServletResponseWrapper(invocation.getDispatchedResponse());
   }
View Full Code Here

          } else if (!checkFileCount(httpRequest, queryParamMap.get("id"))) {
            printResponse(response, "<html id=\"_richfaces_file_upload_forbidden\"></html>");
          } else {

            handleRequest(multipartRequest,  multipartRequest.isFormUpload() ? response :
              new HttpServletResponseWrapper((HttpServletResponse) response){
              @Override
              public void setContentType(String type) {
                super.setContentType(BaseXMLFilter.TEXT_HTML + ";charset=UTF-8");
              }
            }, chain);
View Full Code Here

TOP

Related Classes of javax.servlet.http.HttpServletResponseWrapper

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.