use of org.apache.http.client.methods.HttpHead in project android-volley by mcxiaoke.
the class HttpClientStackTest method createHeadRequest.
@Test
public void createHeadRequest() throws Exception {
TestRequest.Head request = new TestRequest.Head();
assertEquals(request.getMethod(), Method.HEAD);
HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
assertTrue(httpRequest instanceof HttpHead);
}
use of org.apache.http.client.methods.HttpHead in project FastDev4Android by jiangqqlmj.
the class HttpClientStackTest method createHeadRequest.
@Test
public void createHeadRequest() throws Exception {
TestRequest.Head request = new TestRequest.Head();
assertEquals(request.getMethod(), Method.HEAD);
HttpUriRequest httpRequest = HttpClientStack.createHttpRequest(request, null);
assertTrue(httpRequest instanceof HttpHead);
}
use of org.apache.http.client.methods.HttpHead in project openolat by klemens.
the class CertificationTest method getCertificate_head.
@Test
public void getCertificate_head() throws IOException, URISyntaxException {
RestConnection conn = new RestConnection();
Assert.assertTrue(conn.login("administrator", "openolat"));
Identity assessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("cert-11");
Identity unassessedIdentity = JunitTestHelper.createAndPersistIdentityAsRndUser("cert-12");
Identity author = JunitTestHelper.createAndPersistIdentityAsAuthor("cert-2");
RepositoryEntry entry = JunitTestHelper.deployBasicCourse(author);
CertificateInfos certificateInfos = new CertificateInfos(assessedIdentity, 2.0f, true);
Certificate certificate = certificatesManager.generateCertificate(certificateInfos, entry, null, false);
dbInstance.commitAndCloseSession();
Assert.assertNotNull(certificate);
sleep(1000);
URI uri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").path(entry.getOlatResource().getKey().toString()).path("certificates").path(assessedIdentity.getKey().toString()).build();
HttpHead method = conn.createHead(uri, "application/pdf", true);
HttpResponse response = conn.execute(method);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
EntityUtils.consume(response.getEntity());
// check with a stupid number
URI nonExistentUri = UriBuilder.fromUri(getContextURI()).path("repo").path("courses").path(entry.getOlatResource().getKey().toString()).path("certificates").path(unassessedIdentity.getKey().toString()).build();
HttpHead nonExistentMethod = conn.createHead(nonExistentUri, "application/pdf", true);
HttpResponse nonExistentResponse = conn.execute(nonExistentMethod);
Assert.assertEquals(404, nonExistentResponse.getStatusLine().getStatusCode());
EntityUtils.consume(nonExistentResponse.getEntity());
conn.shutdown();
}
use of org.apache.http.client.methods.HttpHead in project openolat by klemens.
the class WebDAVConnection method head.
public HttpResponse head(URI uri) throws IOException, URISyntaxException {
HttpHead propfind = new HttpHead(uri);
HttpResponse response = execute(propfind);
Assert.assertEquals(200, response.getStatusLine().getStatusCode());
return response;
}
use of org.apache.http.client.methods.HttpHead in project hazelcast by hazelcast.
the class HTTPCommunicator method doHead.
private ConnectionResponse doHead(String url) throws IOException {
CloseableHttpClient client = newClient();
CloseableHttpResponse response = null;
try {
HttpHead request = new HttpHead(url);
response = client.execute(request);
return new ConnectionResponse(response);
} finally {
IOUtil.closeResource(response);
IOUtil.closeResource(client);
}
}
Aggregations