Now that I've upgraded, any proxy code I have seems to be returning multiple
"charset" parameters.

That is, I have code that makes a call to another web service.  I take
the Representation instance received and return that as the
Representation for the response call:

   Client client = ...
   Request appRequest = ...
   Response appResponse = client.handle(appRequest);

   if (appResponse.isEntityAvailable()) {
      getResponse().setEntity(appResponse.getEntity());
   }

Unfortunately, this results in two charset parameter values.  That is, if
the remote service returns "application/atom+xml; charset=UTF-8" the
proxy service returns "application/atom+xml; charset=UTF-8; charset=UTF-8".

Is that a bug or a feature?  Seems like a bug to me.

To fix this, I have to do:

  if (appResponse.isEntityAvailable()) {
      Representation rep = appResponse.getEntity();
      MediaType type = rep.getMediaType();
      String charset = type.getParmeters().getFirstValue("charset");
      rep.setMediaType(MediaType.valueOf(rep.getMediaType().getName()));
      rep.setCharacterSet(CharacterSet.valueOf(charset));
  }

That seems rather onerous.

--Alex Milowski

Reply via email to