本文整理汇总了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();
}