Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid KeyError if no Content-Type header; don't perform unnecessary checks in can_minify_response #87

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jdotjdot
Copy link

When using django-htmlmin in my project, I found that some responses were being returned without the Content-Type header. Even though I was excluding those URLs from being minified using the settings.py EXCLUDE_FROM_MINIFYING option, the structure of the middleware's can_minify_response function did two things that resulted in errors:

  1. Even after determining via the RegEx check that the URL should be excluded from minification, it continued to perform additional checks that included the error-containing code, and
  2. The check for the Content-Type header in the request dictionary would throw a KeyError if the header wasn't present.

I've fixed both of those issues, as well as adding an additional test in case request._hit_htmlmin is ever set to False (which it shouldn't be, so why not have a test for it?)

@vinitkumar
Copy link

Can we get this merged please?

@vinitkumar
Copy link

Any updates on this, please?

@diegoponciano
Copy link

I'm affected by this issue too, can you merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants