List of usage examples for io.netty.handler.codec.http HttpMethod OPTIONS
HttpMethod OPTIONS
To view the source code for io.netty.handler.codec.http HttpMethod OPTIONS.
Click Source Link
From source file:com.corundumstudio.socketio.transport.PollingTransport.java
License:Apache License
private void handleMessage(FullHttpRequest req, UUID sessionId, QueryStringDecoder queryDecoder, ChannelHandlerContext ctx) throws IOException { String origin = req.headers().get(HttpHeaders.Names.ORIGIN); if (queryDecoder.parameters().containsKey("disconnect")) { ClientHead client = clientsBox.get(sessionId); client.onChannelDisconnect();/*from ww w .j a v a 2s . co m*/ ctx.channel().writeAndFlush(new XHRPostMessage(origin, sessionId)); } else if (HttpMethod.POST.equals(req.getMethod())) { onPost(sessionId, ctx, origin, req.content()); } else if (HttpMethod.GET.equals(req.getMethod())) { onGet(sessionId, ctx, origin); } else if (HttpMethod.OPTIONS.equals(req.getMethod())) { onOptions(sessionId, ctx, origin); } else { log.error("Wrong {} method invocation for {}", req.getMethod(), sessionId); sendError(ctx); } }
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.linecorp.armeria.client.http.SimpleHttpRequestBuilder.java
License:Apache License
/** * Returns a {@link SimpleHttpRequestBuilder} for an OPTIONS request to the given URI, * for setting additional HTTP parameters as needed. *///from w w w . ja v a2 s . c o m public static SimpleHttpRequestBuilder forOptions(String uri) { return createRequestBuilder(uri, HttpMethod.OPTIONS); }
From source file:com.linecorp.armeria.client.http.SimpleHttpRequestBuilderTest.java
License:Apache License
@Test public void httpMethods() { assertEquals(HttpMethod.GET, SimpleHttpRequestBuilder.forGet("/path").build().method()); assertEquals(HttpMethod.POST, SimpleHttpRequestBuilder.forPost("/path").build().method()); assertEquals(HttpMethod.PUT, SimpleHttpRequestBuilder.forPut("/path").build().method()); assertEquals(HttpMethod.PATCH, SimpleHttpRequestBuilder.forPatch("/path").build().method()); assertEquals(HttpMethod.DELETE, SimpleHttpRequestBuilder.forDelete("/path").build().method()); assertEquals(HttpMethod.HEAD, SimpleHttpRequestBuilder.forHead("/path").build().method()); assertEquals(HttpMethod.OPTIONS, SimpleHttpRequestBuilder.forOptions("/path").build().method()); }
From source file:com.linkedin.r2.transport.http.client.Http2UpgradeHandler.java
License:Apache License
@Override public void handlerAdded(ChannelHandlerContext ctx) throws Exception { _upgradePromise = ctx.channel().newPromise(); DefaultFullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, _path);//ww w.j a va 2 s. com request.headers().add(HttpHeaderNames.HOST, _host + ":" + _port); ctx.writeAndFlush(request); }
From source file:com.rackspacecloud.blueflood.http.RouteMatcher.java
License:Apache License
public void route(ChannelHandlerContext context, FullHttpRequest request) { final String method = request.getMethod().name(); final String URI = request.getUri(); // Method not implemented for any resource. So return 501. if (method == null || !implementedVerbs.contains(method)) { route(context, request, unsupportedVerbsHandler); return;/*from www. j av a 2 s . co m*/ } final Pattern pattern = getMatchingPatternForURL(URI); // No methods registered for this pattern i.e. URL isn't registered. Return 404. if (pattern == null) { route(context, request, noRouteHandler); return; } final Set<String> supportedMethods = getSupportedMethods(pattern); if (supportedMethods == null) { log.warn("No supported methods registered for a known pattern " + pattern); route(context, request, noRouteHandler); return; } // The method requested is not available for the resource. Return 405. if (!supportedMethods.contains(method)) { route(context, request, unsupportedMethodHandler); return; } PatternRouteBinding binding = null; if (method.equals(HttpMethod.GET.name())) { binding = getBindings.get(pattern); } else if (method.equals(HttpMethod.PUT.name())) { binding = putBindings.get(pattern); } else if (method.equals(HttpMethod.POST.name())) { binding = postBindings.get(pattern); } else if (method.equals(HttpMethod.DELETE.name())) { binding = deleteBindings.get(pattern); } else if (method.equals(HttpMethod.PATCH.name())) { binding = deleteBindings.get(pattern); } else if (method.equals(HttpMethod.OPTIONS.name())) { binding = optionsBindings.get(pattern); } else if (method.equals(HttpMethod.HEAD.name())) { binding = headBindings.get(pattern); } else if (method.equals(HttpMethod.TRACE.name())) { binding = traceBindings.get(pattern); } else if (method.equals(HttpMethod.CONNECT.name())) { binding = connectBindings.get(pattern); } if (binding != null) { request = updateRequestHeaders(request, binding); route(context, request, binding.handler); } else { throw new RuntimeException("Cannot find a valid binding for URL " + URI); } }
From source file:com.rackspacecloud.blueflood.http.RouteMatcher.java
License:Apache License
public void options(String pattern, HttpRequestHandler handler) { addBinding(pattern, HttpMethod.OPTIONS.name(), handler, optionsBindings); }
From source file:com.strategicgains.restexpress.plugin.cache.DateHeaderPostprocessorTest.java
License:Apache License
@Test public void shouldNotAddDateHeaderOnOptions() { FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS, "/foo?param1=bar¶m2=blah&yada"); httpRequest.headers().add("Host", "testing-host"); Response response = new Response(); processor.process(new Request(httpRequest, null), response); assertFalse(response.hasHeader(HttpHeaders.Names.DATE)); }
From source file:com.strategicgains.restexpress.plugin.swagger.SwaggerPluginTest.java
License:Apache License
@BeforeClass public static void intialize() { RestAssured.port = PORT;/*from www .j av a 2s. c o m*/ DummyController controller = new DummyController(); SERVER.setBaseUrl(BASE_URL); SERVER.uri("/", controller).action("health", HttpMethod.GET).name("root"); SERVER.uri("/anothers/{userId}", controller).action("readAnother", HttpMethod.GET); SERVER.uri("/users.{format}", controller).action("readAll", HttpMethod.GET) .action("options", HttpMethod.OPTIONS).method(HttpMethod.POST).name("Users Collection"); SERVER.uri("/users/{userId}.{format}", controller).method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE) .action("options", HttpMethod.OPTIONS).name("Individual User"); SERVER.uri("/users/{userId}/orders.{format}", controller).action("readAll", HttpMethod.GET) .method(HttpMethod.POST).name("User Orders Collection"); SERVER.uri("/orders.{format}", controller).action("readAll", HttpMethod.GET).method(HttpMethod.POST) .name("Orders Collection"); SERVER.uri("/orders/{orderId}.{format}", controller) .method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE).name("Individual Order"); SERVER.uri("/orders/{orderId}/items.{format}", controller).action("readAll", HttpMethod.GET) .method(HttpMethod.POST).name("Order Line-Items Collection"); SERVER.uri("/orders/{orderId}/items/{itemId}.{format}", controller) .method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE).name("Individual Order Line-Item"); SERVER.uri("/products.{format}", controller).action("readAll", HttpMethod.GET).method(HttpMethod.POST) .name("Orders Collection"); SERVER.uri("/products/{orderId}.{format}", controller) .method(HttpMethod.GET, HttpMethod.PUT, HttpMethod.DELETE).name("Individual Order"); SERVER.uri("/health", controller).flag("somevalue").action("health", HttpMethod.GET).name("health"); SERVER.uri("/nicknametest", controller).method(HttpMethod.GET).name(" |nickName sh0uld_str1p-CHARS$. "); SERVER.uri("/annotations/{userId}/users", controller) .action("readWithApiOperationAnnotation", HttpMethod.GET).method(HttpMethod.GET) .name("Read with Annotations"); SERVER.uri("/annotations/hidden", controller).action("thisIsAHiddenAPI", HttpMethod.GET) .method(HttpMethod.GET).name("thisIsAHiddenAPI"); SERVER.uri("/annotations/{userId}", controller).action("updateWithApiResponse", HttpMethod.PUT) .method(HttpMethod.PUT).name("Update with Annotations"); SERVER.uri("/annotations/{userId}/users/list", controller) .action("createWithApiImplicitParams", HttpMethod.POST).method(HttpMethod.POST) .name("Create with Implicit Params"); SERVER.uri("/annotations/{userId}/users/newlist", controller).action("createWithApiParam", HttpMethod.POST) .method(HttpMethod.POST).name("Create with Api Param"); SERVER.uri("/annotations/{userId}/users/list2", controller) .action("createWithApiModelRequest", HttpMethod.POST).method(HttpMethod.POST) .name("Create with Implicit Params"); new SwaggerPlugin().apiVersion("1.0").swaggerVersion("1.2").flag("flag1").flag("flag2") .parameter("parm1", "value1").parameter("parm2", "value2").register(SERVER); SERVER.bind(PORT); }
From source file:de.albahrani.pi4j.rest.sysinfo.RaspberrySystemInfoController.java
License:Apache License
/** * Attaches the system info services to your {@link RestExpress} instance * under the <code>baseUri</code>. * /* w w w. j a v a2 s. c o m*/ * @param server * The server to attach the services to * @param baseUri * a common root Uri prefix for all registered system info * services. If <code>null</code>, the services are registered * directly under root (<code>/</code>). */ public void attach(RestExpress server, String baseUri) { Logger.info("Attached RaspberrySystemInfoController to server under: {}", baseUri); server.uri(baseUri + "/clock", this).action("getSystemClockInfo", HttpMethod.GET) .action("getSystemClockInfo", HttpMethod.OPTIONS); server.uri(baseUri + "/java", this).action("getSystemJavaInfo", HttpMethod.GET).action("getSystemJavaInfo", HttpMethod.OPTIONS); server.uri(baseUri + "/memory", this).action("getSystemMemoryInfo", HttpMethod.GET) .action("getSystemMemoryInfo", HttpMethod.OPTIONS); server.uri(baseUri + "/cpu", this).action("getSystemCpuInfo", HttpMethod.GET).action("getSystemCpuInfo", HttpMethod.OPTIONS); server.uri(baseUri + "/os", this).action("getSystemOsInfo", HttpMethod.GET).action("getSystemOsInfo", HttpMethod.OPTIONS); server.uri(baseUri + "/features", this).action("getSystemFeaturesEnabledInfo", HttpMethod.GET) .action("getSystemFeaturesEnabledInfo", HttpMethod.OPTIONS); server.uri(baseUri, this).action("getSystemInfo", HttpMethod.GET).action("getSystemInfo", HttpMethod.OPTIONS); }