Browse Source

Fix for bug #85

pull/103/head
Wolfgang Nagele 11 years ago
parent
commit
0032df538a
  1. 3
      CHANGES.md
  2. 21
      core/src/main/java/feign/Contract.java

3
CHANGES.md

@ -1,3 +1,6 @@ @@ -1,3 +1,6 @@
### Version 6.1.2
* Named query parameters on GET request result in POST request (bug #85)
### Version 6.0.2
* Fix for BasicAuthRequestInterceptor when username and/or password are long.

21
core/src/main/java/feign/Contract.java

@ -22,6 +22,7 @@ import java.net.URI; @@ -22,6 +22,7 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import static feign.Util.checkState;
import static feign.Util.emptyToNull;
@ -165,14 +166,28 @@ public interface Contract { @@ -165,14 +166,28 @@ public interface Contract {
checkState(emptyToNull(name) != null, "Named annotation was empty on param %s.", paramIndex);
nameParam(data, name, paramIndex);
isHttpAnnotation = true;
if (data.template().url().indexOf('{' + name + '}') == -1 && //
!(data.template().queries().containsKey(name)
|| data.template().headers().containsKey(name))) {
String varName = '{' + name + '}';
if (data.template().url().indexOf(varName) == -1 &&
!searchMapValues(data.template().queries(), varName) &&
!searchMapValues(data.template().headers(), varName)) {
data.formParams().add(name);
}
}
}
return isHttpAnnotation;
}
private <K, V> boolean searchMapValues(Map<K, Collection<V>> map, V search) {
Collection<Collection<V>> values = map.values();
if (values == null)
return false;
for (Collection<V> entry : values) {
if (entry.contains(search))
return true;
}
return false;
}
}
}

Loading…
Cancel
Save