Response Content-Type

Plex server seems to be replacing whatever I set as Response object's Content-Type headers with text/plain. I'm sending thumbnail images to output. Though they appear in the client player anyway, I'd still like to force the correct values in the headers.

 

Does anybody knows how?

 

I've only been able to find that the function construct_response in the file components/runtime.py of the framework might be responsible.

All response from a channel are plain text. The values provided by the channel code are converted to XML then passed to the client app. The client apps interpret the XML and display content based on the values included in the XML.

This is true for MediaContainer objects, and those are being sent with Content-Type: application/xml

I actually generate thumbnail images progamatically. Here's a piece of my code:

Response.Headers['content-type'] = image.mimetype
Response.Headers['content-disposition'] = 'inline;filename="%s.%s"' % ('thumbnail', image.format.lower())
return image.make_blob(image.format)

where image is an Image object from Wand library and I was quite surprised to see the content type overridden.

Perhaps returning a DataObject would solve the issue. See an example here:
https://github.com/mikedm139/SickBeard.bundle/blob/87272af77014a366b8562190b20d6718f30abd1a/Contents/Code/init.py#L726

Thanks, that did the trick!

Another thing worth noting I've discovered, is that headers are handled in a case-sensitive way in Plex. So if I'm setting 'cache-control: max-age=86400' and the framework then sets 'Cache-Control: no-cache', both headers are set and may be interpreted as 'Cache-Control: max-age=86400, no-cache' that doesn't make much sense.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.