Example usage for io.netty.handler.codec.http HttpMethod DELETE

List of usage examples for io.netty.handler.codec.http HttpMethod DELETE

Introduction

In this page you can find the example usage for io.netty.handler.codec.http HttpMethod DELETE.

Prototype

HttpMethod DELETE

To view the source code for io.netty.handler.codec.http HttpMethod DELETE.

Click Source Link

Document

The DELETE method requests that the origin server delete the resource identified by the Request-URI.

Usage

From source file:org.restexpress.route.RouteResolverTest.java

License:Apache License

@Test
public void shouldResolveCrudRouteForDelete() {
    FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE,
            "/foo/foo23.json?value=ignored");
    httpRequest.headers().add("Host", "testing-host");
    Request request = new Request(httpRequest, null);
    Action action = resolver.resolve(request);
    assertNotNull(action);//from   ww w.  j  a va  2s  . c  o m
    assertEquals(HttpMethod.DELETE, action.getRoute().getMethod());
    assertEquals("/foo/{fooId}", action.getRoute().getPattern());
}

From source file:org.restexpress.route.RouteResolverTest.java

License:Apache License

@Test
public void shouldResolveAliasCrudRouteForDelete() {
    FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE,
            "/blah/foo/foo23.json?value=ignored");
    httpRequest.headers().add("Host", "testing-host");
    Request request = new Request(httpRequest, null);
    Action action = resolver.resolve(request);
    assertNotNull(action);//from ww  w  .j a  v a 2 s.  c o m
    assertEquals(HttpMethod.DELETE, action.getRoute().getMethod());
    assertEquals("/foo/{fooId}", action.getRoute().getPattern());
}

From source file:org.restexpress.route.RouteResolverTest.java

License:Apache License

@Test
public void shouldSendAllowedMethodsForCrudRoute() {
    FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.OPTIONS,
            "/foo/foo23.json?value=ignored");
    httpRequest.headers().add("Host", "testing-host");
    Request request = new Request(httpRequest, null);
    try {/*from ww  w  .j ava2s.co  m*/
        resolver.resolve(request);
    } catch (MethodNotAllowedException e) {
        List<HttpMethod> allowed = e.getAllowedMethods();
        assertEquals(4, allowed.size());
        assertTrue(allowed.contains(HttpMethod.GET));
        assertTrue(allowed.contains(HttpMethod.PUT));
        assertTrue(allowed.contains(HttpMethod.POST));
        assertTrue(allowed.contains(HttpMethod.DELETE));
    }
}

From source file:org.waarp.openr66.protocol.http.rest.test.HttpTestRestR66Client.java

License:Open Source License

protected static RestFuture deleteData(Channel channel, RESTHANDLERS data)
        throws HttpInvalidAuthenticationException {
    logger.debug("Send query");
    AbstractDbData dbData = getItem(data);
    if (dbData == null) {
        RestFuture future = channel.attr(HttpRestClientSimpleResponseHandler.RESTARGUMENT).get();
        future.cancel();/*from  w ww  . ja v  a2 s  .  c  o  m*/
        WaarpSslUtility.closingSslChannel(channel);
        return future;
    }
    String item = dbData.getJson().path(clientHelper.getPrimaryPropertyName(dbData.getClass().getSimpleName()))
            .asText();
    String key = null, value = null;
    if (HttpTestR66PseudoMain.config.REST_AUTHENTICATED) {
        key = userAuthent;
        value = keyAuthent;
    }
    Map<String, String> args = null;
    if (dbData instanceof DbTaskRunner) {
        args = new HashMap<String, String>();
        args.put(DbTaskRunner.Columns.REQUESTER.name(), hostid);
        args.put(DbTaskRunner.Columns.REQUESTED.name(), hostid);
        args.put(Columns.OWNERREQ.name(), Configuration.configuration.getHOST_ID());
    }
    RestFuture future = clientHelper.sendQuery(HttpTestR66PseudoMain.config, channel, HttpMethod.DELETE, host,
            data.uri + "/" + item, key, value, args, null);
    logger.debug("Query sent");
    return future;
}

From source file:org.waarp.openr66.protocol.http.rest.test.HttpTestRestR66Client.java

License:Open Source License

protected static RestFuture deleteData(Channel channel, RestArgument arg)
        throws HttpInvalidAuthenticationException {
    logger.debug("Send query");
    String base = arg.getBaseUri();
    String item = clientHelper.getPrimaryProperty(arg);
    String key = null, value = null;
    if (HttpTestR66PseudoMain.config.REST_AUTHENTICATED) {
        key = userAuthent;//from w  w  w .  j  av a 2  s  .c o  m
        value = keyAuthent;
    }
    Map<String, String> args = null;
    if (base.equals(HttpRestR66Handler.RESTHANDLERS.DbTaskRunner.uri)) {
        args = new HashMap<String, String>();
        args.put(DbTaskRunner.Columns.REQUESTER.name(), hostid);
        args.put(DbTaskRunner.Columns.REQUESTED.name(), hostid);
        args.put(Columns.OWNERREQ.name(), Configuration.configuration.getHOST_ID());
    }
    RestFuture future = clientHelper.sendQuery(HttpTestR66PseudoMain.config, channel, HttpMethod.DELETE, host,
            base + "/" + item, key, value, args, null);
    logger.debug("Query sent");
    return future;
}

