List of usage examples for io.netty.handler.codec.http HttpMethod DELETE
HttpMethod DELETE
To view the source code for io.netty.handler.codec.http HttpMethod DELETE.
Click Source Link
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.king.platform.net.http.netty.NettyHttpClient.java
License:Apache License
@Override public HttpClientRequest createDelete(String uri) { if (!started.get()) { throw new IllegalStateException("Http client is not started!"); }/* w w w .j a va2 s.com*/ return new HttpClientRequestBuilder(this, HttpVersion.HTTP_1_1, HttpMethod.DELETE, uri, confMap); }
From source file:com.linecorp.armeria.client.http.SimpleHttpRequestBuilder.java
License:Apache License
/** * Returns a {@link SimpleHttpRequestBuilder} for a DELETE request to the given URI, * for setting additional HTTP parameters as needed. *///from www.j av a2 s. c om public static SimpleHttpRequestBuilder forDelete(String uri) { return createRequestBuilder(uri, HttpMethod.DELETE); }
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.proxy.netty.MysqlQueryDecoder.java
License:Apache License
@Override protected void decode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) throws Exception { MysqlQuery result = new MysqlQuery(); try {/* w w w. j a v a 2 s . c o m*/ HttpMethod met = msg.getMethod(); String uri = msg.getUri(); int s = 0; int e = uri.length(); if (uri.charAt(0) == '/') s = 1; if (uri.charAt(e - 1) == '/') e--; String parts[] = uri.substring(s, e).split("/"); result.setDbName(parts[0]); result.setTableName(parts[1]); result.setKeyColName(parts[2]); result.setValueColName(parts[3]); if (met.equals(HttpMethod.PUT)) { /* * If HttpRequest method is PUT, I interpret it as a WRITE query. * MysqlQuery instance's value is set as the value in the HttpRequest. */ result.setKey(parts[4]); byte[] tempData = new byte[msg.content().readableBytes()]; msg.content().readBytes(tempData); result.setValue(tempData); result.setType(QueryType.WRITE); } else if (met.equals(HttpMethod.GET)) { /* * If HttpRequest method is GET, I interpret it as a READ query. * Once the query is processed, the result value (if any) is written to MysqlQuery.value. */ result.setKey(parts[4]); result.setType(QueryType.READ); } else if (met.equals(HttpMethod.DELETE)) { /* * If HttpRequest method is DELETE, I interpret it as a DELETE query. */ result.setKey(parts[4]); result.setType(QueryType.DELETE); } else if (met.equals(HttpMethod.POST)) { /* * If HttpRequest method is POST, I interpret it as a CREATE TABLE query. * I store size of the value column in MysqlQuery.Value. * I store byte array of the string representation. */ result.setValue(parts[4].getBytes()); result.setType(QueryType.CREATE); } else { result.setType(QueryType.INVALID); _LOG.error("Unhandled HttpMethod: " + met); _LOG.error("Type=" + QueryType.INVALID); } } catch (Exception e) { _LOG.error("Exception occured during HttpRequest processing", e); result.setType(QueryType.INVALID); _LOG.error("Type=" + QueryType.INVALID); } out.add(result); }
From source file:com.linkedin.proxy.netty.RocksdbQueryDecoder.java
License:Apache License
@Override protected void decode(ChannelHandlerContext ctx, FullHttpRequest msg, List<Object> out) throws Exception { /*/*from w w w . j av a 2 s. c om*/ * Expected inputs: * PUT /dbName/key <value in content> * GET /dbName/key * DELETE /dbName/key */ Query result = new Query(); try { HttpMethod met = msg.getMethod(); String uri = msg.getUri(); int s = 0; int e = uri.length(); if (uri.charAt(0) == '/') s = 1; if (uri.charAt(e - 1) == '/') e--; String parts[] = uri.substring(s, e).split("/"); result.setDbName(parts[0]); _LOG.debug("DbName: " + parts[0]); result.setKey(parts[1]); _LOG.debug("Key: " + parts[1]); if (met.equals(HttpMethod.PUT)) { /* * If HttpRequest method is PUT, I interpret it as a WRITE query. * Query instance's value is set as the value in the HttpRequest. */ byte[] tempData = new byte[msg.content().readableBytes()]; msg.content().readBytes(tempData); result.setValue(tempData); _LOG.debug("Value size: " + tempData.length); result.setType(QueryType.WRITE); } else if (met.equals(HttpMethod.GET)) { /* * If HttpRequest method is GET, I interpret it as a READ query. * Once the query is processed, the result value (if any) is written to MysqlQuery.value. */ result.setType(QueryType.READ); } else if (met.equals(HttpMethod.DELETE)) { /* * If HttpRequest method is DELETE, I interpret it as a DELETE query. */ result.setType(QueryType.DELETE); } else { result.setType(QueryType.INVALID); _LOG.error("Unhandled HttpMethod: " + met); _LOG.error("Type=" + QueryType.INVALID); } _LOG.debug("Type: " + result.getType()); } catch (Exception e) { _LOG.error("Exception occured during HttpRequest processing", e); result.setType(QueryType.INVALID); _LOG.error("Type=" + QueryType.INVALID); } out.add(result); }
From source file:com.litgh.RouterTest.java
License:Open Source License
public void testRouterAPI() { Router router = new Router(); final Map<String, Boolean> test = new HashMap<String, Boolean>(); router.GET("/GET", new Handler() { public void handle(HttpRequest req, FullHttpResponse resp, List<Param> params) { test.put("GET", true); }// w w w.j a v a 2 s .c o m }); router.POST("/POST", new Handler() { public void handle(HttpRequest req, FullHttpResponse resp, List<Param> params) { test.put("POST", true); } }); router.PUT("/PUT", new Handler() { public void handle(HttpRequest req, FullHttpResponse resp, List<Param> params) { test.put("PUT", true); } }); router.DELETE("/DELETE", new Handler() { public void handle(HttpRequest req, FullHttpResponse resp, List<Param> params) { test.put("DELETE", true); } }); router.HEAD("/HEAD", new Handler() { public void handle(HttpRequest req, FullHttpResponse resp, List<Param> params) { test.put("HEAD", true); } }); router.PATCH("/PATCH", new Handler() { public void handle(HttpRequest req, FullHttpResponse resp, List<Param> params) { test.put("PATCH", true); } }); HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/GET"); FullHttpResponse resp = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK); router.serverHttp(req, resp); req.setMethod(HttpMethod.POST); req.setUri("/POST"); router.serverHttp(req, resp); req.setMethod(HttpMethod.PUT); req.setUri("/PUT"); router.serverHttp(req, resp); req.setMethod(HttpMethod.DELETE); req.setUri("/DELETE"); router.serverHttp(req, resp); req.setMethod(HttpMethod.HEAD); req.setUri("/HEAD"); router.serverHttp(req, resp); req.setMethod(HttpMethod.PATCH); req.setUri("/PATCH"); router.serverHttp(req, resp); assertEquals("routing GET failed", Boolean.TRUE, test.get("GET")); assertEquals("routing POST failed", Boolean.TRUE, test.get("POST")); assertEquals("routing PUT failed", Boolean.TRUE, test.get("PUT")); assertEquals("routing DELETE failed", Boolean.TRUE, test.get("DELETE")); assertEquals("routing HEAD failed", Boolean.TRUE, test.get("HEAD")); assertEquals("routing PATCH failed", Boolean.TRUE, test.get("PATCH")); }
From source file:com.nike.cerberus.endpoints.authentication.RevokeToken.java
License:Apache License
@Override public Matcher requestMatcher() { return Matcher.match("/v1/auth", HttpMethod.DELETE); }
From source file:com.nike.cerberus.endpoints.authentication.RevokeTokenTest.java
License:Apache License
@Test public void requestMatcher_is_http_delete() { final Collection<HttpMethod> httpMethods = subject.requestMatcher().matchingMethods(); assertThat(httpMethods).hasSize(1);//w w w. ja v a2 s. co m assertThat(httpMethods).contains(HttpMethod.DELETE); }
From source file:com.nike.cerberus.endpoints.category.DeleteCategory.java
License:Apache License
@Override public Matcher requestMatcher() { return Matcher.match("/v1/category/{id}", HttpMethod.DELETE); }