本文整理汇总了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;
}