From source file:org.waarp.openr66.protocol.http.rest.test.HttpTestRestR66Client.java

License:Open Source License

protected static RestFuture deleteData(Channel channel, String reqd, String reqr, long specid)
        throws HttpInvalidAuthenticationException {
    logger.debug("Send query");
    String key = null, value = null;
    if (HttpTestR66PseudoMain.config.REST_AUTHENTICATED) {
        key = userAuthent;/* w  w  w  .ja  va  2 s  .c  o  m*/
        value = keyAuthent;
    }
    Map<String, String> args = new HashMap<String, String>();
    args.put(DbTaskRunner.Columns.REQUESTER.name(), reqr);
    args.put(DbTaskRunner.Columns.REQUESTED.name(), reqd);
    RestFuture future = clientHelper.sendQuery(HttpTestR66PseudoMain.config, channel, HttpMethod.DELETE, host,
            RESTHANDLERS.DbTaskRunner.uri + "/" + specid, key, value, args, null);
    logger.debug("Query sent");
    return future;
}

From source file:org.wso2.carbon.analytics.test.osgi.util.TestUtil.java

License:Open Source License

public TestUtil(URI baseURI, String path, Boolean auth, Boolean keepAlive, String methodType,
        String contentType, String userName, String password) {
    try {/*from  www. j  ava  2  s.  c om*/
        URL url = baseURI.resolve(path).toURL();
        boundary = "---------------------------" + currentTimeMillis();
        logger.error(url.toString());
        connection = (HttpURLConnection) url.openConnection();
        connection.setRequestProperty("Accept-Charset", CHARSET);
        connection.setRequestMethod(methodType);
        setHeader("HTTP_METHOD", methodType);
        if (keepAlive) {
            connection.setRequestProperty("Connection", "Keep-Alive");
        }
        if (contentType != null) {
            if (contentType.equals("multipart/form-data")) {
                setHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
            } else {
                setHeader("Content-Type", contentType);
            }
        }
        connection.setUseCaches(false);
        connection.setDoInput(true);
        if (auth) {
            connection.setRequestProperty("Authorization", "Basic "
                    + java.util.Base64.getEncoder().encodeToString((userName + ":" + password).getBytes()));
        }
        if (methodType.equals(HttpMethod.POST.name()) || methodType.equals(HttpMethod.PUT.name())
                || methodType.equals(HttpMethod.DELETE.name())) {
            connection.setDoOutput(true);
            outputStream = connection.getOutputStream();
            writer = new PrintWriter(new OutputStreamWriter(outputStream, CHARSET), true);
        }
    } catch (IOException e) {
        handleException("IOException occurred while running the HttpsSourceTestCaseForSSL", e);
    }
}

From source file:org.wso2.carbon.mss.internal.router.HttpResourceModel.java

License:Open Source License

/**
 * Fetches the HttpMethod from annotations and returns String representation of HttpMethod.
 * Return emptyString if not present./*w  w w  .java  2 s.  c om*/
 *
 * @param method Method handling the http request.
 * @return String representation of HttpMethod from annotations or emptyString as a default.
 */
private Set<HttpMethod> getHttpMethods(Method method) {
    Set<HttpMethod> httpMethods = Sets.newHashSet();
    if (method.isAnnotationPresent(GET.class)) {
        httpMethods.add(HttpMethod.GET);
    }
    if (method.isAnnotationPresent(PUT.class)) {
        httpMethods.add(HttpMethod.PUT);
    }
    if (method.isAnnotationPresent(POST.class)) {
        httpMethods.add(HttpMethod.POST);
    }
    if (method.isAnnotationPresent(DELETE.class)) {
        httpMethods.add(HttpMethod.DELETE);
    }
    return ImmutableSet.copyOf(httpMethods);
}

From source file:org.wso2.carbon.mss.internal.router.HttpServerTest.java

License:Open Source License

@Test
public void testNoPathDeleteMethod() throws Exception {
    HttpURLConnection urlConn = request("/test/v1", HttpMethod.DELETE);
    Assert.assertEquals("no-@Path-DELETE", getContent(urlConn));
    urlConn.disconnect();//from  w w  w.  ja v  a2s . c om
}

From source file:reactor.ipc.netty.http.client.HttpClient.java

License:Open Source License

/**
 * HTTP DELETE the passed URL. When connection has been made, the passed handler is
 * invoked and can be used to build precisely the request and write data to it.
 *
 * @param url the target remote URL// w ww .j ava2 s  . co  m
 * @param handler the {@link Function} to invoke on open channel
 *
 * @return a {@link Mono} of the {@link HttpServerResponse} ready to consume for
 * response
 */
public final Mono<HttpClientResponse> delete(String url,
        Function<? super HttpClientRequest, ? extends Publisher<Void>> handler) {
    return request(HttpMethod.DELETE, url, handler);
}