当前位置: 首页>>代码示例>>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;未经允许,请勿转载。