当前位置: 首页>>代码示例>>Java>>正文


Java HttpRequest类代码示例

本文整理汇总了Java中org.jclouds.http.HttpRequest的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest类的具体用法?Java HttpRequest怎么用?Java HttpRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequest类属于org.jclouds.http包,在下文中一共展示了HttpRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSignedGetContentUri

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
public URI getSignedGetContentUri( String key )
{
    BlobRequestSigner signer = blobStoreContext.getSigner();

    if ( !requestSigningSupported( signer ) )
    {
        return null;
    }

    HttpRequest httpRequest;

    try
    {
        httpRequest = signer.signGetBlob( config.container, key, FIVE_MINUTES_IN_SECONDS );
    }
    catch ( UnsupportedOperationException uoe )
    {
        return null;
    }

    return httpRequest.getEndpoint();
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:23,代码来源:JCloudsAppStorageService.java

示例2: getSignedGetContentUri

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override
public URI getSignedGetContentUri( String key )
{
    BlobRequestSigner signer = blobStoreContext.getSigner();

    if ( !requestSigningSupported( signer ) )
    {
        return null;
    }

    HttpRequest httpRequest;

    try
    {
        httpRequest = signer.signGetBlob( config.container, key, FIVE_MINUTES_IN_SECONDS );
    }
    catch ( UnsupportedOperationException uoe )
    {
        return null;
    }

    return httpRequest.getEndpoint();
}
 
开发者ID:dhis2,项目名称:dhis2-core,代码行数:24,代码来源:JCloudsFileResourceContentStore.java

示例3: getSignedGetContentUri

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override
public URI getSignedGetContentUri( String key )
{
    BlobRequestSigner signer = blobStoreContext.getSigner();

    if ( !requestSigningSupported( signer ) )
    {
        return null;
    }

    HttpRequest httpRequest;

    try
    {
        httpRequest = signer.signGetBlob( container, key, FIVE_MINUTES_IN_SECONDS );
    }
    catch ( UnsupportedOperationException uoe )
    {
        return null;
    }

    return httpRequest.getEndpoint();
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:24,代码来源:JCloudsFileResourceContentStore.java

示例4: generatePutTempURL

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
private void generatePutTempURL() throws IOException {
   System.out.format("Generate PUT Temp URL%n");

   // Create the Payload
   String data = "This object will be public for 10 minutes.";
   ByteSource source = ByteSource.wrap(data.getBytes());
   Payload payload = Payloads.newByteSourcePayload(source);

   // Create the Blob
   Blob blob = blobStore.blobBuilder(FILENAME).payload(payload).contentType("text/plain").build();
   HttpRequest request = blobStoreContext.getSigner(REGION).signPutBlob(CONTAINER, blob, TEN_MINUTES);

   System.out.format("  %s %s%n", request.getMethod(), request.getEndpoint());

   // PUT the file using jclouds
   HttpResponse response = blobStoreContext.utils().http().invoke(request);
   int statusCode = response.getStatusCode();

   if (statusCode >= 200 && statusCode < 299) {
      System.out.format("  PUT Success (%s)%n", statusCode);
   }
   else {
      throw new HttpResponseException(null, response);
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:26,代码来源:GenerateTempURL.java

示例5: generateGetTempURL

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
private void generateGetTempURL() throws IOException {
   System.out.format("Generate GET Temp URL%n");

   HttpRequest request = blobStoreContext.getSigner(REGION).signGetBlob(CONTAINER, FILENAME, TEN_MINUTES);

   System.out.format("  %s %s%n", request.getMethod(), request.getEndpoint());

   // GET the file using jclouds
   File file = File.createTempFile(FILENAME, ".tmp");
   Payload payload = blobStoreContext.utils().http().invoke(request).getPayload();

   try {
      Files.asByteSink(file).writeFrom(payload.openStream());

      System.out.format("  GET Success (%s)%n", file.getAbsolutePath());
   } finally {
      payload.release();
      file.delete();
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:21,代码来源:GenerateTempURL.java

示例6: generateDeleteTempURL

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
private void generateDeleteTempURL() throws IOException {
   System.out.format("Generate DELETE Temp URL%n");

   HttpRequest request = blobStoreContext.getSigner(REGION).signRemoveBlob(CONTAINER, FILENAME);

   System.out.format("  %s %s%n", request.getMethod(), request.getEndpoint());

   // DELETE the file using jclouds
   HttpResponse response = blobStoreContext.utils().http().invoke(request);
   int statusCode = response.getStatusCode();

   if (statusCode >= 200 && statusCode < 299) {
      System.out.format("  DELETE Success (%s)%n", statusCode);
   }
   else {
      throw new HttpResponseException(null, response);
   }
}
 
开发者ID:jclouds,项目名称:jclouds-examples,代码行数:19,代码来源:GenerateTempURL.java

示例7: bindToRequest

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
	ListContainerOptions options = ListContainerOptions.class.cast(input);
	if (options.isRecursive()) {
		request = (R) request.toBuilder()
		      .replaceQueryParam(OrionHttpFields.QUERY_DEPTH, OrionConstantValues.MAXIMUM_DEPTH).build();
	}
	if (options.isDetailed()) {
		// TODO a mechanism for this
	}
	if (options.getDir() != null) {
		String requestPath = request.getEndpoint().toASCIIString();
		if (!requestPath.endsWith(OrionConstantValues.PATH_DELIMITER)) {
			requestPath = requestPath + OrionConstantValues.PATH_DELIMITER;
		}
		requestPath = OrionConstantValues.PATH_DELIMITER + OrionUtils.convert2RelativePath(options.getDir());
		request = (R) request.toBuilder().endpoint(requestPath).build();

	}

	return request;
}
 
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:23,代码来源:ListRequestBinder.java

示例8: bindToRequest

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
   ServerRequest Server = ServerRequest.create(
           checkNotNull(postParams.get("name"), "name parameter not present").toString(),
           checkNotNull(postParams.get("imageId"), "imageId parameter not present").toString(),
           Boolean.valueOf(checkNotNull(postParams.get("start"), "start parameter not present").toString()),
           (NetworkInfo) checkNotNull(postParams.get("networkInfo"), "image parameter not present"),
           (List<Disk>) checkNotNull(postParams.get("disk"), "disk parameter not present"),
           checkNotNull(postParams.get("administratorPassword"), "administratorPassword parameter not present").toString(),
           description, cpu, memoryGb, primaryDns, secondaryDns, microsoftTimeZone);

   return bindToRequest(request, Server);
}
 
开发者ID:cloudsoft,项目名称:amp-dimensiondata,代码行数:14,代码来源:CreateServerOptions.java

示例9: filter

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override
public HttpRequest filter(final HttpRequest request) throws HttpException {
    if (creds.authType() == AuthenticationType.Anonymous) {
        return request;
    } else {
        final String authHeader = creds.authType() + " " + creds.authValue();
        return request.toBuilder().addHeader(HttpHeaders.AUTHORIZATION, authHeader).build();
    }
}
 
开发者ID:cdancy,项目名称:bitbucket-rest,代码行数:10,代码来源:BitbucketAuthentication.java

示例10: getAssetDirectLink

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public URI getAssetDirectLink(String id, String root, String filePath) throws IOException {
    ContainerAndName can = getContainerAndName(id, root, filePath);
    HttpRequest hr = context.getSigner().signGetBlob(can.container, can.name, SIGNED_URL_VALIDITY_SECONDS);
    if (hr == null) {
        throw new IOException("No object found to creat signed url " + id);
    }

    return hr.getEndpoint();
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:14,代码来源:BlobStoreFileSystemHandler.java

示例11: bindToRequest

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
   checkArgument(input instanceof LaunchSpecification, "this binder is only valid for LaunchSpecifications!");
   LaunchSpecification launchSpec = LaunchSpecification.class.cast(input);
   return (R) request.toBuilder().replaceFormParams(Multimaps.forMap(apply(launchSpec))).build();
}
 
开发者ID:apache,项目名称:stratos,代码行数:8,代码来源:BindLaunchSpecificationToFormParams.java

示例12: setContext

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override
public HandlerForGeneratedRequestWithResult<SecurityGroup> setContext(HttpRequest request) {
   region = AWSUtils.findRegionInArgsOrNull(GeneratedHttpRequest.class.cast(request));
   if (region == null)
      region = defaultRegion.get();
   builder = builder();
   return super.setContext(request);
}
 
开发者ID:apache,项目名称:stratos,代码行数:9,代码来源:AWSEC2SecurityGroupHandler.java

示例13: assertNonPayloadHeadersEqual

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override protected void assertNonPayloadHeadersEqual(HttpRequest request, String toMatch) {
   Multimap<String, String> headersToCheck = LinkedHashMultimap.create();
   for (String key : request.getHeaders().keySet()) {
      if (key.equals("X-Amz-Date")) {
         assertEquals(request.getFirstHeaderOrNull(key), "20120416T155408Z");
      } else if (key.equals("Authorization")) {
         assertThat(request.getFirstHeaderOrNull(AUTHORIZATION)).startsWith(
               "AWS4-HMAC-SHA256 Credential=identity/20120416/"
                     + "us-east-1/ec2/aws4_request, SignedHeaders=content-type;host;x-amz-date, Signature=");
      } else {
         headersToCheck.putAll(key, request.getHeaders().get(key));
      }
   }
   assertEquals(sortAndConcatHeadersIntoString(headersToCheck), toMatch);
}
 
开发者ID:apache,项目名称:stratos,代码行数:16,代码来源:BaseAWSEC2ApiTest.java

示例14: filter

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override
public HttpRequest filter(HttpRequest request) throws HttpException {
	OrionSpecificFileMetadata metadata;
	metadata = this.json2OrionSpecificObj.apply((String) request.getPayload().getRawContent());
	metadata.getAttributes().setReadOnly(true);
	request = request.toBuilder().payload(this.orionSpecificObject2JSON.apply(metadata)).build();
	return request;
}
 
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:9,代码来源:CreateReadonlyFileFilter.java

示例15: filter

import org.jclouds.http.HttpRequest; //导入依赖的package包/类
@Override
public HttpRequest filter(HttpRequest request) throws HttpException {
	OrionSpecificFileMetadata metadata;
	metadata = this.json2OrionSpecificObj.apply((String) request.getPayload().getRawContent());
	metadata.getAttributes().setHidden(true);
	request = request.toBuilder().payload(this.orionSpecificObject2JSON.apply(metadata)).build();
	return request;
}
 
开发者ID:timur-han,项目名称:orion-jclouds,代码行数:9,代码来源:CreateHiddenFileFilter.java


注:本文中的org.jclouds.http.HttpRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。