[Python-Dev] [issue3609] does parse_header really belong in CGI module?

Stephen J. Turnbull stephen at xemacs.org
Fri Apr 3 06:12:36 CEST 2009

Senthil Kumaran writes:

 > http://bugs.python.org/issue3609  requests to move the function
 > parse_header present in cgi module to email package.
 > The reasons for this request are:
 > 1) The MIME type header parsing methods rightly belong to email
 > package. Confirming to RFC 2045.

In practice, the "mail" part of the name is historical; RFC 822-style
headers are used in many protocols, most prominently email, netnews
(less important nowadays :-( ), and HTTP.  If there are differences in
usage, the parsing methods may be different.  If not, then this
functionality is redundant in email, which has its own parser.  It
can't be right for email to have two parsers and CGI none!

Anyway, "moving" the function is almost certainly the *wrong* thing to
do, as the email package has its own conventions and organization.  In
particular, in email header parsing is done by methods of the message
and header objects (in their respective initializations), rather than
by a (global) function.

Since Barry et al have been sprinting on email TNG, you really ought
to coordinate this with them.  I think it would be good to have header
parsing and generation in a free-standing package separate from other
aspects of handling Internet protocols, but this will require
coordination of several modules besides email and cgi.

More information about the Python-Dev mailing list