예제 #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.")
예제 #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.")
예제 #3
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
예제 #4
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