예제 #1
0
 def test_malformed_header(self):
     if self.scheme == 'https':
         c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT))
     else:
         c = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
     c.putrequest('GET', '/')
     c.putheader('Content-Type', 'text/plain')
     # See http://www.cherrypy.org/ticket/941 
     c._output('Re, 1.2.3.4#015#012')
     c.endheaders()
     
     response = c.getresponse()
     self.status = str(response.status)
     self.assertStatus(400)
     self.body = response.fp.read()
     self.assertBody("Illegal header line.")
예제 #2
0
 def test_malformed_request_line(self):
     if getattr(cherrypy.server, "using_apache", False):
         return self.skip("skipped due to known Apache differences...")
     
     # Test missing version in Request-Line
     if self.scheme == 'https':
         c = HTTPSConnection('%s:%s' % (self.interface(), self.PORT))
     else:
         c = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
     c._output('GET /')
     c._send_output()
     response = c.response_class(c.sock, strict=c.strict, method='GET')
     response.begin()
     self.assertEqual(response.status, 400)
     self.assertEqual(response.fp.read(22), "Malformed Request-Line")
     c.close()