當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpMethod.getResponseHeader方法代碼示例

本文整理匯總了Java中org.apache.commons.httpclient.HttpMethod.getResponseHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpMethod.getResponseHeader方法的具體用法?Java HttpMethod.getResponseHeader怎麽用?Java HttpMethod.getResponseHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.httpclient.HttpMethod的用法示例。


在下文中一共展示了HttpMethod.getResponseHeader方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendRemoteRequest

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
/**
 * Send Request to the repository
 */
protected HttpMethod sendRemoteRequest(Request req) throws AuthenticationException, IOException
{
    if (logger.isDebugEnabled())
    {
        logger.debug("");
        logger.debug("* Request: " + req.getMethod() + " " + req.getFullUri() + (req.getBody() == null ? "" : "\n" + new String(req.getBody(), "UTF-8")));
    }

    HttpMethod method = createMethod(req);

    // execute method
    executeMethod(method);

    // Deal with redirect
    if(isRedirect(method))
    {
        Header locationHeader = method.getResponseHeader("location");
        if (locationHeader != null)
        {
            String redirectLocation = locationHeader.getValue();
            method.setURI(new URI(redirectLocation, true));
            httpClient.executeMethod(method);
        }
    }

    return method;
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:31,代碼來源:AbstractHttpClient.java

示例2: getResponseMac

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
/**
 * Get the MAC (Message Authentication Code) on the HTTP response
 * 
 * @param res HttpMethod
 * @return the MAC
 * @throws IOException
 */
protected byte[] getResponseMac(HttpMethod res) throws IOException
{
    Header header = res.getResponseHeader(HEADER_MAC);
    if(header != null)
    {
        return Base64.decode(header.getValue());
    }
    else
    {
        return null;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:20,代碼來源:DefaultEncryptionUtils.java

示例3: getResponseTimestamp

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
/**
 * Get the timestamp on the HTTP response
 * 
 * @param method HttpMethod
 * @return timestamp (ms, in UNIX time)
 * @throws IOException
 */
protected Long getResponseTimestamp(HttpMethod method) throws IOException
{
    Header header = method.getResponseHeader(HEADER_TIMESTAMP);
    if(header != null)
    {
        return Long.valueOf(header.getValue());
    }
    else
    {
        return null;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:20,代碼來源:DefaultEncryptionUtils.java

示例4: decodeAlgorithmParameters

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
/**
 * Decode cipher algorithm parameters from the HTTP method
 * 
 * @param method HttpMethod
 * @return decoded algorithm parameters
 * @throws IOException
 */
protected AlgorithmParameters decodeAlgorithmParameters(HttpMethod method) throws IOException
{
    Header header = method.getResponseHeader(HEADER_ALGORITHM_PARAMETERS);
    if(header != null)
    {
        byte[] algorithmParams = Base64.decode(header.getValue());
        AlgorithmParameters algorithmParameters  = encryptor.decodeAlgorithmParameters(algorithmParams);
        return algorithmParameters;
    }
    else
    {
        return null;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-core,代碼行數:22,代碼來源:DefaultEncryptionUtils.java

示例5: executeRequest

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
/**
 * Will create the method and execute it. After this the method is sent to a
 * ResponseHandler that is returned.
 * 
 * @param httpRequest
 *            Request we are receiving from the client
 * @param url
 *            The location we are proxying to
 * @return A ResponseHandler that can be used to write the response
 * @throws MethodNotAllowedException
 *             If the method specified by the request isn't handled
 * @throws IOException
 *             When there is a problem with the streams
 * @throws HttpException
 *             The httpclient can throw HttpExcetion when executing the
 *             method
 */
ResponseHandler executeRequest(HttpServletRequest httpRequest, String url)
        throws MethodNotAllowedException, IOException, HttpException {
    RequestHandler requestHandler = RequestHandlerFactory
            .createRequestMethod(httpRequest.getMethod());

    HttpMethod method = requestHandler.process(httpRequest, url);
    method.setFollowRedirects(false);

    /*
     * Why does method.validate() return true when the method has been
     * aborted? I mean, if validate returns true the API says that means
     * that the method is ready to be executed. TODO I don't like doing type
     * casting here, see above.
     */
    if (!((HttpMethodBase) method).isAborted()) {
        httpClient.executeMethod(method);

        if (method.getStatusCode() == 405) {
            Header allow = method.getResponseHeader("allow");
            String value = allow.getValue();
            throw new MethodNotAllowedException(
                    "Status code 405 from server",
                    AllowedMethodHandler.processAllowHeader(value));
        }
    }

    return ResponseHandlerFactory.createResponseHandler(method);
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:46,代碼來源:ProxyFilter.java

示例6: getContentType

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
protected String getContentType(final HttpMethod method) {
    final Header header = method.getResponseHeader("Content-Type");
    if (header != null) {
        final String contentType = header.getValue();
        if (contentType != null && !contentType.isEmpty()) {
            return contentType.toLowerCase(Locale.ENGLISH);
        }
    }
    return EMPTY;
}
 
開發者ID:jhkst,項目名稱:dlface,代碼行數:11,代碼來源:DefaultFileStreamRecognizer.java

示例7: assertResponseHeader

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
private void assertResponseHeader(HttpMethod m, String name, String expectedRegex) {
    final Header h = m.getResponseHeader(name);
    assertNotNull("Expecting header " + name, h);
    final String value = h.getValue();
    assertTrue("Expected regexp " + expectedRegex + " for header " + name + ", header value is " + value,
            Pattern.matches(expectedRegex, value));
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-launchpad-integration-tests,代碼行數:8,代碼來源:HeadServletTest.java

示例8: assertXReason

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
private void assertXReason(final HttpMethod method) throws IOException {
    // expected the X-Reason header
    final Header reason = method.getResponseHeader("X-Reason");
    assertNotNull(reason);

    // expect the response to be the same as the reason (SLING-1831)
    assertEquals(reason.getValue(), method.getResponseBodyAsString().trim());
}
 
開發者ID:apache,項目名稱:sling-org-apache-sling-launchpad-integration-tests,代碼行數:9,代碼來源:AuthenticationResponseCodeTest.java

示例9: readHTTPImage

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的package包/類
private static BufferedImage readHTTPImage(URI uri,
		HostConfiguration hostConfiguration, HttpClient client,
		ConnectionWrapper wrapper) {
	List<Proxy> list = ProxySelector.getDefault().select(uri);
	for (Proxy p : list)
	{
		InetSocketAddress addr = (InetSocketAddress) p.address();
		
		if (addr == null)
			hostConfiguration.setProxyHost(null);
		else
			hostConfiguration.setProxy(addr.getHostName(), addr.getPort());
		
		try {
			HttpMethod method = new GetMethod(uri.toString());
			synchronized (wrapper) {
				wrapper.connection = method;
			}
			
			int sc = client.executeMethod(hostConfiguration, method);
			
			if (sc != HttpStatus.SC_OK) {
				continue;
			}
			
			// Check Content Type
			Header h = method.getResponseHeader("Content-Type");
			if (h == null || !h.getValue().contains("image")) 
				continue;
			
			return ImageIO.read( method.getResponseBodyAsStream() );
		} catch (IOException ex) {
			continue;
		}
	}
	return null;
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:38,代碼來源:Tile512Overlay.java

示例10: doEnd

import org.apache.commons.httpclient.HttpMethod; //導入方法依賴的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];

        rc = 0;

        responseState = e.toString();
    }
    else {
        HttpMethod method = (HttpMethod) args[0];

        Header sheader = method.getResponseHeader("Server");

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

        rc = 1;
        responseState = method.getStatusLine().getStatusCode() + "";
    }

    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_APPID, this.applicationId);
    params.put(CaptureConstants.INFO_CLIENT_TYPE, "apache.http.Client");
    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,
            ApacheHttpClient3Adapter.class, args);

}
 
開發者ID:uavorg,項目名稱:uavstack,代碼行數:59,代碼來源:ApacheHttpClient3IT.java


注:本文中的org.apache.commons.httpclient.HttpMethod.getResponseHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。