Opened 13 years ago

Closed 13 years ago

#16581 closed Cleanup/optimization (fixed)

Documentation of HttpRequest.META could note possibly surprising type values

Reported by: Roy Smith Owned by: nobody
Component: Documentation Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

HttpRequest.METASERVER_PORT, returns a string (i.e. "80"). It really should be an integer.

Some argument could be made that it really *should* be a string (see http://tinyurl.com/3fpb6px). If it is decided that string is correct, then at least it should be clearly documented. I think most people would expect a network port to be an integer.

Attachments (1)

16581.diff (1.7 KB ) - added by Bernhard Essl 13 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Karen Tracey, 13 years ago

Component: HTTP handlingDocumentation
Summary: HttpRequest.META['SERVER_PORT'] should be an integerDocumentation of HttpRequest.META could note possibly surprising type values
Triage Stage: UnreviewedAccepted
Type: BugCleanup/optimization

SERVER_PORT is coming from the underlying (or copied in, for older Django) Python wsgiref implementation (see http://hg.python.org/cpython/file/532cad687332/Lib/wsgiref/simple_server.py#l56). Note CONTENT_LENGTH is also a string value. I don't believe Django should change either of these, but if someone wants to provide a doc patch that notes that these values in Request.META are strings I suppose that might avoid some confusion for some people.

comment:2 by Roy Smith, 13 years ago

Since this appears to be an intentional decision, and changing it would break backwards compatibility, I agree that documenting this (and CONTENT_LENGTH, and any others) would be a sufficient fix.

by Bernhard Essl, 13 years ago

Attachment: 16581.diff added

comment:3 by Bernhard Essl, 13 years ago

Has patch: set

I added a patch with warning signs :).
I've also changed the description of the other keys a bit.

comment:4 by Aymeric Augustin, 13 years ago

Triage Stage: AcceptedReady for checkin

The patch looks good to me.

comment:5 by Malcolm Tredinnick, 13 years ago

Out of deference to people who have English as a second (or third or seventeenth) language, I'm going to leave most of these changes as they currently are. My understanding (from doing a internationalisation support for most of a decade) is that possessive form constructions are harder to unambiguously understand than the slightly more passive phrasing we have here. It's a bit of a judgement call, I'll admit.

Will commit the additions for LENGTH, TYPE, etc, though.

comment:6 by Malcolm Tredinnick, 13 years ago

Resolution: fixed
Status: newclosed

In [16644]:

Improved documentation around HTTP server meta variables.

Fixed #16581, with thanks to Bernhard Essl.

Note: See TracTickets for help on using tickets.
Back to Top