use of org.apache.http.client.methods.HttpDelete in project cxf by apache.
the class CrossOriginSimpleTest method testNonSimpleActualRequest.
@Test
public void testNonSimpleActualRequest() throws Exception {
configureAllowOrigins(true, null);
String r = configClient.replacePath("/setAllowCredentials/false").accept("text/plain").post(null, String.class);
assertEquals("ok", r);
HttpClient httpclient = HttpClientBuilder.create().build();
HttpDelete httpdelete = new HttpDelete("http://localhost:" + PORT + "/untest/delete");
httpdelete.addHeader("Origin", "http://localhost:" + PORT);
HttpResponse response = httpclient.execute(httpdelete);
assertEquals(200, response.getStatusLine().getStatusCode());
assertAllowCredentials(response, false);
assertOriginResponse(true, null, true, response);
if (httpclient instanceof Closeable) {
((Closeable) httpclient).close();
}
}
use of org.apache.http.client.methods.HttpDelete in project cxf by apache.
the class Client method delete.
private static void delete(final String url, final CloseableHttpClient httpClient) throws IOException {
System.out.println("Sent HTTP DELETE request to remove all books from catalog");
final HttpDelete delete = new HttpDelete(url);
try {
CloseableHttpResponse response = httpClient.execute(delete);
if (response.getStatusLine().getStatusCode() == 200) {
System.out.println(EntityUtils.toString(response.getEntity()));
}
} finally {
delete.releaseConnection();
}
}
use of org.apache.http.client.methods.HttpDelete in project cas by apereo.
the class HttpUtils method execute.
/**
* Execute http request and produce a response.
*
* @param url the url
* @param method the method
* @param basicAuthUsername the basic auth username
* @param basicAuthPassword the basic auth password
* @param parameters the parameters
* @param headers the headers
* @param entity the entity
* @return the http response
*/
public static HttpResponse execute(final String url, final String method, final String basicAuthUsername, final String basicAuthPassword, final Map<String, String> parameters, final Map<String, String> headers, final String entity) {
try {
final HttpClient client = buildHttpClient(basicAuthUsername, basicAuthPassword);
final URI uri = buildHttpUri(url, parameters);
final HttpUriRequest request;
switch(method.toLowerCase()) {
case "post":
request = new HttpPost(uri);
if (StringUtils.isNotBlank(entity)) {
final StringEntity stringEntity = new StringEntity(entity);
((HttpPost) request).setEntity(stringEntity);
}
break;
case "delete":
request = new HttpDelete(uri);
break;
case "get":
default:
request = new HttpGet(uri);
break;
}
headers.forEach(request::addHeader);
return client.execute(request);
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
return null;
}
use of org.apache.http.client.methods.HttpDelete in project janusgraph by JanusGraph.
the class ElasticSearchMultiTypeIndexTest method clear.
private void clear() throws Exception {
try (final CloseableHttpClient httpClient = HttpClients.createDefault()) {
final HttpHost host = new HttpHost(InetAddress.getByName(esr.getHostname()), ElasticsearchRunner.PORT);
IOUtils.closeQuietly(httpClient.execute(host, new HttpDelete("janusgraph*")));
}
}
use of org.apache.http.client.methods.HttpDelete in project camel by apache.
the class CxfRsConsumerSimpleBindingTest method testDeleteVipCustomer.
@Test
public void testDeleteVipCustomer() throws Exception {
HttpDelete delete = new HttpDelete("http://localhost:" + PORT_PATH + "/rest/customerservice/customers/vip/gold/123");
delete.addHeader("Accept", "text/xml");
HttpResponse response = httpclient.execute(delete);
assertEquals(200, response.getStatusLine().getStatusCode());
}
Aggregations