You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But it seems that this method is called twice (I can see it by adding print instructions). Is this a bug ?
And is there another way to specify headers ? Currently, I end up with duplicated values in the header I specify.
The text was updated successfully, but these errors were encountered:
content_types_provided is indeed called in a few different places. In general none of the resource methods are guaranteed to be called once in the course of processing a request. For example, allowed_methods is called at the b10 state of the diagram, but is also used in the default implementation of the options method. There may be a few more examples like this in the code, but those are the ones that I can point out off the top of my head.
Having said that there is a way to accomplish what you want. The handlers associated with content types are indeed only called once. (If they were called multiple times per request, that would definitely be a bug.) If you set the cache control headers in the content type handler, you will get your desired behavior.
To make it concrete, take a look at this resource from issue #41. If you change the to_content method from that resource to instead read:
Hello,
I want to set some headers (cache-control) but there is no method to do so in the
resource
class. So I set it in thecontent_type_provided
method:But it seems that this method is called twice (I can see it by adding print instructions). Is this a bug ?
And is there another way to specify headers ? Currently, I end up with duplicated values in the header I specify.
The text was updated successfully, but these errors were encountered: