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


Java HttpResponse.getLastHeader方法代码示例

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


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

示例1: doResponseRedirectOrNotModifiedLogic

import org.apache.http.HttpResponse; //导入方法依赖的package包/类
protected boolean doResponseRedirectOrNotModifiedLogic(HttpServletRequest servletRequest, HttpServletResponse servletResponse,
        HttpResponse proxyResponse, int statusCode) throws ServletException, IOException {
    // Check if the proxy response is a redirect
    // The following code is adapted from org.tigris.noodle.filters.CheckForRedirect
    if (statusCode >= HttpServletResponse.SC_MULTIPLE_CHOICES /* 300 */
            && statusCode < HttpServletResponse.SC_NOT_MODIFIED /* 304 */) {
        Header locationHeader = proxyResponse.getLastHeader(HttpHeaders.LOCATION);
        if (locationHeader == null) {
            throw new ServletException(
                    "Received status code: " + statusCode + " but no " + HttpHeaders.LOCATION + " header was found in the response");
        }
        // Modify the redirect to go to this proxy servlet rather that the proxied host
        String locStr = rewriteUrlFromResponse(servletRequest, locationHeader.getValue());

        servletResponse.sendRedirect(locStr);
        return true;
    }
    // 304 needs special handling. See:
    // http://www.ics.uci.edu/pub/ietf/http/rfc1945.html#Code304
    // We get a 304 whenever passed an 'If-Modified-Since'
    // header and the data on disk has not changed; server
    // responds w/ a 304 saying I'm not going to send the
    // body because the file has not changed.
    if (statusCode == HttpServletResponse.SC_NOT_MODIFIED) {
        servletResponse.setIntHeader(HttpHeaders.CONTENT_LENGTH, 0);
        servletResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
        return true;
    }
    return false;
}
 
开发者ID:bluecreator,项目名称:http-agent,代码行数:31,代码来源:AgentServlet.java

示例2: registerClients

import org.apache.http.HttpResponse; //导入方法依赖的package包/类
public void registerClients() throws Exception
{
	// Create OAuth client-credentials clients
	final List<OAuthClient> oauthClients = getOAuthClients();
	for( OAuthClient clientInfo : oauthClients )
	{
		ObjectNode oauthclient = mapper.createObjectNode();
		oauthclient.put("name", clientInfo.getName());
		oauthclient.put("clientId", clientInfo.getClientId());
		String secret = clientInfo.getSecret();
		if( Check.isEmpty(secret) )
		{
			secret = UUID.randomUUID().toString();
			clientInfo.setSecret(secret);
		}
		oauthclient.put("clientSecret", secret);
		oauthclient.put("userId", clientInfo.getUserId());
		String redirectUrl = clientInfo.getUrl();
		if( Check.isEmpty(redirectUrl) )
		{
			redirectUrl = "default";
			clientInfo.setUrl(redirectUrl);
		}
		oauthclient.put("redirectUrl", redirectUrl);
		clients.add(clientInfo);
		HttpResponse postResponse = postEntity(oauthclient.toString(), context.getBaseUrl() + "api/oauth",
			adminToken, true);
		Header postHeader = postResponse.getLastHeader("Location");
		if( postHeader == null )
		{
			throw new RuntimeException("POST response did not contain 'Location' in header (code: "
				+ postResponse.getStatusLine().getStatusCode() + ')');
		}
		String clientUri = postHeader.getValue();
		JsonNode entity = getEntity(clientUri, adminToken);
		clientInfo.setUuid(entity.get("uuid").asText());
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:39,代码来源:AbstractRestApiTest.java

示例3: getLocation

import org.apache.http.HttpResponse; //导入方法依赖的package包/类
private String getLocation(HttpResponse response)
{
	Header lastHeader = response.getLastHeader("Location");
	if( lastHeader != null )
	{
		return lastHeader.getValue();
	}
	return null;
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:OAuthTest.java

示例4: checkAccountLocked

import org.apache.http.HttpResponse; //导入方法依赖的package包/类
private static void checkAccountLocked(HttpResponse response) {
    Header header = response.getLastHeader("X-Authentication-Denied-Reason");
    if (header != null) {
        String info = Objects.toString(header.getValue(), "").trim();
        throw new AccessControlException("Your account seems to be locked" + (info.isEmpty() ? "" : ": " + info));
    }
}
 
开发者ID:pascalgn,项目名称:jiracli,代码行数:8,代码来源:HttpClient.java

示例5: doEnd

import org.apache.http.HttpResponse; //导入方法依赖的package包/类
/**
 * for http client
 * 
 * @param args
 * @return
 */
public void doEnd(Object[] args) {

    Map<String, Object> params = new HashMap<String, Object>();

    String server = "";

    int rc = -1;

    String responseState = "";

    if (Throwable.class.isAssignableFrom(args[0].getClass())) {

        Throwable e = (Throwable) args[0];

        responseState = e.toString();
    }
    else {
        HttpResponse response = (HttpResponse) args[0];

        Header sheader = response.getLastHeader("Server");

        if (sheader != null) {
            server = sheader.getValue();
        }

        responseState = response.getStatusLine().getStatusCode() + "";

        rc = 1;
    }

    if (logger.isDebugable()) {
        logger.debug("Invoke END:" + rc + "," + server, null);
    }

    params.put(CaptureConstants.INFO_CLIENT_TARGETSERVER, server);
    params.put(CaptureConstants.INFO_CLIENT_RESPONSECODE, rc);
    params.put(CaptureConstants.INFO_CLIENT_TYPE, "apache.http.Client");
    params.put(CaptureConstants.INFO_CLIENT_APPID, this.applicationId);
    params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, targetURl);
    params.put(CaptureConstants.INFO_CLIENT_RESPONSESTATE, responseState);

    UAVServer.instance().runMonitorCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT,
            Monitor.CapturePhase.DOCAP, params);

    if (ivcContextParams != null) {
        ivcContextParams.putAll(params);
    }

    UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap",
            InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.DOCAP, ivcContextParams,
            ApacheHttpClientAdapter.class, args);
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:59,代码来源:ApacheHttpClientIT.java


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