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


Java HttpHead.setConfig方法代码示例

本文整理汇总了Java中org.apache.http.client.methods.HttpHead.setConfig方法的典型用法代码示例。如果您正苦于以下问题:Java HttpHead.setConfig方法的具体用法?Java HttpHead.setConfig怎么用?Java HttpHead.setConfig使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.http.client.methods.HttpHead的用法示例。


在下文中一共展示了HttpHead.setConfig方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testHeadExternalDatastream

import org.apache.http.client.methods.HttpHead; //导入方法依赖的package包/类
@Test
public void testHeadExternalDatastream() throws IOException, ParseException {
    final String externalContentType = "message/external-body;access-type=URL;url=\"some:uri\"";

    final String id = getRandomUniqueId();
    final HttpPut put = putObjMethod(id);
    put.addHeader(CONTENT_TYPE, externalContentType);
    put.addHeader(LINK, NON_RDF_SOURCE_LINK_HEADER);
    assertEquals(CREATED.getStatusCode(), getStatus(put));

    // Configure HEAD request to NOT follow redirects
    final HttpHead headObjMethod = headObjMethod(id);
    final RequestConfig.Builder requestConfig = RequestConfig.custom();
    requestConfig.setRedirectsEnabled(false);
    headObjMethod.setConfig(requestConfig.build());

    try (final CloseableHttpResponse response = execute(headObjMethod)) {
        assertEquals(TEMPORARY_REDIRECT.getStatusCode(), response.getStatusLine().getStatusCode());
        assertEquals(externalContentType, response.getFirstHeader(CONTENT_TYPE).getValue());
        assertEquals("some:uri", response.getFirstHeader(CONTENT_LOCATION).getValue());
        assertEquals("bytes", response.getFirstHeader("Accept-Ranges").getValue());
        final ContentDisposition disposition =
                new ContentDisposition(response.getFirstHeader(CONTENT_DISPOSITION).getValue());
        assertEquals("attachment", disposition.getType());
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:27,代码来源:FedoraLdpIT.java

示例2: makeHeadRequest

import org.apache.http.client.methods.HttpHead; //导入方法依赖的package包/类
public void makeHeadRequest(String alias, String uri, Map<String, String> headers, Boolean allowRedirects) {
	logger.debug("Making HEAD request");
	HttpHead headRequest = new HttpHead(this.buildUrl(alias, uri));
	headRequest = this.setHeaders(headRequest, headers);
	headRequest.setConfig(RequestConfig.custom().setRedirectsEnabled(allowRedirects).build());
	Session session = this.getSession(alias);
	this.makeRequest(headRequest, session);
}
 
开发者ID:Hi-Fi,项目名称:httpclient,代码行数:9,代码来源:RestClient.java

示例3: doTestUrlExists

import org.apache.http.client.methods.HttpHead; //导入方法依赖的package包/类
private boolean doTestUrlExists(final URI requestUri) {
    try {
        final HttpHead request = new HttpHead(requestUri);
        request.addHeader(new BasicScheme().authenticate(createCredentials(), request, new BasicHttpContext()));
        request.setConfig(createRequestConfig());
        return httpClient.execute(request).getStatusLine().getStatusCode() == HttpStatus.OK.value();
    } catch (final Exception e) {
        LOG.error("Exception, message: " + e.getMessage());
    }
    return false;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:12,代码来源:LukeReportFeature.java

示例4: doHead

import org.apache.http.client.methods.HttpHead; //导入方法依赖的package包/类
public CloseableHttpResponse doHead(String url, int expectedStatusCode)
        throws ClientProtocolException, IOException {
    HttpHead head = new HttpHead(fullURL + url);
    head.setConfig(requestConfig);
    CloseableHttpResponse response = httpClient.execute(targetHost, head, httpClientContext);

    assertStatusCode(expectedStatusCode, response);
    return response;
}
 
开发者ID:WASdev,项目名称:tool.lars,代码行数:10,代码来源:RepositoryContext.java

示例5: doHead

import org.apache.http.client.methods.HttpHead; //导入方法依赖的package包/类
private CloseableHttpResponse doHead(final URL url, final int connectionTimeout, final int readTimeout) throws IOException {
    final RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(readTimeout)
            .setConnectTimeout(connectionTimeout)
            .setAuthenticationEnabled(hasCredentialsConfigured(url))
            .setTargetPreferredAuthSchemes(getAuthSchemePreferredOrder())
            .setProxyPreferredAuthSchemes(getAuthSchemePreferredOrder())
            .build();
    final HttpHead httpHead = new HttpHead(normalizeToString(url));
    httpHead.setConfig(requestConfig);
    return this.httpClient.execute(httpHead);
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:12,代码来源:HttpClientHandler.java

示例6: testHeadExternalDatastreamWithWantDigest

import org.apache.http.client.methods.HttpHead; //导入方法依赖的package包/类
@Test
public void testHeadExternalDatastreamWithWantDigest() throws IOException, ParseException {

    final String dsId = getRandomUniqueId();
    createDatastream(dsId, "x", "01234567890123456789012345678901234567890123456789");

    final String dsUrl = serverAddress + dsId + "/x";
    final String externalContentType = "message/external-body;access-type=URL;url=\"" + dsUrl + "\"";

    final String id = getRandomUniqueId();
    final HttpPut put = putObjMethod(id);
    put.addHeader(CONTENT_TYPE, externalContentType);
    assertEquals(CREATED.getStatusCode(), getStatus(put));

    // Configure HEAD request to NOT follow redirects
    final HttpHead headObjMethod = headObjMethod(id);
    headObjMethod.addHeader(WANT_DIGEST, "sha");
    final RequestConfig.Builder requestConfig = RequestConfig.custom();
    requestConfig.setRedirectsEnabled(false);
    headObjMethod.setConfig(requestConfig.build());

    try (final CloseableHttpResponse response = execute(headObjMethod)) {
        assertEquals(TEMPORARY_REDIRECT.getStatusCode(), response.getStatusLine().getStatusCode());
        assertEquals(externalContentType, response.getFirstHeader(CONTENT_TYPE).getValue());
        assertTrue(response.getHeaders(DIGEST).length > 0);
        final String digesterHeaderValue = response.getHeaders(DIGEST)[0].getValue();
        assertTrue("Fixity Checksum doesn't match",
                digesterHeaderValue.equals("sha=9578f951955d37f20b601c26591e260c1e5389bf"));
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:31,代码来源:FedoraLdpIT.java

示例7: testHeadExternalDatastreamWithWantDigestMultiple

import org.apache.http.client.methods.HttpHead; //导入方法依赖的package包/类
@Test
public void testHeadExternalDatastreamWithWantDigestMultiple() throws IOException, ParseException {

    final String dsId = getRandomUniqueId();
    createDatastream(dsId, "x", "01234567890123456789012345678901234567890123456789");

    final String dsUrl = serverAddress + dsId + "/x";
    final String externalContentType = "message/external-body;access-type=URL;url=\"" + dsUrl + "\"";

    final String id = getRandomUniqueId();
    final HttpPut put = putObjMethod(id);
    put.addHeader(CONTENT_TYPE, externalContentType);
    assertEquals(CREATED.getStatusCode(), getStatus(put));

    // Configure HEAD request to NOT follow redirects
    final HttpHead headObjMethod = headObjMethod(id);
    headObjMethod.addHeader(WANT_DIGEST, "sha, md5;q=0.3");
    final RequestConfig.Builder requestConfig = RequestConfig.custom();
    requestConfig.setRedirectsEnabled(false);
    headObjMethod.setConfig(requestConfig.build());

    try (final CloseableHttpResponse response = execute(headObjMethod)) {
        assertEquals(TEMPORARY_REDIRECT.getStatusCode(), response.getStatusLine().getStatusCode());
        assertEquals(externalContentType, response.getFirstHeader(CONTENT_TYPE).getValue());
        assertTrue(response.getHeaders(DIGEST).length > 0);

        final String digesterHeaderValue = response.getHeaders(DIGEST)[0].getValue();
        assertTrue("SHA-1 Fixity Checksum doesn't match",
                digesterHeaderValue.indexOf("sha=9578f951955d37f20b601c26591e260c1e5389bf") >= 0);
        assertTrue("MD5 fixity checksum doesn't match",
                digesterHeaderValue.indexOf("md5=baed005300234f3d1503c50a48ce8e6f") >= 0);
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:34,代码来源:FedoraLdpIT.java


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