Exemplo n.º 1
0
    def test_http_over_https(self):
        if self.scheme != 'https':
            return self.skip("skipped (not running HTTPS)... ")

        # Try connecting without SSL.
        conn = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
        conn.putrequest("GET", "/", skip_host=True)
        conn.putheader("Host", self.HOST)
        conn.endheaders()
        response = conn.response_class(conn.sock, method="GET")
        response.begin()
        self.assertEqual(response.status, 400)
        self.body = response.read()
        self.assertBody("The client sent a plain HTTP request, but this "
                        "server only speaks HTTPS on this port.")
Exemplo n.º 2
0
 def test_http_over_https(self):
     if self.scheme != 'https':
         return self.skip("skipped (not running HTTPS)... ")
     
     # Try connecting without SSL.
     conn = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
     conn.putrequest("GET", "/", skip_host=True)
     conn.putheader("Host", self.HOST)
     conn.endheaders()
     response = conn.response_class(conn.sock, method="GET")
     response.begin()
     self.assertEqual(response.status, 400)
     self.body = response.read()
     self.assertBody("The client sent a plain HTTP request, but this "
                     "server only speaks HTTPS on this port.")
Exemplo n.º 3
0
 def test_garbage_in(self):
     # Connect without SSL regardless of server.scheme
     c = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
     c._output(ntob('gjkgjklsgjklsgjkljklsg'))
     c._send_output()
     response = c.response_class(c.sock, method="GET")
     try:
         response.begin()
         self.assertEqual(response.status, 400)
         self.assertEqual(response.fp.read(22), ntob("Malformed Request-Line"))
         c.close()
     except socket.error:
         e = sys.exc_info()[1]
         # "Connection reset by peer" is also acceptable.
         if e.errno != errno.ECONNRESET:
             raise
Exemplo n.º 4
0
 def test_garbage_in(self):
     # Connect without SSL regardless of server.scheme
     c = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
     c._output(ntob('gjkgjklsgjklsgjkljklsg'))
     c._send_output()
     response = c.response_class(c.sock, method="GET")
     try:
         response.begin()
         self.assertEqual(response.status, 400)
         self.assertEqual(response.fp.read(22), ntob("Malformed Request-Line"))
         c.close()
     except socket.error:
         e = sys.exc_info()[1]
         # "Connection reset by peer" is also acceptable.
         if e.errno != errno.ECONNRESET:
             raise
Exemplo n.º 5
0
    def test_http_over_https(self):
        if self.scheme != "https":
            return self.skip("skipped (not running HTTPS)... ")

        # Try connecting without SSL.
        conn = HTTPConnection("%s:%s" % (self.interface(), self.PORT))
        conn.putrequest("GET", "/", skip_host=True)
        conn.putheader("Host", self.HOST)
        conn.endheaders()
        response = conn.response_class(conn.sock, method="GET")
        try:
            response.begin()
            self.assertEqual(response.status, 400)
            self.body = response.read()
            self.assertBody("The client sent a plain HTTP request, but this " "server only speaks HTTPS on this port.")
        except socket.error:
            e = sys.exc_info()[1]
            # "Connection reset by peer" is also acceptable.
            if e.errno != errno.ECONNRESET:
                raise
Exemplo n.º 6
0
    def test_http_over_https(self):
        if self.scheme != 'https':
            return self.skip('skipped (not running HTTPS)... ')

        # Try connecting without SSL.
        conn = HTTPConnection('%s:%s' % (self.interface(), self.PORT))
        conn.putrequest('GET', '/', skip_host=True)
        conn.putheader('Host', self.HOST)
        conn.endheaders()
        response = conn.response_class(conn.sock, method='GET')
        try:
            response.begin()
            self.assertEqual(response.status, 400)
            self.body = response.read()
            self.assertBody('The client sent a plain HTTP request, but this '
                            'server only speaks HTTPS on this port.')
        except socket.error:
            e = sys.exc_info()[1]
            # "Connection reset by peer" is also acceptable.
            if e.errno != errno.ECONNRESET:
                raise