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

Fix of #122 #123

Merged
merged 4 commits into from
Jan 30, 2018
Merged

Fix of #122 #123

merged 4 commits into from
Jan 30, 2018

Conversation

Varbin
Copy link
Contributor

@Varbin Varbin commented Jan 25, 2018

As said, the pull request.

If SERVER_NAME or SERVER_PORT are not, an empty string is set instead.

bjoern/request.c Outdated
}
}
/* SERVER_NAME is required */
else {
Copy link
Contributor Author

@Varbin Varbin Jan 25, 2018

Choose a reason for hiding this comment

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

In theory neither SERVER_NAME nor SERVER_PORT must be empty. Should a sane default of "localhost" be used? HTTP_HOST should be preferred by the app. With unix sockets, should the port be set to 80? Url reconstruction will be wrong with unix sockets in any way!

Copy link
Owner

Choose a reason for hiding this comment

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

No, let's leave them empty. This is a case not covered by PEP 333, and we better break applications completely rather than sneaking in wrong values that cause hard-to-debug issues.

bjoern/request.c Outdated
@@ -205,7 +205,18 @@ on_message_complete(http_parser* parser)
/* SERVER_NAME and SERVER_PORT */
if (REQUEST->server_info->host) {
_set_header(_SERVER_NAME, REQUEST->server_info->host);
_set_header(_SERVER_PORT, REQUEST->server_info->port);
if (REQUEST->server_info->port == Py_None) {
_set_header(_SERVER_PORT,
Copy link
Owner

Choose a reason for hiding this comment

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

I guess these environment items could be moved to _initialize_request_module as they never change? Also, please remove these line breaks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They could be set in theory. But _initialize_request_module does not have "access" to the real values as the host name or port number can differ in different setups.

As for the line breaks: I guess you mean I should write

_set_header(_SERVER_PORT,  PyUnicode_FromFormat("%i", REQUEST->server_info->port));

instead of

_set_header(_SERVER_PORT,
            PyUnicode_FromFormat("%i", REQUEST->server_info->port));

shouldn't I?

Copy link
Owner

Choose a reason for hiding this comment

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

But _initialize_request_module does not have "access" to the real values as the host name or port number can differ in different setups.

You can simply pass &info to that function (see _bjoernmodule.c). They won't change while the server is running, or am I missing something?

As for the line breaks

Yes that's what I meant. 90-100 chars line width is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You your are right, that would be possible.

@Varbin Varbin mentioned this pull request Jan 29, 2018
@Varbin
Copy link
Contributor Author

Varbin commented Jan 29, 2018

@jonashaag So is c894bb4 what you meant?

@Varbin
Copy link
Contributor Author

Varbin commented Jan 30, 2018

I guess these environment items could be moved to _initialize_request_module as they never change?

I just moved them.

@jonashaag jonashaag merged commit 3b46a6b into jonashaag:master Jan 30, 2018
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.

2 participants