From 8148151b8550a94aefe5b5598e98ee0f184ed027 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 19 Dec 2011 22:57:52 -0800 Subject: [PATCH] Issue 783:HTTP Accept header field contains invalid type (*) --- .../openstack/nova/NovaAsyncClient.java | 8 ++++++++ .../openstack/nova/NovaAsyncClientTest.java | 18 +++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java index a4150e8e2f..e60b9a406a 100644 --- a/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java +++ b/apis/nova/src/main/java/org/jclouds/openstack/nova/NovaAsyncClient.java @@ -108,6 +108,7 @@ public interface NovaAsyncClient { @POST @QueryParams(keys = "format", values = "json") @Path("/servers/{id}/action") + @Consumes @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"reboot\":%7B\"type\":\"{type}\"%7D%7D") ListenableFuture rebootServer(@PathParam("id") int id, @PayloadParam("type") RebootType rebootType); @@ -118,6 +119,7 @@ public interface NovaAsyncClient { @POST @QueryParams(keys = "format", values = "json") @Path("/servers/{id}/action") + @Consumes @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"resize\":%7B\"flavorId\":{flavorId}%7D%7D") ListenableFuture resizeServer(@PathParam("id") int id, @PayloadParam("flavorId") int flavorId); @@ -128,6 +130,7 @@ public interface NovaAsyncClient { @POST @QueryParams(keys = "format", values = "json") @Path("/servers/{id}/action") + @Consumes @Produces(MediaType.APPLICATION_JSON) @Payload("{\"confirmResize\":null}") ListenableFuture confirmResizeServer(@PathParam("id") int id); @@ -138,6 +141,7 @@ public interface NovaAsyncClient { @POST @QueryParams(keys = "format", values = "json") @Path("/servers/{id}/action") + @Consumes @Produces(MediaType.APPLICATION_JSON) @Payload("{\"revertResize\":null}") ListenableFuture revertResizeServer(@PathParam("id") int id); @@ -160,6 +164,7 @@ public interface NovaAsyncClient { @POST @QueryParams(keys = "format", values = "json") @Path("/servers/{id}/action") + @Consumes @MapBinder(RebuildServerOptions.class) ListenableFuture rebuildServer(@PathParam("id") int id, RebuildServerOptions... options); @@ -169,6 +174,7 @@ public interface NovaAsyncClient { */ @POST @Path("/servers/{id}/action") + @Consumes @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"changePassword\":%7B\"adminPass\":\"{adminPass}\"%7D%7D") ListenableFuture changeAdminPass(@PathParam("id") int id, @PayloadParam("adminPass") String adminPass); @@ -178,6 +184,7 @@ public interface NovaAsyncClient { */ @PUT @Path("/servers/{id}") + @Consumes @Produces(MediaType.APPLICATION_JSON) @Payload("%7B\"server\":%7B\"name\":\"{name}\"%7D%7D") ListenableFuture renameServer(@PathParam("id") int id, @PayloadParam("name") String newName); @@ -253,6 +260,7 @@ public interface NovaAsyncClient { */ @DELETE @ExceptionParser(ReturnFalseOnNotFoundOr404.class) + @Consumes @Path("/images/{id}") ListenableFuture deleteImage(@PathParam("id") int id); diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java index 791fd82228..f9526464be 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaAsyncClientTest.java @@ -139,7 +139,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 2); assertRequestLineEquals(request, "DELETE http://endpoint/vapiversion/images/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, null, null, false); assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class); @@ -446,7 +446,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 2, "foo"); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, "{\"changePassword\":{\"adminPass\":\"foo\"}}", MediaType.APPLICATION_JSON, false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); @@ -462,7 +462,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 2, "foo"); assertRequestLineEquals(request, "PUT http://endpoint/vapiversion/servers/2 HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, "{\"server\":{\"name\":\"foo\"}}", MediaType.APPLICATION_JSON, false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); @@ -547,7 +547,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 3); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, "{\"rebuild\":{}}", MediaType.APPLICATION_JSON, false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); @@ -564,7 +564,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 3, withImage("2")); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/3/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, "{\"rebuild\":{\"imageRef\":\"2\"}}", MediaType.APPLICATION_JSON, false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); @@ -580,7 +580,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 2, RebootType.HARD); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, "{\"reboot\":{\"type\":\"HARD\"}}", MediaType.APPLICATION_JSON, false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); @@ -596,7 +596,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 2, 3); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, "{\"resize\":{\"flavorId\":3}}", MediaType.APPLICATION_JSON, false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); @@ -612,7 +612,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 2); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, "{\"confirmResize\":null}", MediaType.APPLICATION_JSON, false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class); @@ -627,7 +627,7 @@ public class NovaAsyncClientTest extends RestClientTest { HttpRequest request = processor.createRequest(method, 2); assertRequestLineEquals(request, "POST http://endpoint/vapiversion/servers/2/action?format=json HTTP/1.1"); - assertNonPayloadHeadersEqual(request, ""); + assertNonPayloadHeadersEqual(request, "Accept: */*\n"); assertPayloadEquals(request, "{\"revertResize\":null}", MediaType.APPLICATION_JSON, false); assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);