本文整理匯總了Java中org.apache.http.client.methods.HttpPatch.releaseConnection方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpPatch.releaseConnection方法的具體用法?Java HttpPatch.releaseConnection怎麽用?Java HttpPatch.releaseConnection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.client.methods.HttpPatch
的用法示例。
在下文中一共展示了HttpPatch.releaseConnection方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setProperty
import org.apache.http.client.methods.HttpPatch; //導入方法依賴的package包/類
protected HttpResponse setProperty(final String pid, final String txId,
final String propertyUri,
final String value) throws IOException {
final HttpPatch postProp = new HttpPatch(serverAddress
+ (txId != null ? txId + "/" : "") + pid);
postProp.setHeader(CONTENT_TYPE, "application/sparql-update");
final String updateString =
"INSERT { <"
+ serverAddress + pid
+ "> <" + propertyUri + "> \"" + value + "\" } WHERE { }";
postProp.setEntity(new StringEntity(updateString));
final HttpResponse dcResp = execute(postProp);
assertEquals(dcResp.getStatusLine().toString(),
204, dcResp.getStatusLine().getStatusCode());
postProp.releaseConnection();
return dcResp;
}
示例2: patch
import org.apache.http.client.methods.HttpPatch; //導入方法依賴的package包/類
public static TransportResponse patch(TransportTools nuts)
throws ClientProtocolException, IOException {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPatch httppatch = new HttpPatch(nuts.urlString());
if (nuts.headers() != null) {
for (Map.Entry<String, String> headerEntry : nuts.headers().entrySet()) {
httppatch.addHeader(headerEntry.getKey(), headerEntry.getValue());
}
}
if (nuts.pairs() != null && (nuts.contentType() ==null)) {
httppatch.setEntity(new UrlEncodedFormEntity(nuts.pairs()));
}
if (nuts.contentType() !=null) {
httppatch.setEntity(new StringEntity(nuts.contentString(),nuts.contentType()));
}
TransportResponse transportResp = null;
try {
httpclient.execute(httppatch);
//transportResp = new TransportResponse(httpResp.getStatusLine(), httpResp.getEntity(), httpResp.getLocale());
} finally {
httppatch.releaseConnection();
}
return transportResp;
}
示例3: executeUpdateObject
import org.apache.http.client.methods.HttpPatch; //導入方法依賴的package包/類
protected <T> boolean executeUpdateObject(T newObject, String uri) throws BrocadeVcsApiException {
final boolean result = true;
if (_host == null || _host.isEmpty() || _adminuser == null || _adminuser.isEmpty() || _adminpass == null || _adminpass.isEmpty()) {
throw new BrocadeVcsApiException("Hostname/credentials are null or empty");
}
final HttpPatch pm = (HttpPatch)createMethod("patch", uri);
pm.setHeader("Accept", "application/vnd.configuration.resource+xml");
pm.setEntity(new StringEntity(convertToString(newObject), ContentType.APPLICATION_XML));
final HttpResponse response = executeMethod(pm);
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NO_CONTENT) {
String errorMessage;
try {
errorMessage = responseToErrorMessage(response);
} catch (final IOException e) {
s_logger.error("Failed to update object : " + e.getMessage());
throw new BrocadeVcsApiException("Failed to update object : " + e.getMessage());
}
pm.releaseConnection();
s_logger.error("Failed to update object : " + errorMessage);
throw new BrocadeVcsApiException("Failed to update object : " + errorMessage);
}
pm.releaseConnection();
return result;
}
示例4: setProperty
import org.apache.http.client.methods.HttpPatch; //導入方法依賴的package包/類
protected CloseableHttpResponse setProperty(final String id, final String txId, final String propertyUri,
final String value) throws IOException {
final HttpPatch postProp = new HttpPatch(serverAddress + (txId != null ? txId + "/" : "") + id);
postProp.setHeader(CONTENT_TYPE, "application/sparql-update");
final String updateString =
"INSERT { <" + serverAddress + id + "> <" + propertyUri + "> \"" + value + "\" } WHERE { }";
postProp.setEntity(new StringEntity(updateString));
final CloseableHttpResponse dcResp = execute(postProp);
assertEquals(dcResp.getStatusLine().toString(), NO_CONTENT.getStatusCode(), getStatus(dcResp));
postProp.releaseConnection();
return dcResp;
}