本文整理了Java中org.jclouds.http.HttpRequest.getFirstHeaderOrNull()
方法的一些代码示例,展示了HttpRequest.getFirstHeaderOrNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getFirstHeaderOrNull()
方法的具体详情如下:
包路径:org.jclouds.http.HttpRequest
类名称:HttpRequest
方法名:getFirstHeaderOrNull
暂无
代码示例来源:origin: jclouds/legacy-jclouds
@Override
public String createStringToSign(HttpRequest input) {
return input.getFirstHeaderOrNull(DATE);
}
代码示例来源:origin: Nextdoor/bender
@Override
public AdaptTempAuthResponseToAccess setContext(HttpRequest request) {
String host = request.getEndpoint().getHost();
this.host = host;
this.username = request.getFirstHeaderOrNull(identityHeaderNameUser);
return this;
}
}
代码示例来源:origin: Nextdoor/bender
private String createStringToSign(HttpRequest request, long expires) {
utils.logRequest(signatureLog, request, ">>");
StringBuilder buffer = new StringBuilder();
buffer.append(request.getMethod()).append("\n");
buffer.append(Strings.nullToEmpty(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_MD5))).append("\n");
buffer.append(Strings.nullToEmpty(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE))).append("\n");
buffer.append(String.valueOf(expires)).append("\n");
// TODO: extension headers
buffer.append(request.getEndpoint().getPath());
return buffer.toString();
}
}
代码示例来源:origin: apache/jclouds
private String createStringToSign(HttpRequest request, long expires) {
utils.logRequest(signatureLog, request, ">>");
StringBuilder buffer = new StringBuilder();
buffer.append(request.getMethod()).append("\n");
buffer.append(Strings.nullToEmpty(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_MD5))).append("\n");
buffer.append(Strings.nullToEmpty(request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE))).append("\n");
buffer.append(String.valueOf(expires)).append("\n");
// TODO: extension headers
buffer.append(request.getEndpoint().getPath());
return buffer.toString();
}
}
代码示例来源:origin: org.apache.jclouds.api/atmos
@VisibleForTesting
void appendHttpHeaders(HttpRequest request, StringBuilder toSign) {
// Only the value is used, not the header
// name. If a request does not include the header, this is an empty string.
toSign.append(HttpUtils.nullToEmpty(request.getHeaders().get("Range")).toLowerCase()).append("\n");
// Standard HTTP header, in UTC format. Only the date value is used, not the header name.
toSign.append(request.getFirstHeaderOrNull(HttpHeaders.DATE)).append("\n");
}
代码示例来源:origin: jclouds/legacy-jclouds
@VisibleForTesting
void appendHttpHeaders(HttpRequest request, StringBuilder toSign) {
// Only the value is used, not the header
// name. If a request does not include the header, this is an empty string.
for (String header : new String[] { "Range" })
toSign.append(HttpUtils.nullToEmpty(request.getHeaders().get(header)).toLowerCase()).append("\n");
// Standard HTTP header, in UTC format. Only the date value is used, not the header name.
toSign.append(request.getFirstHeaderOrNull(HttpHeaders.DATE)).append("\n");
}
代码示例来源:origin: Nextdoor/bender
@VisibleForTesting
void appendHttpHeaders(HttpRequest request, StringBuilder toSign) {
// Only the value is used, not the header
// name. If a request does not include the header, this is an empty string.
toSign.append(HttpUtils.nullToEmpty(request.getHeaders().get("Range")).toLowerCase()).append("\n");
// Standard HTTP header, in UTC format. Only the date value is used, not the header name.
toSign.append(request.getFirstHeaderOrNull(HttpHeaders.DATE)).append("\n");
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
void testAddsSecurityToken() {
HttpRequest filtered = filter(temporaryCredentials).filter(bucketFooExists);
assertEquals(filtered.getFirstHeaderOrNull("Authorization"),
"AWS AKIAIOSFODNN7EXAMPLE:0fUhWTaRBcIvIAndg2C+5eLfE24=");
assertEquals(filtered.getFirstHeaderOrNull("x-amz-security-token"), temporaryCredentials.getSessionToken());
}
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
void testFilterReplacesOldValues() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
HttpRequest request = newRequest(inputHeaders().put(AtmosHeaders.SIGNATURE, "foo")
.put(HttpHeaders.DATE, "foo").put(AtmosHeaders.DATE, "foo").put(AtmosHeaders.UID, "foo")
.build());
request = filter.filter(request);
assertEquals(request.getFirstHeaderOrNull(AtmosHeaders.SIGNATURE), EXPECTED_SIGNATURE);
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testApply() {
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = filter.filter(request);
assertEquals(request.getHeaders().size(), 2);
assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token");
assertEquals(request.getFirstHeaderOrNull("x-vcloud-authorization"), "token");
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
void testFilter() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
HttpRequest request = newRequest(inputHeaders().build());
request = filter.filter(request);
assertEquals(request.getFirstHeaderOrNull(AtmosHeaders.SIGNATURE), EXPECTED_SIGNATURE);
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testAuth() {
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = new BasicAuthentication(ofInstance(credential1)).filter(request);
assertEquals(request.getFirstHeaderOrNull(AUTHORIZATION), "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
request = new BasicAuthentication(ofInstance(credential2)).filter(request);
assertEquals(request.getFirstHeaderOrNull(AUTHORIZATION), "Basic TGl0dGxlOk1lcm1haWQ=");
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testApply() {
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = filter.filter(request);
assertEquals(request.getHeaders().size(), 1);
assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token");
}
代码示例来源:origin: apache/jclouds
@Override
public HttpResponse invoke(HttpCommand command) {
assertEquals(command.getCurrentRequest().getFirstHeaderOrNull("header"), "theheaderparam");
return HttpResponse.builder().build();
}
});
代码示例来源:origin: jclouds/legacy-jclouds
public void testTags() {
UserMetadata tagsdata = new UserMetadata();
tagsdata.getTags().add("apple");
tagsdata.getTags().add("sushi");
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, tagsdata);
assertEquals(request.getFirstHeaderOrNull("x-emc-tags"), "apple,sushi");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testListableMeta() {
UserMetadata metadata = new UserMetadata();
metadata.getListableMetadata().put("apple", "bear");
metadata.getListableMetadata().put("sushi", "king");
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, metadata);
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testListableTags() {
UserMetadata tagsdata = new UserMetadata();
tagsdata.getListableTags().add("apple");
tagsdata.getListableTags().add("sushi");
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, tagsdata);
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-tags"), "apple,sushi");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testMeta() {
UserMetadata metadata = new UserMetadata();
metadata.getMetadata().put("apple", "bear");
metadata.getMetadata().put("sushi", "king");
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, metadata);
assertEquals(request.getFirstHeaderOrNull("x-emc-meta"), "apple=bear,sushi=king");
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testGood() {
AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null);
Payload payload = Payloads.newStringPayload("");
object.setPayload(payload);
object.getUserMetadata().getListableMetadata().put("apple", "bear");
object.getUserMetadata().getListableMetadata().put("sushi", "king");
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, object);
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
}
代码示例来源:origin: apache/jclouds
public void testGood() {
AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null);
Payload payload = Payloads.newStringPayload("");
object.setPayload(payload);
object.getUserMetadata().getListableMetadata().put("apple", "bear");
object.getUserMetadata().getListableMetadata().put("sushi", "king");
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, object);
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
}
内容来源于网络,如有侵权,请联系作者删除!