Commits

Robert Brewer committed fe9264a

Fixed a couple tests for Python 2

  • Participants
  • Parent commits 2c40e23

Comments (0)

Files changed (2)

File cheroot/server.py

             # Close the connection.
             return
         except errors.NoSSLError:
+            msg = ("The client sent a plain HTTP request, but "
+                   "this server only speaks HTTPS on this port.")
+            self.server.error_log(msg)
+
             if req and not req.sent_headers:
                 # Unwrap our wfile
                 self.wfile = makefile(self.socket._sock, "wb", self.wbufsize)
-                req.simple_response("400 Bad Request",
-                    "The client sent a plain HTTP request, but "
-                    "this server only speaks HTTPS on this port.")
+                req.simple_response("400 Bad Request", msg)
                 self.linger = True
         except Exception:
             e = sys.exc_info()[1]

File cheroot/test/test_core.py

 
         cls.httpserver.wsgi_app = Root()
         cls.httpserver.ssl_adapter = helper.get_default_ssl_adapter()
+        cls.HTTP_CONN = HTTPSConnection
+        cls.scheme = 'https'
 
     setup_server = classmethod(setup_server)
 
 
     def test_http_to_https(self):
         # Test what happens when a client tries to speak HTTP to an HTTPS server
+        msg = ("The client sent a plain HTTP request, but this "
+               "server only speaks HTTPS on this port.")
+
         c = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
         c.putrequest("GET", "/hello")
         c.endheaders()
         else:
             self.status, self.headers, self.body = webtest.shb(response)
             c.close()
-            self.assertStatus(200)
-            self.assertBody("hello")
-        self.assertInLog("The client sent a plain HTTP request, but this "
-                         "server only speaks HTTPS on this port.")
+            self.assertStatus(400)
+            self.assertBody(msg)
+        self.assertInLog(msg)