當前位置: 首頁>>代碼示例>>Java>>正文


Java LastHttpContent.EMPTY_LAST_CONTENT屬性代碼示例

本文整理匯總了Java中io.netty.handler.codec.http.LastHttpContent.EMPTY_LAST_CONTENT屬性的典型用法代碼示例。如果您正苦於以下問題:Java LastHttpContent.EMPTY_LAST_CONTENT屬性的具體用法?Java LastHttpContent.EMPTY_LAST_CONTENT怎麽用?Java LastHttpContent.EMPTY_LAST_CONTENT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在io.netty.handler.codec.http.LastHttpContent的用法示例。


在下文中一共展示了LastHttpContent.EMPTY_LAST_CONTENT屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onInboundNext

@Override
protected void onInboundNext(ChannelHandlerContext ctx, Object msg) {
	if (msg instanceof HttpContent) {
		if (msg != LastHttpContent.EMPTY_LAST_CONTENT) {
			super.onInboundNext(ctx, msg);
		}
		if (msg instanceof LastHttpContent) {
			onInboundComplete();
			if (isOutboundDone()) {
				onHandlerTerminate();
			}
			else {
				//force auto read to enable more accurate close selection now inbound is done
				channel().config()
				         .setAutoRead(true);
			}
		}
	}
	else {
		super.onInboundNext(ctx, msg);
	}
}
 
開發者ID:reactor,項目名稱:reactor-netty,代碼行數:22,代碼來源:HttpServerOperations.java

示例2: shouldDecodeAuthFailureBucketConfigResponse

@Test
public void shouldDecodeAuthFailureBucketConfigResponse() throws Exception {
    HttpResponse responseHeader = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
        new HttpResponseStatus(401, "Unauthorized"));
    HttpContent responseChunk = LastHttpContent.EMPTY_LAST_CONTENT;

    BucketConfigRequest requestMock = mock(BucketConfigRequest.class);
    requestQueue.add(requestMock);
    channel.writeInbound(responseHeader, responseChunk);

    assertEquals(1, eventSink.responseEvents().size());
    BucketConfigResponse event = (BucketConfigResponse) eventSink.responseEvents().get(0).getMessage();

    assertEquals(ResponseStatus.ACCESS_ERROR, event.status());
    assertEquals("Unauthorized", event.config());
    assertTrue(requestQueue.isEmpty());
}
 
開發者ID:couchbase,項目名稱:couchbase-jvm-core,代碼行數:17,代碼來源:ConfigHandlerTest.java

示例3: shouldDecodeSuccessFlushResponse

@Test
public void shouldDecodeSuccessFlushResponse() throws Exception {
    HttpResponse responseHeader = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
        new HttpResponseStatus(200, "OK"));
    HttpContent responseChunk = LastHttpContent.EMPTY_LAST_CONTENT;

    FlushRequest requestMock = mock(FlushRequest.class);
    requestQueue.add(requestMock);
    channel.writeInbound(responseHeader, responseChunk);

    assertEquals(1, eventSink.responseEvents().size());
    FlushResponse event = (FlushResponse) eventSink.responseEvents().get(0).getMessage();

    assertEquals(ResponseStatus.SUCCESS, event.status());
    assertEquals("OK", event.content());
    assertTrue(requestQueue.isEmpty());
}
 
開發者ID:couchbase,項目名稱:couchbase-jvm-core,代碼行數:17,代碼來源:ConfigHandlerTest.java

示例4: channelRead0

@Override
public void channelRead0(ChannelHandlerContext ctx, Object msg) {
    // This handler is the last inbound handler.
    // This means msg has not been handled by any previous handler.
    ctx.close();

    if (msg != LastHttpContent.EMPTY_LAST_CONTENT) {
        onUnknownMessage(msg);
    }
}
 
開發者ID:all4you,項目名稱:redant,代碼行數:10,代碼來源:BadClientSilencer.java

示例5: doWriteData

