Changeset 1899
- Timestamp:
- 02/21/08 12:43:30
- Files:
-
- trunk/cherrypy/_cprequest.py (modified) (1 diff)
- trunk/cherrypy/test/test_core.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cprequest.py
r1834 r1899 686 686 methenv = {'REQUEST_METHOD': "POST"} 687 687 try: 688 # If the headers are missing "Content-Type" then add one 689 # with an empty value. This ensures that FieldStorage 690 # won't parse the request body for params if the client 691 # didn't provide a "Content-Type" header. 692 if 'Content-Type' not in self.headers: 693 h = self.headers.copy() 694 h['Content-Type'] = 'application/octet-stream' 695 else: 696 h = self.headers 697 688 698 forms = _cpcgifs.FieldStorage(fp=self.rfile, 689 headers= self.headers,699 headers=h, 690 700 environ=methenv, 691 701 keep_blank_values=1) trunk/cherrypy/test/test_core.py
r1836 r1899 3 3 from cherrypy.test import test 4 4 test.prefer_parent_path() 5 6 import os 7 localDir = os.path.dirname(__file__) 8 import types 5 9 6 10 import cherrypy 7 11 from cherrypy import _cptools, tools 8 12 from cherrypy.lib import http, static 9 import types 10 11 import os 12 localDir = os.path.dirname(__file__) 13 14 13 15 log_file = os.path.join(localDir, "test.log") 14 16 log_access_file = os.path.join(localDir, "access.log") … … 927 929 self.assertBody(b) 928 930 931 # Request a PUT method with a file body but no Content-Type. 932 # See http://www.cherrypy.org/ticket/790. 933 b = "one thing on top of another" 934 self.persistent = True 935 try: 936 conn = self.HTTP_CONN 937 ## conn.set_debuglevel(10) 938 conn.putrequest("PUT", "/method/request_body", skip_host=True) 939 conn.putheader("Host", self.HOST) 940 conn.putheader('Content-Length', str(len(b))) 941 conn.endheaders() 942 conn.send(b) 943 response = conn.response_class(conn.sock, method="PUT") 944 response.begin() 945 self.assertEqual(response.status, 200) 946 self.body = response.read() 947 self.assertBody(b) 948 finally: 949 self.persistent = False 950 929 951 # Request a PUT method with no body whatsoever (not an empty one). 930 952 # See http://www.cherrypy.org/ticket/650.

