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

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpObject. 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: FlinkHttpObjectAggregator.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
protected void decode(
		final ChannelHandlerContext ctx,
		final HttpObject msg,
		final List<Object> out) throws Exception {

	try {
		super.decode(ctx, msg, out);
	} catch (final TooLongFrameException e) {
		HandlerUtils.sendErrorResponse(
			ctx,
			false,
			new ErrorResponseBody(String.format(
				e.getMessage() + " Try to raise [%s]",
				RestOptions.SERVER_MAX_CONTENT_LENGTH.key())),
			HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE,
			responseHeaders);
	}
}
 
Example #2
Source File: FlinkHttpObjectAggregator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected void decode(
		final ChannelHandlerContext ctx,
		final HttpObject msg,
		final List<Object> out) throws Exception {

	try {
		super.decode(ctx, msg, out);
	} catch (final TooLongFrameException e) {
		HandlerUtils.sendErrorResponse(
			ctx,
			false,
			new ErrorResponseBody(String.format(
				e.getMessage() + " Try to raise [%s]",
				RestOptions.SERVER_MAX_CONTENT_LENGTH.key())),
			HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE,
			responseHeaders);
	}
}
 
Example #3
Source File: FlinkHttpObjectAggregator.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
protected void decode(
		final ChannelHandlerContext ctx,
		final HttpObject msg,
		final List<Object> out) throws Exception {

	try {
		super.decode(ctx, msg, out);
	} catch (final TooLongFrameException e) {
		HandlerUtils.sendErrorResponse(
			ctx,
			false,
			new ErrorResponseBody(String.format(
				e.getMessage() + " Try to raise [%s]",
				RestOptions.SERVER_MAX_CONTENT_LENGTH.key())),
			HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE,
			responseHeaders);
	}
}
 
Example #4
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 #5
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 #6
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();
		}
	}
}