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