MediaType mediaType,
MultivaluedMap<String, String> httpHeaders,
InputStream entityStream) throws IOException,
WebApplicationException {
MultivaluedMap<String, String> map = new MultivaluedMapImpl();
String string = ProviderUtils.readFromStreamAsString(entityStream, mediaType);
StringTokenizer tokenizer = new StringTokenizer(string, "&");
String token;
while (tokenizer.hasMoreTokens()) {
token = tokenizer.nextToken();
int idx = token.indexOf('=');
if (idx < 0) {
map.add(URLDecoder.decode(token, "UTF-8"), null);
} else if (idx > 0) {
map.add(URLDecoder.decode(token.substring(0, idx), "UTF-8"),
URLDecoder.decode(token.substring(idx + 1), "UTF-8"));
}
}
return map;
}