@Override
protected ChannelFuture doWriteData(
        ChannelHandlerContext ctx, int id, int streamId, HttpData data, boolean endStream) {

    if (id >= minClosedId) {
        ReferenceCountUtil.safeRelease(data);
        return ctx.newFailedFuture(ClosedSessionException.get());
    }

    final int length = data.length();
    if (length == 0) {
        ReferenceCountUtil.safeRelease(data);
        final HttpContent content = endStream ? LastHttpContent.EMPTY_LAST_CONTENT : EMPTY_CONTENT;
        final ChannelFuture future = write(ctx, id, content, endStream);
        ctx.flush();
        return future;
    }

    try {
        if (!isTls || length <= MAX_TLS_DATA_LENGTH) {
            // Cleartext connection or data.length() <= MAX_TLS_DATA_LENGTH
            return doWriteUnsplitData(ctx, id, data, endStream);
        } else {
            // TLS and data.length() > MAX_TLS_DATA_LENGTH
            return doWriteSplitData(ctx, id, data, endStream);
        }
    } catch (Throwable t) {
        return ctx.newFailedFuture(t);
    }
}
 
開發者ID:line,項目名稱:armeria,代碼行數:30,代碼來源:Http1ObjectEncoder.java

示例6: channelRead0

/**
 * HTTP upgrade response will be decode by Netty as 2 objects:
 * - 1 HttpObject corresponding to the 101 SWITCHING PROTOCOL headers
 * - 1 EMPTY_LAST_CONTENT
 *
 * The HTTP upgrade is successful whne the 101 SWITCHING PROTOCOL has been received (handshakeComplete = true)
 * but the latch is count down only when the following EMPTY_LAST_CONTENT is also received.
 * Otherwise this ChannelHandler would be removed too soon and the ActiveMQChannelHandler would handle the
 * EMPTY_LAST_CONTENT (while it is expecitng only ByteBuf).
 */
@Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
   if (logger.isDebugEnabled()) {
      logger.debug("Received msg=" + msg);
   }
   if (msg instanceof HttpResponse) {
      HttpResponse response = (HttpResponse) msg;
      if (response.status().code() == HttpResponseStatus.SWITCHING_PROTOCOLS.code() && response.headers().get(HttpHeaderNames.UPGRADE).equals(ACTIVEMQ_REMOTING)) {
         String accept = response.headers().get(SEC_ACTIVEMQ_REMOTING_ACCEPT);
         String expectedResponse = createExpectedResponse(MAGIC_NUMBER, ctx.channel().attr(REMOTING_KEY).get());

         if (expectedResponse.equals(accept)) {
            // HTTP upgrade is successful but let's wait to receive the EMPTY_LAST_CONTENT to count down the latch
            handshakeComplete = true;
         } else {
            // HTTP upgrade failed
            ActiveMQClientLogger.LOGGER.httpHandshakeFailed(msg);
            ctx.close();
            latch.countDown();
         }
         return;
      }
   } else if (msg == LastHttpContent.EMPTY_LAST_CONTENT && handshakeComplete) {
      // remove the http handlers and flag the activemq channel handler as active
      pipeline.remove(httpClientCodec);
      pipeline.remove(this);
      ActiveMQChannelHandler channelHandler = pipeline.get(ActiveMQChannelHandler.class);
      channelHandler.active = true;
   }
   if (!handshakeComplete) {
      ActiveMQClientLogger.LOGGER.httpHandshakeFailed(msg);
      ctx.close();
   }
   latch.countDown();
}
 
開發者ID:apache,項目名稱:activemq-artemis,代碼行數:45,代碼來源:NettyConnector.java

示例7: readChunk

@Override
public @Nullable HttpContent readChunk(ByteBufAllocator allocator) throws Exception {
    if (hasSentTerminatingChunk) {
        return null;
    }
    ByteBuf nextChunk = readNextChunk();
    if (nextChunk != null) {
        return new DefaultHttpContent(nextChunk);
    }
    // chunked transfer encoding must be terminated by a final chunk of length zero
    hasSentTerminatingChunk = true;
    return LastHttpContent.EMPTY_LAST_CONTENT;
}
 
開發者ID:glowroot,項目名稱:glowroot,代碼行數:13,代碼來源:ChunkedInputs.java

示例8: channelRead0

@Override
public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
	if (msg instanceof HttpResponse) {
		if (((HttpResponse)msg).getStatus().code() != 200)
			Logger.error("Upload Put Handler got unexpected read, non http response");
	}
	else if (msg != LastHttpContent.EMPTY_LAST_CONTENT)
		Logger.error("Upload Put Handler got unexpected read, non http response");

	this.finish();
}
 
開發者ID:Gadreel,項目名稱:divconq,代碼行數:11,代碼來源:UploadPutHandler.java


注:本文中的io.netty.handler.codec.http.LastHttpContent.EMPTY_LAST_CONTENT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。