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


Java HttpEntityEnclosingRequest.addHeader方法代碼示例

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


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

示例1: testSimpleSigner

import org.apache.http.HttpEntityEnclosingRequest; //導入方法依賴的package包/類
@Test
public void testSimpleSigner() throws Exception {
    HttpEntityEnclosingRequest request =
            new BasicHttpEntityEnclosingRequest("GET", "/query?a=b");
    request.setEntity(new StringEntity("I'm an entity"));
    request.addHeader("foo", "bar");
    request.addHeader("content-length", "0");

    HttpCoreContext context = new HttpCoreContext();
    context.setTargetHost(HttpHost.create("localhost"));

    createInterceptor().process(request, context);

    assertEquals("bar", request.getFirstHeader("foo").getValue());
    assertEquals("wuzzle", request.getFirstHeader("Signature").getValue());
    assertNull(request.getFirstHeader("content-length"));
}
 
開發者ID:awslabs,項目名稱:aws-request-signing-apache-interceptor,代碼行數:18,代碼來源:AWSRequestSigningApacheInterceptorTest.java

示例2: testEncodedUriSigner

import org.apache.http.HttpEntityEnclosingRequest; //導入方法依賴的package包/類
@Test
public void testEncodedUriSigner() throws Exception {
    HttpEntityEnclosingRequest request =
            new BasicHttpEntityEnclosingRequest("GET", "/foo-2017-02-25%2Cfoo-2017-02-26/_search?a=b");
    request.setEntity(new StringEntity("I'm an entity"));
    request.addHeader("foo", "bar");
    request.addHeader("content-length", "0");

    HttpCoreContext context = new HttpCoreContext();
    context.setTargetHost(HttpHost.create("localhost"));

    createInterceptor().process(request, context);

    assertEquals("bar", request.getFirstHeader("foo").getValue());
    assertEquals("wuzzle", request.getFirstHeader("Signature").getValue());
    assertNull(request.getFirstHeader("content-length"));
    assertEquals("/foo-2017-02-25%2Cfoo-2017-02-26/_search", request.getFirstHeader("resourcePath").getValue());
}
 
開發者ID:awslabs,項目名稱:aws-request-signing-apache-interceptor,代碼行數:19,代碼來源:AWSRequestSigningApacheInterceptorTest.java

示例3: generate

import org.apache.http.HttpEntityEnclosingRequest; //導入方法依賴的package包/類
public synchronized byte[] generate(QUser user, String uri, HashMap<String, String> params) {
    final HttpEntityEnclosingRequest r = new BasicHttpEntityEnclosingRequest("POST", uri);
    r.addHeader("Cookie", "username=" + user.getName() + "; password=" + user.getPassword());
    final StringBuilder sb = new StringBuilder();
    params.keySet().stream().forEach((st) -> {
        sb.append("&").append(st).append("=").append(params.get(st));
    });
    final InputStream is = new ByteArrayInputStream(sb.substring(1).getBytes());
    final BasicHttpEntity b = new BasicHttpEntity();
    b.setContent(is);
    r.setEntity(b);
    sb.setLength(0);
    return generate(r).getData();
}
 
開發者ID:bcgov,項目名稱:sbc-qsystem,代碼行數:15,代碼來源:QReportsList.java


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