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

Fixes method post #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tomdottom
Copy link
Contributor

Adds CONTENT_LENGTH & CONTENT_TYPE so that post requests work correctly

Many frameworks/applications will rely on CONTENT_LENGTH to determine the length of the body appended to the end of uwsgi_packet_header + uwsgi_vars.

Copy link
Owner

@andreif andreif left a comment

Choose a reason for hiding this comment

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

Could you please fix those things and rebase on master after #8 is merged?

if body is None:
body = ''.encode('utf-8')
else:
body = body.encode('utf-8')
Copy link
Owner

Choose a reason for hiding this comment

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

Let's make it in one line

body = (body or '').encode('utf-8')

for header in headers or ():
key, _, value = header.partition(':')
var['HTTP_' + key.strip().upper()] = value.strip()
var['HTTP_' + key.strip().upper().replace('-', '_')] = value.strip()
if 'HTTP_CONTENT-TYPE' in var.keys():
Copy link
Owner

Choose a reason for hiding this comment

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

It's probably a typo there and I wonder do we even need HTTP_CONTENT_TYPE there at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is indeed a typo and should be HTTP_CONTENT_TYPE.

However, we do still need it. In much the same way we're special casing SERVER_NAME and SERVER_PORT we also need to extract the well used uWSGI param CONTENT_TYPE from the header HTTP_CONTENT_TYPE.

@tomdottom tomdottom force-pushed the fixes-method-post branch 4 times, most recently from cc4015f to 1e5d194 Compare May 25, 2018 13:29
@tomdottom
Copy link
Contributor Author

tomdottom commented May 25, 2018

I should also point out that this work is base on top of #8.
If you're happy with this PR you can merge it and simply close #8.

@coveralls
Copy link

coveralls commented May 25, 2018

Coverage Status

Coverage remained the same at ?% when pulling f5faed6 on tomdottom:fixes-method-post into a86fea9 on andreif:master.

@andreif
Copy link
Owner

andreif commented May 30, 2018

So now when #8 is merged, could you please rebase on master?

@tomdottom
Copy link
Contributor Author

Rebased and ready for review.

@tomdottom
Copy link
Contributor Author

Hey @andreif 👋 . Is there anything I left I need to do to get this PR merged?

@andreif
Copy link
Owner

andreif commented Jun 7, 2018

@tomdottom Hey! Thanks a lot for all the commits! I just need to find few calm minutes to go through them 😄

@andreif andreif self-requested a review June 7, 2018 13:19
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