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