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

Silky doesn't work when django.middleware.gzip.GZipMiddleware is enabled #43

Closed
melbic opened this issue Nov 25, 2014 · 7 comments
Closed

Comments

@melbic
Copy link

melbic commented Nov 25, 2014

When the 'django.middleware.gzip.GZipMiddleware' is enabled the following error happens:
File "...r/lib/python2.7/site-packages/silk/sql.py", line 39, in execute_sql
sql_query = q % params
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal not in range(128)

@brmc
Copy link
Contributor

brmc commented Nov 30, 2014

Edit your MIDDLEWARE_CLASSES so that GZipMiddleware is before SilkyMiddleware

brmc added a commit to brmc/silk that referenced this issue Nov 30, 2014
Issue 43: jazzband#43
SilkyMiddleWare should be listed before GZipMiddleware
@mtford90
Copy link
Collaborator

mtford90 commented Dec 1, 2014

As @brmc says, things can go awry with middleware placement. I thought I'd fixed the unicode issues however, so I'll leave this open for now and investigate further at some point

@brmc
Copy link
Contributor

brmc commented Dec 2, 2014

The unicode issues arent really your fault. Python 2.x is just traditionally terrible with unicode. This same thing will happen with gzipmiddleware just about anytime other apps are analyzing or modifying the response.
Even so, in your case it wouldn't even really make sense to compensate for the encoding/decoding issues because after everything was decoded properly, you'd still have to decompress the gzipped response. It would be much more beneficial for everyone to just insist on proper middleware ordering.

And FWIW, i like where this app is going. it picks up exactly where debug-toolbar leaves off. In the next couple weeks Im going to try and tackle your enhancement requests(no promises though in case i get busy with work). and i'll probably add some tox integration and python 3 support along the way.

good work!

@mtford90
Copy link
Collaborator

mtford90 commented Dec 3, 2014

@brmc

That's a good point and thanks! If you get to the enhancements do let me know if have any questions about anything. Tox especially sounds like a good idea

--Mike

@brmc
Copy link
Contributor

brmc commented Dec 3, 2014

@mtford90
will do.

in regards to tox, i'll probably start by restructuring your test paths if that's ok with you. similar to, if not exactly like, what I did here: https://github.com/brmc/django-media-helper

the main difference being that, rather than copying the directories during the tests, i'd create a test folder and then symlink to the project from within.

@mtford90
Copy link
Collaborator

mtford90 commented Dec 4, 2014

@brmc

Yeah that's fine with me, the proj organisation is a bit skewed anyhow. We should prob move this to a diff. issue btw ;)

@mtford90
Copy link
Collaborator

Closing this as can be solved by middleware placement. Let me know if you're still havin issues tho @melbic

pablodiazgutierrez pushed a commit to appfluence/django-silk that referenced this issue Oct 18, 2020
yaroslav0114 pushed a commit to yaroslav0114/django-silk that referenced this issue Dec 17, 2022
Issue 43: jazzband/django-silk#43
SilkyMiddleWare should be listed before GZipMiddleware
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

No branches or pull requests

3 participants