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

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

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

HttpRequest.getPayload介绍

暂无

代码示例

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

private void appendPayloadMetadata(HttpRequest request, StringBuilder buffer) {
 buffer.append(
    Strings.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata()
       .getContentType())).append("\n");
}

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

public HttpRequest filter(HttpRequest request) {
   checkNotNull(request.getPayload(), "request is not ready to wrap; payload not present");
   Credentials current = creds.get();
   String body = request.getPayload().getRawContent().toString();
   Payload wrappedPayload = Payloads.newStringPayload(new StringBuilder()
      .append(format(SOAP_PREFIX, current.identity, current.credential)).append(body).append(SOAP_SUFFIX)
      .toString());
   wrappedPayload.getContentMetadata().setContentType("application/xml");
   return request.toBuilder().payload(wrappedPayload).build();
  }
}

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

@Test
void testBuildCanonicalizedStringSetsVersion() {
 HttpRequest filtered = staticCredentialsFilter.filter(request);
 assertEquals(filtered.getPayload().getRawContent(),
    "Action=DescribeImages&ImageId.1=ami-2bb65342&Signature=ugnt4m2eHE7Ka/vXTr9EhKZq7bhxOfvW0y4pAEqF97w%3D&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2009-11-08T15%3A54%3A08.897Z&Version=apiVersion&AWSAccessKeyId=identity");
}

代码示例来源:origin: io.cloudsoft.jclouds.api/atmos

private void appendPayloadMetadata(HttpRequest request, StringBuilder buffer) {
 buffer.append(
    Strings.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata()
       .getContentType())).append("\n");
}

代码示例来源:origin: com.amysta.jclouds.provider/ultradns-ws

public HttpRequest filter(HttpRequest request) {
   checkNotNull(request.getPayload(), "request is not ready to wrap; payload not present");
   Credentials current = creds.get();
   String body = request.getPayload().getRawContent().toString();
   Payload wrappedPayload = Payloads.newStringPayload(new StringBuilder()
      .append(format(SOAP_PREFIX, current.identity, current.credential)).append(body).append(SOAP_SUFFIX)
      .toString());
   wrappedPayload.getContentMetadata().setContentType("application/xml");
   return request.toBuilder().payload(wrappedPayload).build();
  }
}

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

public void testAlarmNamesBinder() throws Exception {
 HttpRequest request = binder.bindToRequest(request(), ImmutableSet.of("TestAlarmName1", "TestAlarmName2"));
 Assert.assertEquals(request.getPayload().getRawContent(),
           "AlarmNames.member.1=TestAlarmName1&AlarmNames.member.2=TestAlarmName2");
}

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

private void appendPayloadMetadata(HttpRequest request, StringBuilder buffer) {
 buffer.append(
    HttpUtils.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata()
       .getContentMD5())).append("\n");
 buffer.append(
    Strings.nullToEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata()
       .getContentType())).append("\n");
}

代码示例来源:origin: org.apache.jclouds.provider/ultradns-ws

public HttpRequest filter(HttpRequest request) {
   checkNotNull(request.getPayload(), "request is not ready to wrap; payload not present");
   Credentials current = creds.get();
   String body = request.getPayload().getRawContent().toString();
   Payload wrappedPayload = Payloads.newStringPayload(new StringBuilder()
      .append(format(SOAP_PREFIX, current.identity, current.credential)).append(body).append(SOAP_SUFFIX)
      .toString());
   wrappedPayload.getContentMetadata().setContentType("application/xml");
   return request.toBuilder().payload(wrappedPayload).build();
  }
}

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

public void test() {
 HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
 request = binder.bindToRequest(request, ImmutableList.builder().add("alpha").add("omega").build());
 assertEquals(request.getPayload().getRawContent(), "ResourceId.1=alpha&ResourceId.2=omega");
}

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

private void appendPayloadMetadata(HttpRequest request, StringBuilder buffer) {
 buffer.append(utils.valueOrEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata().getContentMD5()))
      .append("\n");
 buffer.append(utils.valueOrEmpty(request.getPayload() == null ? null : request.getPayload().getContentMetadata().getContentType()))
      .append("\n");
}

代码示例来源:origin: io.cloudsoft.jclouds.provider/ultradns-ws

