org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpContent Java Examples

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpContent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HttpTestClient.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
	LOG.debug("Received {}", msg);

	if (msg instanceof HttpResponse) {
		HttpResponse response = (HttpResponse) msg;

		currentStatus = response.getStatus();
		currentType = response.headers().get(HttpHeaders.Names.CONTENT_TYPE);
		currentLocation = response.headers().get(HttpHeaders.Names.LOCATION);

		if (HttpHeaders.isTransferEncodingChunked(response)) {
			LOG.debug("Content is chunked");
		}
	}

	if (msg instanceof HttpContent) {
		HttpContent content = (HttpContent) msg;

		// Add the content
		currentContent += content.content().toString(CharsetUtil.UTF_8);

		// Finished with this
		if (content instanceof LastHttpContent) {
			responses.add(new SimpleHttpResponse(currentStatus, currentType,
					currentContent, currentLocation));

			currentStatus = null;
			currentType = null;
			currentLocation = null;
			currentContent = "";

			ctx.close();
		}
	}
}
 
Example #2
Source File: HttpTestClient.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
	LOG.debug("Received {}", msg);

	if (msg instanceof HttpResponse) {
		HttpResponse response = (HttpResponse) msg;

		currentStatus = response.getStatus();
		currentType = response.headers().get(HttpHeaders.Names.CONTENT_TYPE);
		currentLocation = response.headers().get(HttpHeaders.Names.LOCATION);

		if (HttpHeaders.isTransferEncodingChunked(response)) {
			LOG.debug("Content is chunked");
		}
	}

	if (msg instanceof HttpContent) {
		HttpContent content = (HttpContent) msg;

		// Add the content
		currentContent += content.content().toString(CharsetUtil.UTF_8);

		// Finished with this
		if (content instanceof LastHttpContent) {
			responses.add(new SimpleHttpResponse(currentStatus, currentType,
					currentContent, currentLocation));

			currentStatus = null;
			currentType = null;
			currentLocation = null;
			currentContent = "";

			ctx.close();
		}
	}
}
 
Example #3
Source File: HttpTestClient.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception {
	LOG.debug("Received {}", msg);

	if (msg instanceof HttpResponse) {
		HttpResponse response = (HttpResponse) msg;

		currentStatus = response.getStatus();
		currentType = response.headers().get(HttpHeaders.Names.CONTENT_TYPE);
		currentLocation = response.headers().get(HttpHeaders.Names.LOCATION);

		if (HttpHeaders.isTransferEncodingChunked(response)) {
			LOG.debug("Content is chunked");
		}
	}

	if (msg instanceof HttpContent) {
		HttpContent content = (HttpContent) msg;

		// Add the content
		currentContent += content.content().toString(CharsetUtil.UTF_8);

		// Finished with this
		if (content instanceof LastHttpContent) {
			responses.add(new SimpleHttpResponse(currentStatus, currentType,
					currentContent, currentLocation));

			currentStatus = null;
			currentType = null;
			currentLocation = null;
			currentContent = "";

			ctx.close();
		}
	}
}