Skip to content

content-type comparison is failing #2

Open

Description

@dh-harald

Hi,

In my case https://github.com/luca-moser/iris-cache/blob/master/cache.go#L119 failed, because my Content-type contains my encoding: Content-Type: text/html; charset=UTF-8
Therefore I can't use your provided values for content type (cache.ContentTypeHTML/cache.ContentTypeJSON)

Could you fix it somehow? For example trim the variable after ;. It's not a big deal, but it could be better with a fix.

Activity

  1. luca-moser commented on Dec 6, 2017

    @luca-moser
    Owner

    The ContentType constants are merely the same values as used by iris (iris repo link).

    With the Config struct, you are able to set a custom ContentType which should be cached (link).

    So in your case supplying a Config to NewCacheHF or NewCache with a custom ContentType of "text/html; charset=UTF-8" should fix your issue.

    I think it's faster when the user of the middleware supplies his/her used content types, since otherwise the middleware would have to do trimming and whatnot.

  2. dh-harald commented on Dec 6, 2017

    @dh-harald
    Author

    I know, I'm already using that method, you suggested... (that was my workaround)
    I've opened this ticket, because based on the documentation, the middleware couldn't working in special circumstances (eg. it's not caching anything).
    Just because of nature of Content-Type header, you could easily trim it after ;, and the content type values could work afterwards...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions