mirror of https://github.com/apache/jclouds.git
fixed problem where empty query string doesn't work: Issue 576
This commit is contained in:
parent
b037be29fa
commit
7f1a543fb6
|
@ -168,8 +168,9 @@ public class ModifyRequest {
|
|||
while (pairs.hasNext()) {
|
||||
Map.Entry<String, String> pair = pairs.next();
|
||||
formBuilder.append(Strings2.urlEncode(pair.getKey(), skips));
|
||||
if (pair.getValue() != null && !pair.getValue().equals("")) {
|
||||
if (pair.getValue() != null)
|
||||
formBuilder.append("=");
|
||||
if (pair.getValue() != null && !pair.getValue().equals("")) {
|
||||
formBuilder.append(Strings2.urlEncode(pair.getValue(), skips));
|
||||
}
|
||||
if (pairs.hasNext())
|
||||
|
|
|
@ -1865,6 +1865,11 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
|||
@QueryParams(keys = "acl")
|
||||
ListenableFuture<String> getQueryNull(@PathParam("id") String id);
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@QueryParams(keys = "acl", values="")
|
||||
ListenableFuture<String> getQueryEmpty(@PathParam("id") String id);
|
||||
|
||||
@PUT
|
||||
@Path("/{id}")
|
||||
ListenableFuture<String> put(@PathParam("id") @ParamParser(FirstCharacter.class) String id,
|
||||
|
@ -1948,6 +1953,16 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
|||
assertEquals(request.getHeaders().size(), 0);
|
||||
}
|
||||
|
||||
public void testCreateGetQueryEmpty() throws SecurityException, NoSuchMethodException {
|
||||
Method method = TestRequest.class.getMethod("getQueryEmpty", String.class);
|
||||
HttpRequest request = factory(TestRequest.class).createRequest(method, new Object[] { "1" });
|
||||
assertEquals(request.getEndpoint().getHost(), "localhost");
|
||||
assertEquals(request.getEndpoint().getPath(), "/1");
|
||||
assertEquals(request.getEndpoint().getQuery(), "acl=");
|
||||
assertEquals(request.getMethod(), HttpMethod.GET);
|
||||
assertEquals(request.getHeaders().size(), 0);
|
||||
}
|
||||
|
||||
public class PayloadOptions extends BaseHttpRequestOptions {
|
||||
@Override
|
||||
public String buildStringPayload() {
|
||||
|
|
Loading…
Reference in New Issue