URLEncoding also parameter names.

This commit is contained in:
Simone Bordet 2014-05-15 09:09:22 +02:00
parent ab67143c29
commit 660c05d399
2 changed files with 4 additions and 4 deletions

View File

@ -212,7 +212,7 @@ public class HttpRequest implements Request
{ {
// If we have an existing query string, preserve it and append the new parameter. // If we have an existing query string, preserve it and append the new parameter.
if (query != null) if (query != null)
query += "&" + name + "=" + urlEncode(value); query += "&" + urlEncode(name) + "=" + urlEncode(value);
else else
query = buildQuery(); query = buildQuery();
uri = null; uri = null;
@ -648,7 +648,7 @@ public class HttpRequest implements Request
private String buildQuery() private String buildQuery()
{ {
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
for (Iterator<Fields.Field> iterator = params.iterator(); iterator.hasNext();) for (Iterator<Fields.Field> iterator = params.iterator(); iterator.hasNext(); )
{ {
Fields.Field field = iterator.next(); Fields.Field field = iterator.next();
List<String> values = field.getValues(); List<String> values = field.getValues();
@ -690,7 +690,7 @@ public class HttpRequest implements Request
String[] parts = nameValue.split("="); String[] parts = nameValue.split("=");
if (parts.length > 0) if (parts.length > 0)
{ {
String name = parts[0]; String name = urlDecode(parts[0]);
if (name.trim().length() == 0) if (name.trim().length() == 0)
continue; continue;
param(name, parts.length < 2 ? "" : urlDecode(parts[1]), true); param(name, parts.length < 2 ? "" : urlDecode(parts[1]), true);

View File

@ -58,7 +58,7 @@ public class FormContentProvider extends StringContentProvider
{ {
if (builder.length() > 0) if (builder.length() > 0)
builder.append("&"); builder.append("&");
builder.append(field.getName()).append("=").append(encode(value, charset)); builder.append(encode(field.getName(), charset)).append("=").append(encode(value, charset));
} }
} }
return builder.toString(); return builder.toString();