org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultFullHttpRequest Java Examples
The following examples show how to use
org.apache.flink.shaded.netty4.io.netty.handler.codec.http.DefaultFullHttpRequest.
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 |
/** * Sends a simple GET request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to GET (http://$host:$host/$path) */ public void sendGetRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #2
Source File: HttpTestClient.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Sends a simple DELETE request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to DELETE (http://$host:$host/$path) */ public void sendDeleteRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #3
Source File: HttpTestClient.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
/** * Sends a simple PATCH request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to PATCH (http://$host:$host/$path) */ public void sendPatchRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PATCH, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #4
Source File: AbstractHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testFileCleanup() throws Exception { final Path dir = temporaryFolder.newFolder().toPath(); final Path file = dir.resolve("file"); Files.createFile(file); RestfulGateway mockRestfulGateway = TestingRestfulGateway.newBuilder() .build(); final GatewayRetriever<RestfulGateway> mockGatewayRetriever = () -> CompletableFuture.completedFuture(mockRestfulGateway); CompletableFuture<Void> requestProcessingCompleteFuture = new CompletableFuture<>(); TestHandler handler = new TestHandler(requestProcessingCompleteFuture, mockGatewayRetriever); RouteResult<?> routeResult = new RouteResult<>("", "", Collections.emptyMap(), Collections.emptyMap(), ""); HttpRequest request = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.GET, TestHandler.TestHeaders.INSTANCE.getTargetRestEndpointURL(), Unpooled.wrappedBuffer(new byte[0])); RoutedRequest<?> routerRequest = new RoutedRequest<>(routeResult, request); Attribute<FileUploads> attribute = new SimpleAttribute(); attribute.set(new FileUploads(dir)); Channel channel = mock(Channel.class); when(channel.attr(any(AttributeKey.class))).thenReturn(attribute); ChannelHandlerContext context = mock(ChannelHandlerContext.class); when(context.channel()).thenReturn(channel); handler.respondAsLeader(context, routerRequest, mockRestfulGateway); // the (asynchronous) request processing is not yet complete so the files should still exist Assert.assertTrue(Files.exists(file)); requestProcessingCompleteFuture.complete(null); Assert.assertFalse(Files.exists(file)); }
Example #5
Source File: HttpTestClient.java From flink with Apache License 2.0 | 5 votes |
/** * Sends a simple GET request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to GET (http://$host:$host/$path) */ public void sendGetRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #6
Source File: HttpTestClient.java From flink with Apache License 2.0 | 5 votes |
/** * Sends a simple DELETE request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to DELETE (http://$host:$host/$path) */ public void sendDeleteRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #7
Source File: HttpTestClient.java From flink with Apache License 2.0 | 5 votes |
/** * Sends a simple PATCH request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to PATCH (http://$host:$host/$path) */ public void sendPatchRequest(String path, FiniteDuration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PATCH, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #8
Source File: AbstractHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFileCleanup() throws Exception { final Path dir = temporaryFolder.newFolder().toPath(); final Path file = dir.resolve("file"); Files.createFile(file); RestfulGateway mockRestfulGateway = TestingRestfulGateway.newBuilder() .build(); final GatewayRetriever<RestfulGateway> mockGatewayRetriever = () -> CompletableFuture.completedFuture(mockRestfulGateway); CompletableFuture<Void> requestProcessingCompleteFuture = new CompletableFuture<>(); TestHandler handler = new TestHandler(requestProcessingCompleteFuture, mockGatewayRetriever); RouteResult<?> routeResult = new RouteResult<>("", "", Collections.emptyMap(), Collections.emptyMap(), ""); HttpRequest request = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.GET, TestHandler.TestHeaders.INSTANCE.getTargetRestEndpointURL(), Unpooled.wrappedBuffer(new byte[0])); RoutedRequest<?> routerRequest = new RoutedRequest<>(routeResult, request); Attribute<FileUploads> attribute = new SimpleAttribute(); attribute.set(new FileUploads(dir)); Channel channel = mock(Channel.class); when(channel.attr(any(AttributeKey.class))).thenReturn(attribute); ChannelHandlerContext context = mock(ChannelHandlerContext.class); when(context.channel()).thenReturn(channel); handler.respondAsLeader(context, routerRequest, mockRestfulGateway); // the (asynchronous) request processing is not yet complete so the files should still exist Assert.assertTrue(Files.exists(file)); requestProcessingCompleteFuture.complete(null); Assert.assertFalse(Files.exists(file)); }
Example #9
Source File: HttpTestClient.java From flink with Apache License 2.0 | 5 votes |
/** * Sends a simple GET request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to GET (http://$host:$host/$path) */ public void sendGetRequest(String path, Duration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #10
Source File: HttpTestClient.java From flink with Apache License 2.0 | 5 votes |
/** * Sends a simple DELETE request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to DELETE (http://$host:$host/$path) */ public void sendDeleteRequest(String path, Duration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #11
Source File: HttpTestClient.java From flink with Apache License 2.0 | 5 votes |
/** * Sends a simple PATCH request to the given path. You only specify the $path part of * http://$host:$host/$path. * * @param path The $path to PATCH (http://$host:$host/$path) */ public void sendPatchRequest(String path, Duration timeout) throws TimeoutException, InterruptedException { if (!path.startsWith("/")) { path = "/" + path; } HttpRequest getRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PATCH, path); getRequest.headers().set(HttpHeaders.Names.HOST, host); getRequest.headers().set(HttpHeaders.Names.CONNECTION, HttpHeaders.Values.CLOSE); sendRequest(getRequest, timeout); }
Example #12
Source File: AbstractHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testFileCleanup() throws Exception { final Path dir = temporaryFolder.newFolder().toPath(); final Path file = dir.resolve("file"); Files.createFile(file); RestfulGateway mockRestfulGateway = new TestingRestfulGateway.Builder() .build(); final GatewayRetriever<RestfulGateway> mockGatewayRetriever = () -> CompletableFuture.completedFuture(mockRestfulGateway); CompletableFuture<Void> requestProcessingCompleteFuture = new CompletableFuture<>(); TestHandler handler = new TestHandler(requestProcessingCompleteFuture, mockGatewayRetriever); RouteResult<?> routeResult = new RouteResult<>("", "", Collections.emptyMap(), Collections.emptyMap(), ""); HttpRequest request = new DefaultFullHttpRequest( HttpVersion.HTTP_1_1, HttpMethod.GET, TestHandler.TestHeaders.INSTANCE.getTargetRestEndpointURL(), Unpooled.wrappedBuffer(new byte[0])); RoutedRequest<?> routerRequest = new RoutedRequest<>(routeResult, request); Attribute<FileUploads> attribute = new SimpleAttribute(); attribute.set(new FileUploads(dir)); Channel channel = mock(Channel.class); when(channel.attr(any(AttributeKey.class))).thenReturn(attribute); ChannelHandlerContext context = mock(ChannelHandlerContext.class); when(context.channel()).thenReturn(channel); handler.respondAsLeader(context, routerRequest, mockRestfulGateway); // the (asynchronous) request processing is not yet complete so the files should still exist Assert.assertTrue(Files.exists(file)); requestProcessingCompleteFuture.complete(null); Assert.assertFalse(Files.exists(file)); }