public HttpRequest filter(HttpRequest request) {
   checkNotNull(request.getPayload(), "request is not ready to wrap; payload not present");
   Credentials current = creds.get();
   String body = request.getPayload().getRawContent().toString();
   Payload wrappedPayload = Payloads.newStringPayload(new StringBuilder()
      .append(format(SOAP_PREFIX, current.identity, current.credential)).append(body).append(SOAP_SUFFIX)
      .toString());
   wrappedPayload.getContentMetadata().setContentType("application/xml");
   return request.toBuilder().payload(wrappedPayload).build();
  }
}

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

public void test() {
 HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
 request = binder.bindToRequest(request, ImmutableMultimap.<String, String> builder()
                              .put("resource-type", "instance")
                              .put("key", "stack")
                              .putAll("value", "Test", "Production")
                              .build());
 assertEquals(
    request.getPayload().getRawContent(),
    "Filter.1.Name=resource-type&Filter.1.Value.1=instance&Filter.2.Name=key&Filter.2.Value.1=stack&Filter.3.Name=value&Filter.3.Value.1=Test&Filter.3.Value.2=Production");
}

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

@Override
protected HttpUriRequest convert(HttpRequest request) throws IOException {
 HttpUriRequest returnVal = apacheHCUtils.convertToApacheRequest(request);
 if (request.getPayload() != null && request.getPayload().getContentMetadata().getContentMD5() != null){
   String md5 = base64().encode(asByteSource(request.getPayload().getInput()).hash(md5()).asBytes());
   returnVal.addHeader("Content-MD5", md5);
 }
 return returnVal;
}

代码示例来源:origin: org.apache.jclouds.provider/profitbricks

private HttpRequest createSoapRequest(HttpRequest request) {
 Payload oldPayload = request.getPayload();
 ContentMetadata oldMetadata = oldPayload.getContentMetadata();
 String body = SOAP_PREFIX.concat(oldPayload.getRawContent().toString()).concat(SOAP_SUFFIX);
 Payload newPayload = Payloads.newStringPayload(body);
 HttpUtils.copy(oldMetadata, newPayload.getContentMetadata());
 newPayload.getContentMetadata().setContentLength(Long.valueOf(body.getBytes().length)); // resize, add prefix/suffix length
 return request.toBuilder().payload(newPayload).build();
}

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

@Test
public void testFactoryCorrect() throws SecurityException, NoSuchMethodException {
 BindToJsonPayloadWrappedWith binder = injector.getInstance(BindToJsonPayloadWrappedWith.Factory.class).create(
      "envelope");
 HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
 request = binder.bindToRequest(request, ImmutableMap.of("imageName", "foo", "serverId", "2"));
 assertEquals(request.getPayload().getRawContent(), "{\"envelope\":{\"imageName\":\"foo\",\"serverId\":\"2\"}}");
}

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

@Override
  public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
   checkArgument(payload instanceof Server, "this binder is only valid for Server!");
   Server create = Server.class.cast(payload);
   Map<String, String> map = createServerRequestToMap.apply(create);
   request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map)));
   request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
   return request;
  }
}

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

public void testSimple() throws IOException {
 HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
 i.getInstance(BindServerToPlainTextString.class).bindToRequest(request, SERVER);
 assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
 assertEquals(request.getPayload().getRawContent(), CREATED_SERVER);
}

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

public void testApplyInputStream() throws IOException {

   HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build();
   BindNoBucketLoggingToXmlPayload binder = injector.getInstance(BindNoBucketLoggingToXmlPayload.class);

   request = binder.bindToRequest(request, "bucket");
   assertEquals(request.getPayload().getRawContent(),
        "<BucketLoggingStatus xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\"/>");

  }
}

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

@Override
  public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
   checkArgument(payload instanceof Drive, "this binder is only valid for Drive!");
   Drive create = Drive.class.cast(payload);
   Map<String, String> map = createDriveRequestToMap.apply(create);
   request.setPayload(listOfMapsToListOfKeyValuesDelimitedByBlankLines.apply(ImmutableSet.of(map)));
   request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_PLAIN);
   return request;
  }
}

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

public void testSimple() throws IOException {
 HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
 FN.bindToRequest(request, SERVER);
 assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
 assertEquals(request.getPayload().getRawContent(), CREATED_SERVER);
}

相关文章