List of usage examples for io.netty.handler.codec.http HttpMethod GET
HttpMethod GET
To view the source code for io.netty.handler.codec.http HttpMethod GET.
Click Source Link
From source file:com.github.ambry.rest.PublicAccessLogHandlerTest.java
License:Open Source License
/** * Tests two successive request without completing first request * @throws IOException//from www. j a v a2s .co m */ @Test public void requestHandleWithTwoSuccessiveRequest() throws IOException { doRequestHandleWithMultipleRequest(HttpMethod.POST, "POST"); doRequestHandleWithMultipleRequest(HttpMethod.GET, "GET"); doRequestHandleWithMultipleRequest(HttpMethod.DELETE, "DELETE"); }
From source file:com.github.ambry.rest.PublicAccessLogHandlerTest.java
License:Open Source License
/** * Tests for the request handling flow for close * @throws IOException// ww w .j av a 2 s. co m */ @Test public void requestHandleOnCloseTest() throws IOException { doRequestHandleTest(HttpMethod.POST, EchoMethodHandler.CLOSE_URI, true); doRequestHandleTest(HttpMethod.GET, EchoMethodHandler.CLOSE_URI, true); doRequestHandleTest(HttpMethod.DELETE, EchoMethodHandler.CLOSE_URI, true); }
From source file:com.github.ambry.rest.PublicAccessLogHandlerTest.java
License:Open Source License
/** * Tests for the request handling flow on disconnect * @throws IOException//from w ww . jav a 2s.com */ @Test public void requestHandleOnDisconnectTest() throws IOException { // disonnecting the embedded channel, calls close of PubliAccessLogRequestHandler doRequestHandleTest(HttpMethod.POST, EchoMethodHandler.DISCONNECT_URI, true); doRequestHandleTest(HttpMethod.GET, EchoMethodHandler.DISCONNECT_URI, true); doRequestHandleTest(HttpMethod.DELETE, EchoMethodHandler.DISCONNECT_URI, true); }
From source file:com.github.ambry.rest.PublicAccessLogHandlerTest.java
License:Open Source License
/** * Verifies either the expected request headers are found or not found (based on the parameter passed) in the * public access log entry/*from w ww . java2s .c o m*/ * @param logEntry the public access log entry * @param headers expected headers * @param httpMethod HttpMethod type * @param expected, true if the headers are expected, false otherwise */ private void verifyPublicAccessLogEntryForRequestHeaders(String logEntry, HttpHeaders headers, HttpMethod httpMethod, boolean expected) { Iterator<Map.Entry<String, String>> itr = headers.iterator(); while (itr.hasNext()) { Map.Entry<String, String> entry = itr.next(); if (!entry.getKey().startsWith(NOT_LOGGED_HEADER_KEY) && !entry.getKey().startsWith(EchoMethodHandler.RESPONSE_HEADER_KEY_PREFIX)) { if (httpMethod == HttpMethod.GET && !entry.getKey().equals(HttpHeaders.Names.CONTENT_TYPE)) { String subString = "[" + entry.getKey() + "=" + entry.getValue() + "]"; boolean actual = logEntry.contains(subString); if (expected) { Assert.assertTrue("Public Access log entry does not have expected header", actual); } else { Assert.assertFalse("Public Access log entry have unexpected header", actual); } } } } }
From source file:com.github.jonbonazza.puni.core.mux.DefaultMuxer.java
License:Apache License
public DefaultMuxer() { methodMap.put(HttpMethod.CONNECT, new HashMap<>()); methodMap.put(HttpMethod.DELETE, new HashMap<>()); methodMap.put(HttpMethod.GET, new HashMap<>()); methodMap.put(HttpMethod.HEAD, new HashMap<>()); methodMap.put(HttpMethod.OPTIONS, new HashMap<>()); methodMap.put(HttpMethod.PATCH, new HashMap<>()); methodMap.put(HttpMethod.POST, new HashMap<>()); methodMap.put(HttpMethod.PUT, new HashMap<>()); methodMap.put(HttpMethod.TRACE, new HashMap<>()); }
From source file:com.github.jonbonazza.puni.core.mux.DefaultMuxerTest.java
License:Apache License
@Before public void setupTest() { HttpHandler handler = Mockito.mock(HttpHandler.class); Map<HttpMethod, Map<String, HttpHandler>> methodMap = new HashMap<>(); Map<String, HttpHandler> handlerMap = new HashMap<>(); handlerMap.put("/test/.*", handler); methodMap.put(HttpMethod.GET, handlerMap); muxer = new DefaultMuxer(methodMap); }
From source file:com.github.jonbonazza.puni.core.mux.DefaultMuxerTest.java
License:Apache License
@Test public void testMux() { HttpRequest request = new HttpRequest( new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/test/test")); HttpHandler handler = muxer.mux(request); assertNotNull(handler);//from www .j ava2 s. c om request.setUri("/test"); handler = muxer.mux(request); assertNull(handler); }
From source file:com.github.jonbonazza.puni.core.mux.DefaultMuxerTest.java
License:Apache License
@Test public void testHandle() { HttpHandler handler = Mockito.mock(HttpHandler.class); muxer.handle(HttpMethod.GET, "/test", handler); Map<String, HttpHandler> getMap = muxer.getMethodMap().get(HttpMethod.GET); assertNotNull(getMap.get("/test")); }
From source file:com.github.jonbonazza.puni.example.ExampleApplication.java
License:Apache License
@Override protected void configure(AppConfiguration configuration, Muxer muxer) throws Exception { muxer.handle(HttpMethod.GET, "/hello", new HelloWorldHandler()); }
From source file:com.github.smallcreep.bmp.client.tests.TestProxyBMPClient.java
License:Apache License
@Test public void testOverridesResponseAsResponseFilterAndListUrl() throws Throwable { Headers headersExpected = new Headers(); List<String> accessControlAllowCredentialsList = new ArrayList<>(); accessControlAllowCredentialsList.add("test"); accessControlAllowCredentialsList.add("test2"); headersExpected.put(ACCESS_CONTROL_ALLOW_CREDENTIALS, accessControlAllowCredentialsList); List<String> accessControlMaxAgeList = new ArrayList<>(); accessControlMaxAgeList.add("test3"); headersExpected.put(ACCESS_CONTROL_MAX_AGE, accessControlMaxAgeList); io.netty.handler.codec.http.HttpResponse responseOverrides = new DefaultFullHttpResponse( HttpVersion.HTTP_1_1, HttpResponseStatus.FORBIDDEN); for (String headers : headersExpected.keySet()) { for (String headersValue : headersExpected.get(headers)) { responseOverrides.headers().add(headers, headersValue); }/*from ww w. ja v a 2s . com*/ } HttpMessageContents contents = new HttpMessageContents( new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.FORBIDDEN)); contents.setTextContents("<html><body>Response successfully intercepted</body></html>"); List<FilterUrls> filterUrls = new ArrayList<>(); filterUrls.add(new FilterUrls("(.*)index\\.html(.*)")); filterUrls.add(new FilterUrls("^http:\\/\\/search\\.maven\\.org\\/$", HttpMethod.GET)); filterUrls.add(new FilterUrls("(.*)test\\.html(.*)", HttpMethod.POST)); BMPResponseFilter bmpResponseFilter = new BMPResponseFilter(responseOverrides, contents, null, filterUrls); getBmpLittleProxy().setFilterResponse(bmpResponseFilter); Unirest.setProxy(new HttpHost(getBmpLittleProxy().getAddress(), getBmpLittleProxy().getPort())); HttpResponse<String> response = Unirest.get(URL_PROTOCOL + URL_FOR_TEST).asString(); assertOverrideResponseEquals(accessControlAllowCredentialsList, accessControlMaxAgeList, response); response = Unirest.post(URL_PROTOCOL + URL_FOR_TEST).asString(); assertOverrideResponseNotEquals(accessControlAllowCredentialsList, accessControlMaxAgeList, response); response = Unirest.get("http://search.maven.org/index.html").asString(); assertOverrideResponseEquals(accessControlAllowCredentialsList, accessControlMaxAgeList, response); response = Unirest.post("http://search.maven.org/index.html").asString(); assertOverrideResponseEquals(accessControlAllowCredentialsList, accessControlMaxAgeList, response); response = Unirest.get("http://search.maven.org/test.html").asString(); assertOverrideResponseNotEquals(accessControlAllowCredentialsList, accessControlMaxAgeList, response); response = Unirest.post("http://search.maven.org/test.html").asString(); assertOverrideResponseEquals(accessControlAllowCredentialsList, accessControlMaxAgeList, response); response = Unirest.get("http://search.maven.org/abracadabra.alibaba").asString(); assertOverrideResponseNotEquals(accessControlAllowCredentialsList, accessControlMaxAgeList, response); response = Unirest.post("http://search.maven.org/abracadabra.alibaba").asString(); assertOverrideResponseNotEquals(accessControlAllowCredentialsList, accessControlMaxAgeList, response); }