Please return the proper Content-Type for the remote API. Code included

Hi,

I'm using Jersey a Java Framework for making REST calls to external API's I know, I'm sorry.

Jersey is a massive pain in the ass when it does not get the right Content-Type back from the server, in your case is gets back text/plain, refusing any unmarshalling. I've tried a few hacks of varying degrees of nastiness and there is no clean fix for this.

Out of boredom I checked the code in /usr/libexec/webmin/virtual-server/remote.cgi and found you can replace

print "Content-type: text/plain\n\n";

with

if($format == "xml") { print "Content-type: application/xml\n\n"; } else { if($format == "json") { print "Content-type: application/json\n\n"; } else { print "Content-type: text/plain\n\n"; } }

Sorry, not the best of perl. Basically what it does is force the Content Type to be consistent with the requested data type. I can appreciate that not everbody would like this change, but I'm sharing it in the hopes you'll consider changing the current behaviour.

For now I'll just patch my own instances with this.

Status: 
Closed (fixed)

Comments

Thanks for pointing this out - the next Virtualmin release (4.04) will set the correct MIME type.

Automatically closed -- issue fixed for 2 weeks with no activity.