本文整理匯總了Java中org.apache.http.client.methods.HttpDelete.setHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpDelete.setHeader方法的具體用法?Java HttpDelete.setHeader怎麽用?Java HttpDelete.setHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.client.methods.HttpDelete
的用法示例。
在下文中一共展示了HttpDelete.setHeader方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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
示例2: del
import org.apache.http.client.methods.HttpDelete; //導入方法依賴的package包/類
/**
* DELETEメソッド.
* @param url リクエスト対象URL
* @param headers リクエストヘッダのハッシュマップ
* @return DcResponse型
* @throws PersoniumException DAO例外
*/
public final PersoniumResponse del(final String url, final HashMap<String, String> headers)
throws PersoniumException {
HttpDelete req = new HttpDelete(url);
for (Map.Entry<String, String> entry : headers.entrySet()) {
req.setHeader(entry.getKey(), entry.getValue());
}
req.addHeader("X-Personium-Version", PersoniumCoreTestConfig.getCoreVersion());
debugHttpRequest(req, "");
return this.request(req);
}
示例3: subscriptionDeleteRequest
import org.apache.http.client.methods.HttpDelete; //導入方法依賴的package包/類
/**
* subscriptionDeleteRequest Method
* Send to Mobius for delete the oneM2M subscription resource
* @param cse
* @param ae
* @param container
* @return
* @throws Exception
*/
public static int subscriptionDeleteRequest(CSEBase cse, AE ae, Subscription subscription) throws Exception {
System.out.println("[&CubeThyme] Subscription \"" + subscription.subname + "\" delete request.......");
URI uri = new URIBuilder()
.setScheme("http")
.setHost(cse.CSEHostAddress + ":" + cse.CSEPort)
.setPath("/" + cse.CSEName + subscription.parentpath + "/" + subscription.subname)
.build();
HttpDelete delete = new HttpDelete(uri);
delete.setHeader("Accept", "application/xml");
delete.setHeader("locale", "ko");
delete.setHeader("X-M2M-Origin", ae.aeId);
delete.setHeader("X-M2M-RI", "nCubeThyme" + Integer.toString(requestId++));
CloseableHttpClient httpClient = HttpClients.createDefault();
HttpResponse response = httpClient.execute(delete);
HttpEntity responseEntity = response.getEntity();
String responseString = EntityUtils.toString(responseEntity);
int responseCode = response.getStatusLine().getStatusCode();
System.out.println("[&CubeThyme] Subscription delete HTTP Response Code : " + responseCode);
System.out.println("[&CubeThyme] Subscription delete HTTP Response String : " + responseString);
httpClient.close();
return responseCode;
}