当前位置: 首页>>代码示例>>Java>>正文


Java HttpDelete类代码示例

本文整理汇总了Java中org.apache.http.client.methods.HttpDelete的典型用法代码示例。如果您正苦于以下问题:Java HttpDelete类的具体用法?Java HttpDelete怎么用?Java HttpDelete使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpDelete类属于org.apache.http.client.methods包,在下文中一共展示了HttpDelete类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIntegrityUnicityError

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
/**
 * @see ExceptionMapperResource#throwDataIntegrityUnicityException()
 */
@Test
public void testIntegrityUnicityError() throws IOException {
	final HttpDelete httpdelete = new HttpDelete(BASE_URI + RESOURCE + "/integrity-unicity");
	HttpResponse response = null;
	try {
		response = httpclient.execute(httpdelete);
		Assert.assertEquals(HttpStatus.SC_PRECONDITION_FAILED, response.getStatusLine().getStatusCode());
		final String content = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
		final Map<?, ?> result = new ObjectMapperTrim().readValue(content, HashMap.class);
		Assert.assertEquals("integrity-unicity", result.get("code"));
		Assert.assertNull(result.get("cause"));
		Assert.assertEquals("2003/PRIMARY", result.get("message"));
	} finally {
		if (response != null) {
			response.getEntity().getContent().close();
		}
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:22,代码来源:ExceptionMapperIT.java

示例2: delete

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
private void delete(String url) throws IOException, HttpException {
	CredentialsProvider credentials = credentialsProvider();
	CloseableHttpClient httpclient = HttpClients.custom()
               .setDefaultCredentialsProvider(credentials)
               .build();

	try {
		HttpDelete httpDelete = new HttpDelete(url);
 		httpDelete.setHeader("Accept", "application/json");
	        
	    System.out.println("Executing request " + httpDelete.getRequestLine());
	    CloseableHttpResponse response = httpclient.execute(httpDelete);
	    try {
	        LOG.debug("----------------------------------------");
	        LOG.debug((String)response.getStatusLine().getReasonPhrase());
	    } finally {
	        response.close();
	    }
	} finally {
	    httpclient.close();
	}
}
 
开发者ID:dellemc-symphony,项目名称:ticketing-service-paqx-parent-sample,代码行数:23,代码来源:TicketingIntegrationService.java

示例3: sendHttpDelete

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
@Override
public CloseableHttpResponse sendHttpDelete(String url, List<Header> headers) {
    CloseableHttpResponse execute = null;
    try {
        LOGGER.info("Sending GET request to url-" + url);
        CloseableHttpClient httpClient = this.httpClientFactory.getHttpClient();
        HttpDelete httpDelete = new HttpDelete(url);
        if (headers != null && !headers.isEmpty()) {
            for (Header header : headers) {
                httpDelete.addHeader(header);
            }
        }
        execute = httpClient.execute(httpDelete);
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, "Was unable to send Get request to url-" + url, e);
    }

    return execute;
}
 
开发者ID:SoftGorilla,项目名称:restheart-java-client,代码行数:20,代码来源:HttpConnectionUtils.java

示例4: sendDeleteCommand

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
/**
 * sendDeleteCommand
 *
 * @param url
 * @return
 */
public Map<String, String> sendDeleteCommand(String url, Map<String, Object> credentials)
        throws ManagerResponseException {
    Map<String, String> response = new HashMap<String, String>();
    CloseableHttpClient httpclient = HttpClients.createDefault();

    HttpDelete httpDelete = new HttpDelete(url);
    CloseableHttpResponse httpResponse;
    try {
        httpResponse = httpclient.execute(httpDelete, localContext);
        ResponseHandler<String> handler = new CustomResponseErrorHandler();
        String body = handler.handleResponse(httpResponse);
        response.put("body", body);
        httpResponse.close();
    } catch (Exception e) {
        throw new ManagerResponseException(e.getMessage(), e);
    }

    return response;
}
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:26,代码来源:RestUtils.java

示例5: sendDelete

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
public DockerResponse sendDelete(URI uri, Boolean httpRequired) throws JSONClientException {

        if (logger.isDebugEnabled()) {
            logger.debug("Send a delete request to : " + uri);
        }
        CloseableHttpResponse response = null;
        try {
            CloseableHttpClient httpClient = buildSecureHttpClient();
            HttpDelete httpDelete = new HttpDelete(uri);
            response = httpClient.execute(httpDelete);
        } catch (IOException e) {
            throw new JSONClientException("Error in sendDelete method due to : " + e.getMessage(), e);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Status code : " + response.getStatusLine().getStatusCode());
        }

        return new DockerResponse(response.getStatusLine().getStatusCode(), "");
    }
 
开发者ID:oncecloud,项目名称:devops-cstack,代码行数:21,代码来源:JSONClient.java

示例6: assertNotFound

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
private void assertNotFound(final String path, final String message) throws IOException, ClientProtocolException, JsonParseException, JsonMappingException {
	final HttpDelete httpdelete = new HttpDelete(BASE_URI + RESOURCE + path);
	HttpResponse response = null;
	try {
		response = httpclient.execute(httpdelete);
		Assert.assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatusLine().getStatusCode());
		final String content = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
		final Map<?, ?> result = new ObjectMapperTrim().readValue(content, HashMap.class);
		Assert.assertEquals("entity", result.get("code"));
		Assert.assertEquals(message, result.get("message"));
		Assert.assertNull(result.get("cause"));
	} finally {
		if (response != null) {
			response.getEntity().getContent().close();
		}
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:18,代码来源:ExceptionMapperIT.java

示例7: testCannotAcquireLockException

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
/**
 * @see ExceptionMapperResource#throwCannotAcquireLockException()
 */
@Test
public void testCannotAcquireLockException() throws IOException {
	final HttpDelete httpdelete = new HttpDelete(BASE_URI + RESOURCE + "/cannotAcquireLockException");
	HttpResponse response = null;
	try {
		response = httpclient.execute(httpdelete);
		Assert.assertEquals(HttpStatus.SC_CONFLICT, response.getStatusLine().getStatusCode());
		final String content = IOUtils.toString(response.getEntity().getContent(), StandardCharsets.UTF_8);
		final Map<?, ?> result = new ObjectMapperTrim().readValue(content, HashMap.class);
		Assert.assertEquals("database-lock", result.get("code"));
		Assert.assertNull(result.get("message"));
		Assert.assertNull(result.get("cause"));
	} finally {
		if (response != null) {
			response.getEntity().getContent().close();
		}
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:22,代码来源:ExceptionMapperIT.java

示例8: getRequest

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
private HttpRequestBase getRequest(String url){
	switch(method){
	case DELETE:
		return new HttpDelete(url);
	case GET:
		return new HttpGet(url);
	case HEAD:
		return new HttpHead(url);
	case PATCH:
		return new HttpPatch(url);
	case POST:
		return new HttpPost(url);
	case PUT:
		return new HttpPut(url);
	default:
		throw new IllegalArgumentException("Invalid or null HttpMethod: " + method);
	}
}
 
开发者ID:hotpads,项目名称:datarouter,代码行数:19,代码来源:DatarouterHttpRequest.java

示例9: createApacheRequest

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
private HttpRequestBase createApacheRequest(SdkHttpFullRequest request, String uri) {
    switch (request.method()) {
        case HEAD:
            return new HttpHead(uri);
        case GET:
            return new HttpGet(uri);
        case DELETE:
            return new HttpDelete(uri);
        case OPTIONS:
            return new HttpOptions(uri);
        case PATCH:
            return wrapEntity(request, new HttpPatch(uri));
        case POST:
            return wrapEntity(request, new HttpPost(uri));
        case PUT:
            return wrapEntity(request, new HttpPut(uri));
        default:
            throw new RuntimeException("Unknown HTTP method name: " + request.method());
    }
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:21,代码来源:ApacheHttpRequestFactory.java

示例10: delete

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
static Request delete(DeleteRequest deleteRequest) {
    String endpoint = endpoint(deleteRequest.index(), deleteRequest.type(), deleteRequest.id());

    Params parameters = Params.builder();
    parameters.withRouting(deleteRequest.routing());
    parameters.withParent(deleteRequest.parent());
    parameters.withTimeout(deleteRequest.timeout());
    parameters.withVersion(deleteRequest.version());
    parameters.withVersionType(deleteRequest.versionType());
    parameters.withRefreshPolicy(deleteRequest.getRefreshPolicy());
    parameters.withWaitForActiveShards(deleteRequest.waitForActiveShards());

    return new Request(HttpDelete.METHOD_NAME, endpoint, parameters.getParams(), null);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:Request.java

示例11: doDelete

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
@Override
public Response doDelete(final URL url, final Set<RequestHeader> headers) throws IOException {
    final HttpDelete request = new HttpDelete(url.toString());
    for(RequestHeader header : headers) {
        if(header.getKey().equals(HTTP.TRANSFER_ENCODING)) {
            continue;
        }
        if(header.getKey().equals(HTTP.CONTENT_LEN)) {
            continue;
        }
        request.addHeader(new BasicHeader(header.getKey(), header.getValue()));
    }
    final CloseableHttpResponse response = client.execute(request);
    return new CommonsHttpResponse(response);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:16,代码来源:OneDriveCommonsHttpRequestExecutor.java

示例12: deleteRESTUser

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
public static void deleteRESTUser(String usrName){
	try{
		DefaultHttpClient client = new DefaultHttpClient();

		client.getCredentialsProvider().setCredentials(
				new AuthScope(host, 8002),
				new UsernamePasswordCredentials("admin", "admin"));

		HttpDelete delete = new HttpDelete("http://"+host+":8002/manage/v2/users/"+usrName);

		HttpResponse response = client.execute(delete);
		if(response.getStatusLine().getStatusCode()== 202){
			Thread.sleep(3500);
		}
	}catch (Exception e) {
		// writing error to Log
		e.printStackTrace();
	}

}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:21,代码来源:ConnectedRESTQA.java

示例13: deleteUserRole

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
public static void deleteUserRole(String roleName){
	try{
		DefaultHttpClient client = new DefaultHttpClient();

		client.getCredentialsProvider().setCredentials(
				new AuthScope(host, 8002),
				new UsernamePasswordCredentials("admin", "admin"));

		HttpDelete delete = new HttpDelete("http://"+host+":8002/manage/v2/roles/"+roleName);

		HttpResponse response = client.execute(delete);
		if(response.getStatusLine().getStatusCode()== 202){
			Thread.sleep(3500);
		}
	}catch (Exception e) {
		// writing error to Log
		e.printStackTrace();
	}

}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:21,代码来源:ConnectedRESTQA.java

示例14: deleteRESTServerWithDB

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
public static void deleteRESTServerWithDB(String restServerName)	{
	try{
		DefaultHttpClient client = new DefaultHttpClient();

		client.getCredentialsProvider().setCredentials(
				new AuthScope(host, 8002),
				new UsernamePasswordCredentials("admin", "admin"));

		HttpDelete delete = new HttpDelete("http://"+host+":8002/v1/rest-apis/"+restServerName+"?include=content&include=modules");

		HttpResponse response = client.execute(delete);
		if(response.getStatusLine().getStatusCode()== 202){
			Thread.sleep(9500);
		}
	}catch (Exception e) {
		// writing error to Log
		e.printStackTrace();
	}
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:20,代码来源:ConnectedRESTQA.java

示例15: deleteRESTServer

import org.apache.http.client.methods.HttpDelete; //导入依赖的package包/类
public static void deleteRESTServer(String restServerName)	{
	try{
		DefaultHttpClient client = new DefaultHttpClient();

		client.getCredentialsProvider().setCredentials(
				new AuthScope(host, 8002),
				new UsernamePasswordCredentials("admin", "admin"));

		HttpDelete delete = new HttpDelete("http://"+host+":8002/v1/rest-apis/"+restServerName+"&include=modules");
		HttpResponse response = client.execute(delete);

		if(response.getStatusLine().getStatusCode()== 202){
			Thread.sleep(3500);
			waitForServerRestart();
		}
		else System.out.println("Server response "+response.getStatusLine().getStatusCode());
	}catch (Exception e) {
		// writing error to Log
		System.out.println("Inside Deleting Rest server is throwing an error");
		e.printStackTrace();
	}
}
 
开发者ID:marklogic,项目名称:marklogic-rdf4j,代码行数:23,代码来源:ConnectedRESTQA.java


注:本文中的org.apache.http.client.methods.HttpDelete类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。