Dobes Vandermeer
Dobes Vandermeer

Reputation: 8810

Pyramid: Set Content-Type in response to match accept header?

We're using the pyramid web framework. We use the accept predicate to match on the client's Accept header. We use some custom headers for our json responses, like application/vnd.whatever+json.

What I would like is for the Content-Type of the response to be set equal to the accept predicate value.

Currently pyramid always sends back application/json.

How should I go about having the Content-Type of the response set to match the custom media type in the request Accept header that was negotiated?

Upvotes: 3

Views: 2499

Answers (1)

user2846569
user2846569

Reputation: 2832

To set response header use:

request.response.content_type = 'application/download'

This will set Content-Type for download, but you can set whatever you like.

Upvotes: 3

Related Questions