Package org.jboss.netty.handler.codec.http

Examples of org.jboss.netty.handler.codec.http.DefaultHttpResponse


  @Test
  public void testTargetSCNExceptionAfterStartCase2() throws Exception
  {
    TestAbstractQueue queue = new TestAbstractQueue();
    TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
    HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
    Checkpoint cp = new Checkpoint();
    cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_CATCHUP);
    BootstrapTargetScnHttpResponseProcessor  processor =
        new BootstrapTargetScnHttpResponseProcessor(null, queue, stateMsg, cp,
View Full Code Here


  @Test
  public void testTargetSCNExceptionAfterStartCase3() throws Exception
  {
    TestAbstractQueue queue = new TestAbstractQueue();
    TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
    HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
    Checkpoint cp = new Checkpoint();
    cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_CATCHUP);
    BootstrapTargetScnHttpResponseProcessor  processor =
        new BootstrapTargetScnHttpResponseProcessor(null, queue, stateMsg, cp,
View Full Code Here

  @Test
  public void testTargetSCNExceptionAfterFinish() throws Exception
  {
    TestAbstractQueue queue = new TestAbstractQueue();
    TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
    HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
    Checkpoint cp = new Checkpoint();
    cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
    BootstrapTargetScnHttpResponseProcessor  processor =
        new BootstrapTargetScnHttpResponseProcessor(null, queue, stateMsg, cp,
View Full Code Here

    private void handleWebSocketHandshake(final ChannelHandlerContext ctx, MessageEvent messageEvent) throws IOException, URISyntaxException {
        final HttpRequest request = (HttpRequest) messageEvent.getMessage();

        // Allow only GET methods.
        if (request.getMethod() != GET) {
            sendHttpResponse(ctx, request, new DefaultHttpResponse(HTTP_1_1, FORBIDDEN));
            return;
        }

        WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(getWebSocketLocation(request), null, false);
        WebSocketServerHandshaker handshaker = wsFactory.newHandshaker(request);
View Full Code Here

            }
        }

        long fileLength = raf.length();

        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);
        contentType(request, response, file);
        setContentLength(response, fileLength);
        setDateAndCacheHeaders(response,file);

        Channel ch = e.getChannel();
View Full Code Here

        }
        return uri;
    }

    private static void sendNotModified(ChannelHandlerContext ctx) {
        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, NOT_MODIFIED);
        setDateHeader(response);

        // Close the connection as soon as the error message is sent.
        ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE);
    }
View Full Code Here

        response.setHeader(DATE, dateFormatter.format(time.getTime()));
    }

    protected void sendError(ChannelHandlerContext ctx, HttpResponseStatus status, MessageEvent event) {
        logger.trace("Error {} for {}", status, event);
        HttpResponse response = new DefaultHttpResponse(HTTP_1_1, status);
        response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8");
        response.setHeader(CONTENT_LENGTH, "0");
        response.setHeader("Server", "Atmosphere-" + Version.getRawVersion());

        // Close the connection as soon as the error message is sent.
        ctx.getChannel().write(response).addListener(ChannelFutureListener.CLOSE);
    }
View Full Code Here

        if (!channel.isOpen()) {
            return this;
        }

        try {
            DefaultHttpResponse r = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
                    HttpResponseStatus.valueOf(errorCode));
            channel.write(r).addListener(ChannelFutureListener.CLOSE);
        } catch (Throwable ex) {
            logger.debug("", ex);
        }
View Full Code Here

        {
          ObjectMapper mapper = new ObjectMapper();
          StringWriter sw = new StringWriter();
          mapper.writeValue(sw, bfResponse);

          HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
          response.setContent(ChannelBuffers.copiedBuffer(sw.toString(), CharsetUtil.UTF_8));
          response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain; charset=UTF-8");
          e.getChannel().write(response);
              try
              {
                Thread.sleep(_timeout);
              } catch (InterruptedException ie) {

              }
          e.getChannel().close();
        }

        else
        {
          HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR);
          response.setHeader(HttpHeaders.Names.CONTENT_TYPE, "text/plain; charset=UTF-8");
          e.getChannel().write(response);
          e.getChannel().close();
        }
      }
View Full Code Here

    }
  }

  private HttpResponse generateEmptyResponse()
  {
    HttpResponse response = new DefaultHttpResponse(HTTP_1_1, OK);

    //response.setContent(ChannelBuffers.wrappedBuffer(responseBody));
    response.setHeader(CONTENT_TYPE, "text/plain; charset=UTF-8");
    response.setHeader("Access-Control-Allow-Origin", "*");

    setTrackingInfo(response);

    // Encode the cookie.
    String cookieString = _httpRequest.getHeader(COOKIE);
    if (cookieString != null)
    {
        CookieDecoder cookieDecoder = new CookieDecoder();
        Set<Cookie> cookies = cookieDecoder.decode(cookieString);
        if(!cookies.isEmpty()) {
            // Reset the cookies if necessary.
            CookieEncoder cookieEncoder = new CookieEncoder(true);
            for (Cookie cookie : cookies) {
                cookieEncoder.addCookie(cookie);
            }
            response.addHeader(SET_COOKIE, cookieEncoder.encode());
        }
    }

    return response;
  }
View Full Code Here

TOP

Related Classes of org.jboss.netty.handler.codec.http.DefaultHttpResponse

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.