org.jclouds.http.HttpRequest.getHeaders()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.jclouds.http.HttpRequest.getHeaders()方法的一些代码示例,展示了HttpRequest.getHeaders()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getHeaders()方法的具体详情如下:
包路径:org.jclouds.http.HttpRequest
类名称:HttpRequest
方法名:getHeaders

HttpRequest.getHeaders介绍

暂无

代码示例

代码示例来源:origin: io.cloudsoft.jclouds/jclouds-core

/**
* Configure the HTTP request headers in the connection.
*/
protected void configureRequestHeaders(HttpURLConnection connection, HttpRequest request) {
 for (Map.Entry<String, String> entry : request.getHeaders().entries()) {
   connection.setRequestProperty(entry.getKey(), entry.getValue());
 }
}

代码示例来源:origin: stackoverflow.com

public class HeadersRequestInterceptor implements ClientHttpRequestInterceptor {
  @Override
  public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
    request.getHeaders().set("Connection", "Close");
    return execution.execute(request, body);
  }
}

代码示例来源:origin: stackoverflow.com

GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(this.TRANSPORT).setJsonFactory(this.JSON_FACTORY)
.setClientSecrets(Constants.CLIENT_ID, Constants.CLIENT_SECRET).setRequestInitializer((new HttpRequestInitializer(){
        @Override
        public void initialize(HttpRequest request)
            throws IOException {
          request.getHeaders().put("Authorization", "Bearer " + accessToken);
        }
      })).build()

代码示例来源: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: io.cloudsoft.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: com.amysta.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

/**
* build a shell script that invokes the contents of the http request in bash.
* 
* @return a shell script that will invoke the http request
*/
public static Statement extractTargzIntoDirectory(HttpRequest targz, String directory) {
 return Statements
      .extractTargzIntoDirectory(targz.getMethod(), targz.getEndpoint(), targz.getHeaders(), directory);
}

代码示例来源:origin: jclouds/legacy-jclouds

/**
* build a shell script that invokes the contents of the http request in bash.
* 
* @return a shell script that will invoke the http request
*/
public static Statement execHttpResponse(HttpRequest request) {
 return pipeHttpResponseToBash(request.getMethod(), request.getEndpoint(), request.getHeaders());
}

代码示例来源:origin: org.apache.jclouds/jclouds-compute

/**
* build a shell script that invokes the contents of the http request in bash.
*
* @return a shell script that will invoke the http request
*/
public static Statement execHttpResponse(HttpRequest request) {
 return pipeHttpResponseToBash(request.getMethod(), request.getEndpoint(), request.getHeaders());
}

代码示例来源:origin: jclouds/legacy-jclouds

/**
* build a shell script that invokes the contents of the http request in bash.
* 
* @return a shell script that will invoke the http request
*/
public static Statement extractZipIntoDirectory(HttpRequest zip, String directory) {
 return Statements.extractZipIntoDirectory(zip.getMethod(), zip.getEndpoint(), zip.getHeaders(), directory);
}

代码示例来源:origin: jclouds/legacy-jclouds

void appendPayloadMetadata(HttpRequest request, StringBuilder buffer) {
 // note that we fall back to headers, and some requests such as ?uploads do not have a
 // payload, yet specify payload related parameters
 buffer.append(
      request.getPayload() == null ? Strings.nullToEmpty(request.getFirstHeaderOrNull("Content-MD5")) :
          HttpUtils.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata()
               .getContentMD5())).append("\n");
 buffer.append(
      Strings.nullToEmpty(request.getPayload() == null ? request.getFirstHeaderOrNull(HttpHeaders.CONTENT_TYPE)
          : request.getPayload().getContentMetadata().getContentType())).append("\n");
 for (String header : FIRST_HEADERS_TO_SIGN)
   buffer.append(HttpUtils.nullToEmpty(request.getHeaders().get(header))).append("\n");
}

代码示例来源:origin: org.jclouds/jclouds-azure

private void calculateAndReplaceAuthHeader(HttpRequest request, String toSign) throws HttpException {
 String signature = signString(toSign);
 if (signatureWire.enabled())
   signatureWire.input(Utils.toInputStream(signature));
 request.getHeaders().replaceValues(HttpHeaders.AUTHORIZATION,
      Collections.singletonList("SharedKeyLite " + identity + ":" + signature));
}

代码示例来源:origin: jclouds/legacy-jclouds

public HttpRequest filter(HttpRequest request) throws HttpException {
   if (request.getHeaders().containsKey("filterme")) {
    request = request.toBuilder().replaceHeader("test", "test").build();
   }
   return request;
 }
}

代码示例来源:origin: jclouds/legacy-jclouds

public HttpRequest filter(HttpRequest request) throws HttpException {
   if (request.getHeaders().containsKey("filterme")) {
    request = request.toBuilder().replaceHeader("test", "test").build();
   }
   return request;
 }
}

代码示例来源: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: jclouds/legacy-jclouds

public static <T> HttpRequest cleanRequest(HttpRequest returnVal) {
 checkNotNull(returnVal, "http request");
 for (HttpRequestFilter filter : returnVal.getFilters())
   returnVal = filter.filter(returnVal);
 return HttpRequest.builder().method(returnVal.getMethod()).endpoint(returnVal.getEndpoint())
      .headers(returnVal.getHeaders()).payload(returnVal.getPayload()).build();
}

代码示例来源:origin: com.amysta.jclouds/jclouds-blobstore

public static <T> HttpRequest cleanRequest(HttpRequest returnVal) {
 checkNotNull(returnVal, "http request");
 for (HttpRequestFilter filter : returnVal.getFilters())
   returnVal = filter.filter(returnVal);
 return HttpRequest.builder().method(returnVal.getMethod()).endpoint(returnVal.getEndpoint())
      .headers(returnVal.getHeaders()).payload(returnVal.getPayload()).build();
}

代码示例来源: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

public void testReplaceHeaders() {
 HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://foo")
                  .addHeader("foo", "bar")
                  .addHeader("rabbit", "tree").build();
 assertEquals(
      request.toBuilder()
         .replaceHeaders(ImmutableMultimap.of("foo", "bar", "rabbit", "robot", "robert", "baz")).build().getHeaders(),
      ImmutableMultimap.of("foo", "bar", "rabbit", "robot", "robert", "baz"));
}

代码示例来源:origin: jclouds/legacy-jclouds

public void testPutHeadersAddsAnotherValue() {
 HttpRequest request = HttpRequest.builder()
                  .method("GET").endpoint("http://foo")
                  .addHeader("foo", "bar").build();
 assertEquals(request.toBuilder()
           .addHeader("foo", "baz").build().getHeaders(), 
        ImmutableMultimap.<String, String> builder()
                .putAll("foo", "bar", "baz").build());
}

相关文章