# Response Content-Type

**URL:** <https://forums.plex.tv/t/response-content-type/62447>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [April 2, 2014, 7:49pm UTC](https://forums.plex.tv/t/response-content-type/62447 "2014-04-02T19:49:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![czukowski](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/czukowski/32/9008_2.png) [@czukowski](https://forums.plex.tv/u/czukowski)\
**Post date:** [April 2, 2014, 7:49pm UTC](https://forums.plex.tv/t/response-content-type/62447/1 "2014-04-02T19:49:16Z")

</div>

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.

&nbsp;

Does anybody knows how?

&nbsp;

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

---

<div class="post-metadata">

**Author:** ![mikedm139](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mikedm139/32/96909_2.png) [@mikedm139](https://forums.plex.tv/u/mikedm139)\
**Post date:** [April 2, 2014, 8:00pm UTC](https://forums.plex.tv/t/response-content-type/62447/2 "2014-04-02T20:00:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![czukowski](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/czukowski/32/9008_2.png) [@czukowski](https://forums.plex.tv/u/czukowski)\
**Post date:** [April 3, 2014, 2:43pm UTC](https://forums.plex.tv/t/response-content-type/62447/3 "2014-04-03T14:43:54Z")

</div>

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](http://docs.wand-py.org/en/0.3.7/) and I was quite surprised to see the content type overridden.

---

<div class="post-metadata">

**Author:** ![mikedm139](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/mikedm139/32/96909_2.png) [@mikedm139](https://forums.plex.tv/u/mikedm139)\
**Post date:** [April 3, 2014, 6:44pm UTC](https://forums.plex.tv/t/response-content-type/62447/4 "2014-04-03T18:44:15Z")

</div>

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](https://github.com/mikedm139/SickBeard.bundle/blob/87272af77014a366b8562190b20d6718f30abd1a/Contents/Code/ __init__.py#L726)

---

<div class="post-metadata">

**Author:** ![czukowski](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/czukowski/32/9008_2.png) [@czukowski](https://forums.plex.tv/u/czukowski)\
**Post date:** [April 3, 2014, 7:47pm UTC](https://forums.plex.tv/t/response-content-type/62447/5 "2014-04-03T19:47:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 21, 2019, 1:45am UTC](https://forums.plex.tv/t/response-content-type/62447/6 "2019-12-21T01:45:04Z")

</div>

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