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


Java HttpRequestBase.getMethod方法代碼示例

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


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

示例1: performRequest

import org.apache.http.client.methods.HttpRequestBase; //導入方法依賴的package包/類
public CloseableHttpResponse performRequest(HttpRequestBase request, boolean revalidate) {
    String method = request.getMethod();
    if (revalidate) {
        request.addHeader(HttpHeaders.CACHE_CONTROL, "max-age=0");
    }
    CloseableHttpResponse response;
    try {
        response = executeGetOrHead(request);
    } catch (IOException e) {
        throw new HttpRequestException(String.format("Could not %s '%s'.", method, request.getURI()), e);
    }

    return response;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:15,代碼來源:HttpClientHelper.java

示例2: addRequestBody

import org.apache.http.client.methods.HttpRequestBase; //導入方法依賴的package包/類
private static HttpRequestBase addRequestBody(HttpRequestBase httpRequest, HttpEntity entity) {
    if (entity != null) {
        if (httpRequest instanceof HttpEntityEnclosingRequestBase) {
            ((HttpEntityEnclosingRequestBase)httpRequest).setEntity(entity);
        } else {
            throw new UnsupportedOperationException(httpRequest.getMethod() + " with body is not supported");
        }
    }
    return httpRequest;
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,代碼來源:RestClient.java

示例3: getWire

import org.apache.http.client.methods.HttpRequestBase; //導入方法依賴的package包/類
/**
 * method to get the wire.
 * @param method
 * @param responseBody
 * @param headerString
 * @param responseStatus
 * @param subTests
 * @return
 * @throws ComplianceException
 */
public static Wire getWire(HttpRequestBase method, String responseBody,
                           String headerString, String responseStatus,
                           ArrayList<String> subTests) throws ComplianceException {

    StringBuffer toServer = new StringBuffer();
    StringBuffer fromServer = new StringBuffer();
    StringBuffer subTestsPerformed = new StringBuffer();

    toServer.append(method.getRequestLine().getMethod()).append(" ");
    toServer.append(method.getRequestLine().getUri()+"\n");
    toServer.append(method.getRequestLine().getProtocolVersion().getProtocol());
    for (org.apache.http.Header header : method.getAllHeaders()) {
        toServer.append(header.getName()).append(": ").append(header.getValue()).append("\n");
    }

    if(method.getMethod() != "GET" && method.getMethod() != "DELETE"){
        try {
            HttpEntity entity = ((HttpEntityEnclosingRequest)method).getEntity();
            toServer.append(EntityUtils.toString(entity));
        } catch (Exception e) {
            throw new ComplianceException(500, "Error in getting the request payload");
        }
    }
    fromServer.append("\n" + "Headers : ");
    fromServer.append(headerString + "\n");
    fromServer.append("\n" + "Status : ");
    fromServer.append(responseStatus + "\n");
    fromServer.append("\n" + responseBody);
    for (String subTest : subTests) {
        subTestsPerformed.append(subTest).append("\n");
    }
    return new Wire(toServer.toString(), fromServer.toString(), subTestsPerformed.toString());
}
 
開發者ID:wso2-incubator,項目名稱:scim2-compliance-test-suite,代碼行數:44,代碼來源:ComplianceUtils.java


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