mirror of https://github.com/apache/jclouds.git
Merge pull request #1383 from jclouds/remove-expect-100
remove default add of Expect 100 Continue header
This commit is contained in:
commit
1ab2bea92a
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.atmos;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.EXPECT;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Named;
|
||||
|
@ -56,6 +58,7 @@ import org.jclouds.blobstore.BlobStoreFallbacks.ThrowKeyNotFoundOn404;
|
|||
import org.jclouds.http.options.GetOptions;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Fallback;
|
||||
import org.jclouds.rest.annotations.Headers;
|
||||
import org.jclouds.rest.annotations.ParamParser;
|
||||
import org.jclouds.rest.annotations.QueryParams;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
|
@ -119,6 +122,7 @@ public interface AtmosAsyncClient {
|
|||
@Named("CreateObject")
|
||||
@POST
|
||||
@Path("/{parent}/{name}")
|
||||
@Headers(keys = EXPECT, values = "100-continue")
|
||||
@Consumes(MediaType.WILDCARD)
|
||||
ListenableFuture<URI> createFile(
|
||||
@PathParam("parent") String parent,
|
||||
|
@ -131,6 +135,7 @@ public interface AtmosAsyncClient {
|
|||
@Named("UpdateObject")
|
||||
@PUT
|
||||
@Path("/{parent}/{name}")
|
||||
@Headers(keys = EXPECT, values = "100-continue")
|
||||
@Fallback(ThrowKeyNotFoundOn404.class)
|
||||
@Consumes(MediaType.WILDCARD)
|
||||
ListenableFuture<Void> updateFile(
|
||||
|
|
|
@ -167,7 +167,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
.apply(BindBlobToMultipartFormTest.TEST_BLOB)));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\nExpect: 100-continue\n");
|
||||
assertPayloadEquals(request, "hello", "text/plain", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class);
|
||||
|
@ -185,7 +185,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
|
||||
assertRequestLineEquals(request, "POST https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT
|
||||
+ ": */*\nx-emc-groupacl: other=READ\nx-emc-useracl: root=FULL_CONTROL\n");
|
||||
+ ": */*\nExpect: 100-continue\nx-emc-groupacl: other=READ\nx-emc-useracl: root=FULL_CONTROL\n");
|
||||
assertPayloadEquals(request, "hello", "text/plain", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseURIFromListOrLocationHeaderIf20x.class);
|
||||
|
@ -202,7 +202,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
.apply(BindBlobToMultipartFormTest.TEST_BLOB)));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\n");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": */*\nExpect: 100-continue\n");
|
||||
assertPayloadEquals(request, "hello", "text/plain", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
@ -220,7 +220,7 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
|||
|
||||
assertRequestLineEquals(request, "PUT https://accesspoint.atmosonline.com/rest/namespace/dir/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT
|
||||
+ ": */*\nx-emc-groupacl: other=READ\nx-emc-useracl: root=FULL_CONTROL\n");
|
||||
+ ": */*\nExpect: 100-continue\nx-emc-groupacl: other=READ\nx-emc-useracl: root=FULL_CONTROL\n");
|
||||
assertPayloadEquals(request, "hello", "text/plain", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
|
||||
|
|
|
@ -101,7 +101,7 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncCl
|
|||
"POST https://accesspoint.atmosonline.com/rest/namespace/container/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(
|
||||
request,
|
||||
"Accept: */*\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nx-emc-signature: 7Cbdnu+YA5rG9J/C9RlHk07mU7w=\nx-emc-uid: identity\n");
|
||||
"Accept: */*\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nExpect: 100-continue\nx-emc-signature: 7Cbdnu+YA5rG9J/C9RlHk07mU7w=\nx-emc-uid: identity\n");
|
||||
|
||||
assertContentHeadersEqual(request, "text/plain", null, null, null, (long) 2l, new byte[] { 0, 2, 4, 8 }, new Date(1000));
|
||||
|
||||
|
|
|
@ -80,12 +80,14 @@ public class CloudFilesBlobSignerExpectTest extends BaseBlobSignerExpectTest {
|
|||
protected HttpRequest putBlob() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/name")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.addHeader("X-Auth-Token", authToken).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HttpRequest putBlobWithTime() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.endpoint("https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_83a9d536-2e25-4166-bd3b-a503a934f953/container/name?temp_url_sig=f83fa711f353f6f0bab3a66c56e35a972b9b3922&temp_url_expires=123456792").build();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.s3;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.EXPECT;
|
||||
import static org.jclouds.blobstore.attr.BlobScopes.CONTAINER;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -168,6 +169,7 @@ public interface S3AsyncClient {
|
|||
@Named("PutObject")
|
||||
@PUT
|
||||
@Path("/{key}")
|
||||
@Headers(keys = EXPECT, values = "100-continue")
|
||||
@ResponseParser(ParseETagHeader.class)
|
||||
ListenableFuture<String> putObject(
|
||||
@Bucket @EndpointParam(parser = AssignCorrectHostnameForBucket.class) @BinderParam(BindAsHostPrefixIfConfigured.class) @ParamValidators(BucketNameValidator.class) String bucketName,
|
||||
|
|
|
@ -82,6 +82,7 @@ public class PathBasedS3ClientExpectTest extends BaseS3ClientExpectTest {
|
|||
|
||||
HttpRequest bucketFooExists = HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://s3.amazonaws.com/bucket/object")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.addHeader("Date", CONSTANT_DATE)
|
||||
.addHeader("Authorization", "AWS identity:6gC0m7SYFDPwkUqY5EHV/6i9DfM=")
|
||||
.payload("hello world")
|
||||
|
|
|
@ -20,7 +20,10 @@ package org.jclouds.s3;
|
|||
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_LENGTH;
|
||||
import static com.google.common.net.HttpHeaders.ETAG;
|
||||
import static com.google.common.net.HttpHeaders.EXPECT;
|
||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||
import static org.jclouds.Constants.PROPERTY_MAX_RETRIES;
|
||||
import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
|
||||
import static org.jclouds.s3.reference.S3Constants.PROPERTY_S3_VIRTUAL_HOST_BUCKETS;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
|
@ -46,7 +49,7 @@ import com.google.mockwebserver.RecordedRequest;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test
|
||||
@Test(singleThreaded = true)
|
||||
public class S3ClientMockTest {
|
||||
|
||||
private static final Set<Module> modules = ImmutableSet.<Module> of(
|
||||
|
@ -55,7 +58,9 @@ public class S3ClientMockTest {
|
|||
static RestContext<? extends S3Client,? extends S3AsyncClient> getContext(URL server) {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
|
||||
|
||||
// prevent expect-100 bug http://code.google.com/p/mockwebserver/issues/detail?id=6
|
||||
overrides.setProperty(PROPERTY_SO_TIMEOUT, "0");
|
||||
overrides.setProperty(PROPERTY_MAX_RETRIES, "1");
|
||||
return ContextBuilder.newBuilder("s3")
|
||||
.credentials("accessKey", "secretKey")
|
||||
.endpoint(server.toString())
|
||||
|
@ -79,24 +84,28 @@ public class S3ClientMockTest {
|
|||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getRequestLine(), "PUT /bucket/object HTTP/1.1");
|
||||
assertEquals(request.getHeaders(CONTENT_LENGTH), ImmutableList.of("0"));
|
||||
// will fail unless -Dsun.net.http.allowRestrictedHeaders=true is set
|
||||
assertEquals(request.getHeaders(EXPECT), ImmutableList.of("100-continue"));
|
||||
server.shutdown();
|
||||
}
|
||||
|
||||
public void testDirectorySeparator() throws IOException, InterruptedException {
|
||||
MockWebServer server = new MockWebServer();
|
||||
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
|
||||
server.play();
|
||||
MockWebServer server = new MockWebServer();
|
||||
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
|
||||
server.play();
|
||||
|
||||
S3Client client = getContext(server.getUrl("/")).getApi();
|
||||
S3Object fileInDir = client.newS3Object();
|
||||
fileInDir.getMetadata().setKey("someDir/fileName");
|
||||
fileInDir.setPayload(new byte[] {});
|
||||
S3Client client = getContext(server.getUrl("/")).getApi();
|
||||
S3Object fileInDir = client.newS3Object();
|
||||
fileInDir.getMetadata().setKey("someDir/fileName");
|
||||
fileInDir.setPayload(new byte[] { 1, 2, 3, 4 });
|
||||
|
||||
assertEquals(client.putObject("bucket", fileInDir), "ABCDEF");
|
||||
assertEquals(client.putObject("bucket", fileInDir), "ABCDEF");
|
||||
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getRequestLine(), "PUT /bucket/someDir/fileName HTTP/1.1");
|
||||
RecordedRequest request = server.takeRequest();
|
||||
assertEquals(request.getRequestLine(), "PUT /bucket/someDir/fileName HTTP/1.1");
|
||||
// will fail unless -Dsun.net.http.allowRestrictedHeaders=true is set
|
||||
assertEquals(request.getHeaders(EXPECT), ImmutableList.of("100-continue"));
|
||||
|
||||
server.shutdown();
|
||||
}
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ public class S3BlobSignerExpectTest extends BaseBlobSignerExpectTest {
|
|||
protected HttpRequest putBlob() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://container.s3.amazonaws.com/name")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.addHeader("Host", "container.s3.amazonaws.com")
|
||||
.addHeader("Date", "Thu, 05 Jun 2008 16:38:19 GMT")
|
||||
.addHeader("Authorization", "AWS identity:j9Dy/lmmvlCKjA4lkqZenLxMkR4=").build();
|
||||
|
@ -98,6 +99,7 @@ public class S3BlobSignerExpectTest extends BaseBlobSignerExpectTest {
|
|||
protected HttpRequest putBlobWithTime() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://container.s3.amazonaws.com/name")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.addHeader("Host", "container.s3.amazonaws.com")
|
||||
.addHeader("Date", "Thu, 05 Jun 2008 16:38:19 GMT")
|
||||
.addHeader("Authorization", "AWS identity:0uvBv1wEskuhFHYJF/L6kEV9A7o=").build();
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.openstack.swift;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.EXPECT;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -196,6 +198,7 @@ public interface CommonSwiftAsyncClient {
|
|||
@Named("PutObject")
|
||||
@PUT
|
||||
@Path("/{container}/{name}")
|
||||
@Headers(keys = EXPECT, values = "100-continue")
|
||||
@ResponseParser(ParseETagHeader.class)
|
||||
ListenableFuture<String> putObject(@PathParam("container") String container,
|
||||
@PathParam("name") @ParamParser(ObjectName.class) @BinderParam(BindSwiftObjectMetadataToRequest.class) SwiftObject object);
|
||||
|
|
|
@ -78,6 +78,7 @@ public class SwiftBlobSignerExpectTest extends BaseBlobSignerExpectTest {
|
|||
protected HttpRequest putBlob() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("http://storage/container/name")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.addHeader("X-Auth-Token", "testtoken").build();
|
||||
}
|
||||
|
||||
|
@ -85,6 +86,7 @@ public class SwiftBlobSignerExpectTest extends BaseBlobSignerExpectTest {
|
|||
protected HttpRequest putBlobWithTime() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("http://storage/container/name?temp_url_sig=e894c60fa1284cc575cf22d7786bab07b8c33610&temp_url_expires=123456792")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -72,13 +72,16 @@ public class SwiftKeystoneBlobSignerExpectTest extends BaseBlobSignerExpectTest
|
|||
protected HttpRequest putBlob() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://objects.jclouds.org/v1.0/40806637803162/container/name")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.addHeader("X-Auth-Token", "Auth_4f173437e4b013bee56d1007").build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected HttpRequest putBlobWithTime() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://objects.jclouds.org/v1.0/40806637803162/container/name?temp_url_sig=72e5f6ebafab2b3da0586198797e58fb7478211e&temp_url_expires=123456792").build();
|
||||
.endpoint("https://objects.jclouds.org/v1.0/40806637803162/container/name?temp_url_sig=72e5f6ebafab2b3da0586198797e58fb7478211e&temp_url_expires=123456792")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.net.URI;
|
|||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
@ -36,6 +37,7 @@ import com.google.common.base.Objects;
|
|||
import com.google.common.base.Objects.ToStringHelper;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
|
@ -47,6 +49,9 @@ import com.google.common.collect.Multimaps;
|
|||
*/
|
||||
public class HttpRequest extends HttpMessage {
|
||||
|
||||
public static final Set<String> NON_PAYLOAD_METHODS = ImmutableSet
|
||||
.of("OPTIONS", "GET", "HEAD", "DELETE", "TRACE", "CONNECT");
|
||||
|
||||
public static Builder<?> builder() {
|
||||
return new ConcreteBuilder();
|
||||
}
|
||||
|
|
|
@ -63,7 +63,6 @@ import com.google.common.base.Function;
|
|||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableMultimap;
|
||||
import com.google.common.collect.ImmutableMultimap.Builder;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.io.CountingOutputStream;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.inject.Inject;
|
||||
|
@ -227,18 +226,14 @@ public class JavaUrlHttpCommandExecutorService extends BaseHttpCommandExecutorSe
|
|||
}
|
||||
|
||||
protected void writeNothing(HttpURLConnection connection) {
|
||||
connection.setRequestProperty(CONTENT_LENGTH, "0");
|
||||
// for some reason POST/PUT undoes the content length header above.
|
||||
if (ImmutableSet.of("POST", "PUT").contains(connection.getRequestMethod())) {
|
||||
connection.setFixedLengthStreamingMode(0);
|
||||
connection.setDoOutput(true);
|
||||
if (!HttpRequest.NON_PAYLOAD_METHODS.contains(connection.getRequestMethod())) {
|
||||
connection.setRequestProperty(CONTENT_LENGTH, "0");
|
||||
}
|
||||
}
|
||||
|
||||
void writePayloadToConnection(Payload payload, HttpURLConnection connection) throws IOException {
|
||||
Long length = payload.getContentMetadata().getContentLength();
|
||||
connection.setRequestProperty(CONTENT_LENGTH, length.toString());
|
||||
connection.setRequestProperty("Expect", "100-continue");
|
||||
connection.setFixedLengthStreamingMode(length.intValue());
|
||||
connection.setDoOutput(true);
|
||||
CountingOutputStream out = new CountingOutputStream(connection.getOutputStream());
|
||||
|
|
|
@ -200,10 +200,13 @@ public class RestAnnotationProcessor implements Function<Invocation, HttpRequest
|
|||
throw new NoSuchElementException(format("no endpoint found for %s", invocation));
|
||||
GeneratedHttpRequest.Builder requestBuilder = GeneratedHttpRequest.builder().invocation(invocation)
|
||||
.caller(caller);
|
||||
String requestMethod = null;
|
||||
if (r != null) {
|
||||
requestMethod = r.getMethod();
|
||||
requestBuilder.fromHttpRequest(r);
|
||||
} else {
|
||||
requestBuilder.method(tryFindHttpMethod(invocation.getInvokable()).get());
|
||||
requestMethod = tryFindHttpMethod(invocation.getInvokable()).get();
|
||||
requestBuilder.method(requestMethod);
|
||||
}
|
||||
|
||||
requestBuilder.filters(getFiltersIfAnnotated(invocation));
|
||||
|
@ -286,7 +289,7 @@ public class RestAnnotationProcessor implements Function<Invocation, HttpRequest
|
|||
payload = new MultipartForm(MultipartForm.BOUNDARY, parts);
|
||||
} else if (formParams.size() > 0) {
|
||||
payload = Payloads.newUrlEncodedFormPayload(transformValues(formParams, NullableToStringFunction.INSTANCE));
|
||||
} else if (headers.containsKey(CONTENT_TYPE)) {
|
||||
} else if (headers.containsKey(CONTENT_TYPE) && !HttpRequest.NON_PAYLOAD_METHODS.contains(requestMethod)) {
|
||||
if (payload == null)
|
||||
payload = Payloads.newByteArrayPayload(new byte[] {});
|
||||
payload.getContentMetadata().setContentType(get(headers.get(CONTENT_TYPE), 0));
|
||||
|
|
|
@ -25,13 +25,13 @@ import javax.ws.rs.Consumes;
|
|||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.dynect.v3.domain.Job;
|
||||
import org.jclouds.dynect.v3.features.RecordAsyncApi;
|
||||
import org.jclouds.dynect.v3.features.SessionAsyncApi;
|
||||
import org.jclouds.dynect.v3.features.ZoneAsyncApi;
|
||||
import org.jclouds.dynect.v3.filters.AlwaysAddContentType;
|
||||
import org.jclouds.dynect.v3.filters.SessionManager;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
import org.jclouds.rest.annotations.Fallback;
|
||||
|
@ -55,8 +55,7 @@ public interface DynECTAsyncApi {
|
|||
@Named("GetJob")
|
||||
@GET
|
||||
@Path("/Job/{jobId}")
|
||||
@Produces(APPLICATION_JSON)
|
||||
@RequestFilters(SessionManager.class)
|
||||
@RequestFilters({ AlwaysAddContentType.class, SessionManager.class })
|
||||
@Headers(keys = "API-Version", values = "{jclouds.api-version}")
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Consumes(APPLICATION_JSON)
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.jclouds.dynect.v3.features;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
import static org.jclouds.http.Uris.uriBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
|
@ -29,7 +28,6 @@ import javax.inject.Named;
|
|||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.JobStillRunningException;
|
||||
|
@ -44,6 +42,7 @@ import org.jclouds.dynect.v3.domain.rdata.NSData;
|
|||
import org.jclouds.dynect.v3.domain.rdata.PTRData;
|
||||
import org.jclouds.dynect.v3.domain.rdata.SRVData;
|
||||
import org.jclouds.dynect.v3.domain.rdata.TXTData;
|
||||
import org.jclouds.dynect.v3.filters.AlwaysAddContentType;
|
||||
import org.jclouds.dynect.v3.filters.SessionManager;
|
||||
import org.jclouds.dynect.v3.functions.ToRecordIds;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -66,10 +65,8 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* href="https://manage.dynect.net/help/docs/api2/rest/resources/AllRecord.html">doc</a>
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// required for all calls
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Headers(keys = "API-Version", values = "{jclouds.api-version}")
|
||||
@RequestFilters(SessionManager.class)
|
||||
@RequestFilters({ AlwaysAddContentType.class, SessionManager.class })
|
||||
public interface RecordAsyncApi {
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,22 +18,21 @@
|
|||
*/
|
||||
package org.jclouds.dynect.v3.features;
|
||||
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HeaderParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.jclouds.dynect.v3.DynECTFallbacks.FalseOn400;
|
||||
import org.jclouds.dynect.v3.domain.Session;
|
||||
import org.jclouds.dynect.v3.domain.SessionCredentials;
|
||||
import org.jclouds.dynect.v3.filters.AlwaysAddContentType;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Fallback;
|
||||
import org.jclouds.rest.annotations.Headers;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.SelectJson;
|
||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||
|
||||
|
@ -47,10 +46,9 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @see <a href="https://manage.dynect.net/help/docs/api2/rest/" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// required for all calls
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Headers(keys = "API-Version", values = "{jclouds.api-version}")
|
||||
@Path("/Session")
|
||||
@RequestFilters(AlwaysAddContentType.class)
|
||||
public interface SessionAsyncApi {
|
||||
|
||||
/**
|
||||
|
|
|
@ -31,12 +31,13 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.TargetExistsException;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.JobStillRunningException;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.TargetExistsException;
|
||||
import org.jclouds.dynect.v3.domain.CreatePrimaryZone;
|
||||
import org.jclouds.dynect.v3.domain.CreatePrimaryZone.ToFQDN;
|
||||
import org.jclouds.dynect.v3.domain.Job;
|
||||
import org.jclouds.dynect.v3.domain.Zone;
|
||||
import org.jclouds.dynect.v3.filters.AlwaysAddContentType;
|
||||
import org.jclouds.dynect.v3.filters.SessionManager;
|
||||
import org.jclouds.dynect.v3.functions.ExtractZoneNames;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
|
@ -60,10 +61,8 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* href="https://manage.dynect.net/help/docs/api2/rest/resources/Zone.html">doc</a>
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// required for all calls
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Headers(keys = "API-Version", values = "{jclouds.api-version}")
|
||||
@RequestFilters(SessionManager.class)
|
||||
@RequestFilters({ AlwaysAddContentType.class, SessionManager.class })
|
||||
public interface ZoneAsyncApi {
|
||||
|
||||
/**
|
||||
|
@ -102,6 +101,7 @@ public interface ZoneAsyncApi {
|
|||
*/
|
||||
@Named("CreatePrimaryZone")
|
||||
@POST
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Payload("%7B\"rname\":\"{contact}\",\"serial_style\":\"increment\",\"ttl\":3600%7D")
|
||||
@Path("/Zone/{fqdn}")
|
||||
@SelectJson("data")
|
||||
|
@ -132,8 +132,9 @@ public interface ZoneAsyncApi {
|
|||
*/
|
||||
@Named("PublishZone")
|
||||
@PUT
|
||||
@Payload("{\"publish\":true}")
|
||||
@Path("/Zone/{fqdn}")
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Payload("{\"publish\":true}")
|
||||
@SelectJson("data")
|
||||
ListenableFuture<Zone> publish(@PathParam("fqdn") String fqdn) throws JobStillRunningException;
|
||||
|
||||
|
@ -143,6 +144,7 @@ public interface ZoneAsyncApi {
|
|||
@Named("FreezeZone")
|
||||
@PUT
|
||||
@Path("/Zone/{fqdn}")
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Payload("{\"freeze\":true}")
|
||||
@Consumes(APPLICATION_JSON)
|
||||
ListenableFuture<Job> freeze(@PathParam("fqdn") String fqdn) throws JobStillRunningException;
|
||||
|
@ -153,6 +155,7 @@ public interface ZoneAsyncApi {
|
|||
@Named("ThawZone")
|
||||
@PUT
|
||||
@Path("/Zone/{fqdn}")
|
||||
@Produces(APPLICATION_JSON)
|
||||
@Payload("{\"thaw\":true}")
|
||||
@Consumes(APPLICATION_JSON)
|
||||
ListenableFuture<Job> thaw(@PathParam("fqdn") String fqdn) throws JobStillRunningException;
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.dynect.v3.filters;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
import static org.jclouds.http.HttpRequest.NON_PAYLOAD_METHODS;
|
||||
|
||||
import org.jclouds.http.HttpException;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpRequestFilter;
|
||||
|
||||
/**
|
||||
*
|
||||
* DynECT requires Content-Type even on GET requests.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public final class AlwaysAddContentType implements HttpRequestFilter {
|
||||
@Override
|
||||
public HttpRequest filter(HttpRequest request) throws HttpException {
|
||||
if (NON_PAYLOAD_METHODS.contains(request.getMethod()))
|
||||
return request.toBuilder().replaceHeader(CONTENT_TYPE, APPLICATION_JSON).build();
|
||||
return request;
|
||||
}
|
||||
}
|
|
@ -56,7 +56,7 @@ public class GetJobRedirectionRetryHandler extends RedirectionRetryHandler {
|
|||
if (location != null && location.indexOf("Job") != -1) {
|
||||
HttpRequest getRequest = command.getCurrentRequest().toBuilder()
|
||||
.method("GET")
|
||||
.payload(emptyPayload).build();
|
||||
.payload((Payload) null).build();
|
||||
command.setCurrentRequest(getRequest);
|
||||
}
|
||||
return super.shouldRetryRequest(command, response);
|
||||
|
|
|
@ -19,17 +19,16 @@
|
|||
package org.jclouds.dynect.v3;
|
||||
|
||||
import static com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor;
|
||||
import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
|
||||
import static org.jclouds.Constants.PROPERTY_MAX_RETRIES;
|
||||
import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.TargetExistsException;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.JobStillRunningException;
|
||||
import org.jclouds.dynect.v3.DynECTExceptions.TargetExistsException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -43,18 +42,18 @@ import com.google.mockwebserver.MockWebServer;
|
|||
*/
|
||||
@Test(singleThreaded = true)
|
||||
public class DynectApiMockTest {
|
||||
|
||||
private static final Set<Module> modules = ImmutableSet.<Module> of(
|
||||
new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()));
|
||||
|
||||
static DynECTApi mockDynectApi(String uri) {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(PROPERTY_CONNECTION_TIMEOUT, "1000");
|
||||
// prevent expect-100 bug http://code.google.com/p/mockwebserver/issues/detail?id=6
|
||||
overrides.setProperty(PROPERTY_SO_TIMEOUT, "0");
|
||||
overrides.setProperty(PROPERTY_MAX_RETRIES, "1");
|
||||
return ContextBuilder.newBuilder("dynect")
|
||||
.credentials("jclouds:joe", "letmein")
|
||||
.endpoint(uri)
|
||||
.overrides(overrides)
|
||||
.modules(ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor())))
|
||||
.modules(modules)
|
||||
.build(DynECTApiMetadata.CONTEXT_TOKEN).getApi();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.dynect.v3.features;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
import static org.jclouds.dynect.v3.domain.RecordId.recordIdBuilder;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -49,8 +50,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getSOA = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/SOARecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse soaResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_soa.json", APPLICATION_JSON)).build();
|
||||
|
@ -75,8 +76,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getAAAA = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/AAAARecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse aaaaResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_aaaa.json", APPLICATION_JSON)).build();
|
||||
|
@ -101,8 +102,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getA = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/ARecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse aResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_a.json", APPLICATION_JSON)).build();
|
||||
|
@ -127,8 +128,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getCNAME = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/CNAMERecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse cnameResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_cname.json", APPLICATION_JSON)).build();
|
||||
|
@ -153,8 +154,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getMX = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/MXRecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse mxResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_mx.json", APPLICATION_JSON)).build();
|
||||
|
@ -179,8 +180,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getNS = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/NSRecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse nsResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_ns.json", APPLICATION_JSON)).build();
|
||||
|
@ -205,8 +206,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getPTR = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/PTRRecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse ptrResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_ptr.json", APPLICATION_JSON)).build();
|
||||
|
@ -242,8 +243,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getSRV = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/SRVRecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse srvResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_srv.json", APPLICATION_JSON)).build();
|
||||
|
@ -263,8 +264,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest getTXT = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/TXTRecord/adrianc.zone.dynecttest.jclouds.org/adrianc.zone.dynecttest.jclouds.org/50976579")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse txtResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_record_txt.json", APPLICATION_JSON)).build();
|
||||
|
@ -289,8 +290,8 @@ public class RecordApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
HttpRequest list = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/AllRecord/adrianc.zone.dynecttest.jclouds.org")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload()).build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/list_records.json", APPLICATION_JSON)).build();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.dynect.v3.features;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
|
@ -47,11 +48,10 @@ public class SessionApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
}
|
||||
|
||||
HttpRequest isValid = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/Session")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload())
|
||||
.build();
|
||||
.endpoint("https://api2.dynect.net/REST/Session")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse validResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/session_valid.json", APPLICATION_JSON)).build();
|
||||
|
@ -70,11 +70,10 @@ public class SessionApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
}
|
||||
|
||||
HttpRequest logout = HttpRequest.builder().method("DELETE")
|
||||
.endpoint("https://api2.dynect.net/REST/Session")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload())
|
||||
.build();
|
||||
.endpoint("https://api2.dynect.net/REST/Session")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse logoutResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/logout.json", APPLICATION_JSON)).build();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.dynect.v3.features;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.ACCEPT;
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
|
@ -40,11 +41,10 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit", testName = "ZoneApiExpectTest")
|
||||
public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
||||
HttpRequest get = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload())
|
||||
.build();
|
||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse getResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/get_zone.json", APPLICATION_JSON)).build();
|
||||
|
@ -83,11 +83,10 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
}
|
||||
|
||||
HttpRequest list = HttpRequest.builder().method("GET")
|
||||
.endpoint("https://api2.dynect.net/REST/Zone")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload())
|
||||
.build();
|
||||
.endpoint("https://api2.dynect.net/REST/Zone")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/list_zones.json", APPLICATION_JSON)).build();
|
||||
|
@ -99,12 +98,11 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
}
|
||||
|
||||
HttpRequest deleteChanges = HttpRequest.builder().method("DELETE")
|
||||
.endpoint("https://api2.dynect.net/REST/ZoneChanges/jclouds.org")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload())
|
||||
.build();
|
||||
.endpoint("https://api2.dynect.net/REST/ZoneChanges/jclouds.org")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse deleteChangesResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/delete_zone_changes.json", APPLICATION_JSON)).build();
|
||||
|
@ -116,12 +114,11 @@ public class ZoneApiExpectTest extends BaseDynECTApiExpectTest {
|
|||
}
|
||||
|
||||
HttpRequest delete = HttpRequest.builder().method("DELETE")
|
||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload())
|
||||
.build();
|
||||
.endpoint("https://api2.dynect.net/REST/Zone/jclouds.org")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/delete_zone.json", APPLICATION_JSON)).build();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
package org.jclouds.dynect.v3.handlers;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.ACCEPT;
|
||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||
import static com.google.common.net.HttpHeaders.LOCATION;
|
||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||
|
||||
|
@ -54,9 +55,8 @@ public class GetJobRedirectionRetryHandlerExpectTest extends BaseDynECTApiExpect
|
|||
.endpoint("https://api2.dynect.net/REST/Job/1234")
|
||||
.addHeader("API-Version", "3.3.8")
|
||||
.addHeader(ACCEPT, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken)
|
||||
.payload(emptyJsonPayload())
|
||||
.build();
|
||||
.addHeader(CONTENT_TYPE, APPLICATION_JSON)
|
||||
.addHeader("Auth-Token", authToken).build();
|
||||
|
||||
HttpResponse success = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/delete_zone.json", APPLICATION_JSON)).build();
|
||||
|
|
|
@ -57,12 +57,6 @@ public class BaseDynECTExpectTest<T> extends BaseRestApiExpectTest<T> {
|
|||
}
|
||||
}
|
||||
|
||||
public static Payload emptyJsonPayload() {
|
||||
Payload p = Payloads.newByteArrayPayload(new byte[] {});
|
||||
p.getContentMetadata().setContentType(APPLICATION_JSON);
|
||||
return p;
|
||||
}
|
||||
|
||||
public static Payload stringPayload(String json) {
|
||||
Payload p = Payloads.newPayload(json);
|
||||
p.getContentMetadata().setContentType(APPLICATION_JSON);
|
||||
|
|
|
@ -451,6 +451,7 @@
|
|||
</property>
|
||||
</properties>
|
||||
<systemPropertyVariables>
|
||||
<sun.net.http.allowRestrictedHeaders>true</sun.net.http.allowRestrictedHeaders>
|
||||
<jclouds.wire.httpstream.url>${jclouds.wire.httpstream.url}</jclouds.wire.httpstream.url>
|
||||
<jclouds.wire.httpstream.md5>${jclouds.wire.httpstream.md5}</jclouds.wire.httpstream.md5>
|
||||
</systemPropertyVariables>
|
||||
|
|
|
@ -105,7 +105,7 @@ public class AWSS3AsyncClientTest extends S3AsyncClientTest<AWSS3AsyncClient> {
|
|||
blobToS3Object.apply(BindBlobToMultipartFormTest.TEST_BLOB)));
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/hello HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
assertNonPayloadHeadersEqual(request, "Expect: 100-continue\nHost: bucket." + url + "\n");
|
||||
assertPayloadEquals(request, "hello", "text/plain", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseETagHeader.class);
|
||||
|
|
|
@ -73,6 +73,7 @@ public class AWSS3ClientExpectTest extends BaseAWSS3ClientExpectTest {
|
|||
HttpRequest.builder()
|
||||
.method("PUT")
|
||||
.endpoint("https://test.s3-eu-west-1.amazonaws.com/test")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.addHeader("x-amz-storage-class", "REDUCED_REDUNDANCY")
|
||||
.addHeader("Host", "test.s3-eu-west-1.amazonaws.com")
|
||||
.addHeader("Date", CONSTANT_DATE)
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.azureblob;
|
||||
|
||||
import static com.google.common.net.HttpHeaders.EXPECT;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
|
@ -217,6 +219,7 @@ public interface AzureBlobAsyncClient {
|
|||
@Named("PutBlob")
|
||||
@PUT
|
||||
@Path("{container}/{name}")
|
||||
@Headers(keys = EXPECT, values = "100-continue")
|
||||
@ResponseParser(ParseETagHeader.class)
|
||||
ListenableFuture<String> putBlob(
|
||||
@PathParam("container") @ParamValidators(ContainerNameValidator.class) String container,
|
||||
|
|
|
@ -97,7 +97,7 @@ public class AzureBlobRequestSignerTest extends BaseAsyncClientTest<AzureBlobAsy
|
|||
assertRequestLineEquals(request, "PUT https://identity.blob.core.windows.net/container/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(
|
||||
request,
|
||||
"Authorization: SharedKeyLite identity:ssvK6ZB8GMqRcp1lBpY9vIzbLKL9Goxh7wZ2YhfHNzQ=\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nx-ms-blob-type: BlockBlob\nx-ms-version: 2009-09-19\n");
|
||||
"Authorization: SharedKeyLite identity:ssvK6ZB8GMqRcp1lBpY9vIzbLKL9Goxh7wZ2YhfHNzQ=\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nExpect: 100-continue\nx-ms-blob-type: BlockBlob\nx-ms-version: 2009-09-19\n");
|
||||
assertContentHeadersEqual(request, "text/plain", null, null, null, (long) 2l, new byte[] { 0, 2, 4, 8 }, new Date(1000));
|
||||
|
||||
assertEquals(request.getFilters().size(), 0);
|
||||
|
|
|
@ -75,6 +75,7 @@ public class HPCloudObjectStorageBlobSignerExpectTest extends BaseBlobSignerExpe
|
|||
protected HttpRequest putBlob() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://objects.jclouds.org/v1.0/40806637803162/container/name")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.addHeader("X-Auth-Token", "Auth_4f173437e4b013bee56d1007").build();
|
||||
}
|
||||
|
||||
|
@ -82,6 +83,7 @@ public class HPCloudObjectStorageBlobSignerExpectTest extends BaseBlobSignerExpe
|
|||
protected HttpRequest putBlobWithTime() {
|
||||
return HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://objects.jclouds.org/v1.0/40806637803162/container/name?temp_url_sig=40806637803162%3Aidentity%3Ac90269245ab0a316d5ea5e654d4c2a975fb4bf77&temp_url_expires=123456792")
|
||||
.addHeader("Expect", "100-continue")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue