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

Updated middleware Providers to take Sender config, fixed wsgi CONTENT_LENGTH error #94

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

Conversation

markstuart
Copy link

I'm using raygun4py in a project where it's already used as wsgi middleware. Recently we found that some of the env vars going through to Raygun we wanted to filter out, and it seems the way to do that is via config to the RaygunSender when initialising it.

Unfortunately, only the Django middleware supports this, so I raised this PR to hopefully get the other middlewares up to the same level.

@coveralls
Copy link

coveralls commented Apr 6, 2020

Coverage Status

Coverage increased (+0.1%) to 88.559% when pulling 2d0e4fd on mediasuitenz:add_config_to_middleware into f65727a on MindscapeHQ:master.

Earlier versions of Werkzerg created a default of ''
for the CONTENT_LENGTH environ var if the client
did not provide the header.

See pallets/werkzeug#1056
if content_length:
http_form = request['wsgi.input'].read(content_length)
content_length = request.get('CONTENT_LENGTH', 0)
if content_length and content_length != '':
Copy link
Author

@markstuart markstuart Apr 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some wsgi servers set the CONTENT_LENGTH to '' if the client did not provide the header. This was happening in my case and the result was that the attempt to cast '' to an int was raising an exception, and the try:except was handily swallowing the error.

The result was that rg_request never got instantiated and was failing later on when trying to set rg_request['headers'] = _headers.

I think this change should be compatible with the intent of what was there previously. It does however mean that the http_form would not get created if request.get('CONTENT_LENGTH') == ''

@markstuart markstuart changed the title Updated middleware Providers to take Sender config Updated middleware Providers to take Sender config, fixed wsgi CONTENT_LENGTH error Apr 8, 2020
@sreecodeslayer
Copy link

hey folks, any chance this can get merged and have a release
I want to disable env vars from being sent on a flask app

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.

None yet

3 participants