I agree, as long as URLEncoder seems to work.
Do you think we need to modify URI so that it uses URLEncoder to encode the query part of URIs? In cases where a client has a URL string that may or may not contain query parameters, it would lead to a slightly more natural API usage:
HttpMethod meth = new GetMethod(new URI(urlString));
as opposed to
String query = null;
int index = urlString.indexOf('?');
if (index != -1) {
query = urlString.substring(index+1);
urlString = urlString.substring(0, index);
}
HttpMethod meth = new GetMethod(new URI(urlString));
meth.setQueryString(java.net.URLEncoder.encode(query));
or something like that, with error checking of course.
I don't think URI should be doing any form urlencoding. The URI spec does not use the concept of query params. It just treats the entire query as a single entity.
Also, when creating a URI containing query params, the params must be encoded before the URI is generated otherwise it will not be parsable. For example, when creating a URI with the following query params:
Name Value param1 value&1 param2 value=2
If not pre-encoded, the URI would look something like "http://host/path?param1=value&1¶m2=value=2".
Once joined together it is too late to encode. This is why the HttpMethod(String) constructor assumes that all URIs are already encoded, as it is not possible to correctly encoded them after the fact.
Please let me know if you will be writing some code for this as I will take care of it tomorrow otherwise.
Mike
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
