comparison MoinMoin/support/werkzeug/test.py @ 4627:c404a1295318

updated werkzeug
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 05 Mar 2009 23:01:03 +0100
parents 159902268129
children 06a744121699
comparison
equal deleted inserted replaced
4626:25532a36f2b5 4627:c404a1295318
8 :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details. 8 :copyright: (c) 2009 by the Werkzeug Team, see AUTHORS for more details.
9 :license: BSD, see LICENSE for more details. 9 :license: BSD, see LICENSE for more details.
10 """ 10 """
11 import sys 11 import sys
12 import urlparse 12 import urlparse
13 import mimetypes
13 from time import time 14 from time import time
14 from random import random 15 from random import random
15 from itertools import chain 16 from itertools import chain
16 from tempfile import TemporaryFile 17 from tempfile import TemporaryFile
17 from cStringIO import StringIO 18 from cStringIO import StringIO
18 from cookielib import CookieJar 19 from cookielib import CookieJar
19 from mimetypes import guess_type
20 from urllib2 import Request as U2Request 20 from urllib2 import Request as U2Request
21 21
22 from werkzeug._internal import _empty_stream 22 from werkzeug._internal import _empty_stream
23 from werkzeug.wrappers import BaseRequest 23 from werkzeug.wrappers import BaseRequest
24 from werkzeug.utils import create_environ, run_wsgi_app, get_current_url, \ 24 from werkzeug.utils import create_environ, run_wsgi_app, get_current_url, \
67 if reader is not None: 67 if reader is not None:
68 filename = getattr(value, 'filename', 68 filename = getattr(value, 'filename',
69 getattr(value, 'name', None)) 69 getattr(value, 'name', None))
70 content_type = getattr(value, 'content_type', None) 70 content_type = getattr(value, 'content_type', None)
71 if content_type is None: 71 if content_type is None:
72 content_type = filename and guess_type(filename)[0] or \ 72 content_type = filename and \
73 'application/octet-stream' 73 mimetypes.guess_type(filename)[0] or \
74 'application/octet-stream'
74 if filename is not None: 75 if filename is not None:
75 write('; filename="%s"\r\n' % filename) 76 write('; filename="%s"\r\n' % filename)
76 else: 77 else:
77 write('\r\n') 78 write('\r\n')
78 write('Content-Type: %s\r\n\r\n' % content_type) 79 write('Content-Type: %s\r\n\r\n' % content_type)