|
38 | 38 | import sys
|
39 | 39 | import os
|
40 | 40 | import urllib
|
41 |
| -import email.Parser |
| 41 | +import mimetools |
| 42 | +import rfc822 |
42 | 43 | import UserDict
|
43 | 44 | try:
|
44 | 45 | from cStringIO import StringIO
|
@@ -107,8 +108,6 @@ def nolog(*allargs):
|
107 | 108 | # Parsing functions
|
108 | 109 | # =================
|
109 | 110 |
|
110 |
| -_header_parser = email.Parser.HeaderParser() |
111 |
| - |
112 | 111 | # Maximum input we will accept when REQUEST_METHOD is POST
|
113 | 112 | # 0 ==> unlimited input
|
114 | 113 | maxlen = 0
|
@@ -271,7 +270,7 @@ def parse_multipart(fp, pdict):
|
271 | 270 | data = None
|
272 | 271 | if terminator:
|
273 | 272 | # At start of next part. Read headers first.
|
274 |
| - headers = _header_parser.parse(fp) |
| 273 | + headers = mimetools.Message(fp) |
275 | 274 | clength = headers.getheader('content-length')
|
276 | 275 | if clength:
|
277 | 276 | try:
|
@@ -408,9 +407,8 @@ class FieldStorage:
|
408 | 407 |
|
409 | 408 | disposition_options: dictionary of corresponding options
|
410 | 409 |
|
411 |
| - headers: a dictionary(-like) object (sometimes |
412 |
| - email.Message.Message or a subclass thereof) containing *all* |
413 |
| - headers |
| 410 | + headers: a dictionary(-like) object (sometimes rfc822.Message or a |
| 411 | + subclass thereof) containing *all* headers |
414 | 412 |
|
415 | 413 | The class is subclassable, mostly for the purpose of overriding
|
416 | 414 | the make_file() method, which is called internally to come up with
|
@@ -652,7 +650,7 @@ def read_multi(self, environ, keep_blank_values, strict_parsing):
|
652 | 650 | environ, keep_blank_values, strict_parsing)
|
653 | 651 | # Throw first part away
|
654 | 652 | while not part.done:
|
655 |
| - headers = _header_parser.parse(self.fp) |
| 653 | + headers = rfc822.Message(self.fp) |
656 | 654 | part = klass(self.fp, headers, ib,
|
657 | 655 | environ, keep_blank_values, strict_parsing)
|
658 | 656 | self.list.append(part)
|
|
0 commit comments