if(contentEncoding == null || contentEncoding.trim().length() == 0) {
// We use the encoding which should be used according to the HTTP spec, which is UTF-8
contentEncoding = EncoderCache.URL_ARGUMENT_ENCODING;
}
StringBuilder buf = new StringBuilder();
PropertyIterator iter = getArguments().iterator();
boolean first = true;
while (iter.hasNext()) {
HTTPArgument item = null;
/*
* N.B. Revision 323346 introduced the ClassCast check, but then used iter.next()
* to fetch the item to be cast, thus skipping the element that did not cast.
* Reverted to work more like the original code, but with the check in place.
* Added a warning message so can track whether it is necessary
*/
Object objectValue = iter.next().getObjectValue();
try {
item = (HTTPArgument) objectValue;
} catch (ClassCastException e) {
log.warn("Unexpected argument type: "+objectValue.getClass().getName());
item = new HTTPArgument((Argument) objectValue);