Example #1
0
 def _checkURL(self, url):
     """
     Check if the ``url`` is *alive* (i.e., remote server returns code 200(OK)
     or 401 (unauthorized)).
     """
     try:
         p = urlparse(url)
         h = HTTPConnection(p[1])
         h.putrequest('HEAD', p[2])
         h.endheaders()
         r = h.getresponse()
         if r.status in (200, 401):  # CloudMan UI is pwd protected so include 401
             return True
     except Exception:
         # No response or no good response
         pass
     return False
Example #2
0
 def _checkURL(self, url):
     """
     Check if the ``url`` is *alive* (i.e., remote server returns code 200(OK)
     or 401 (unauthorized)).
     """
     try:
         p = urlparse(url)
         h = HTTPConnection(p[1])
         h.putrequest('HEAD', p[2])
         h.endheaders()
         r = h.getresponse()
         if r.status in (
                 200, 401):  # CloudMan UI is pwd protected so include 401
             return True
     except Exception:
         # No response or no good response
         pass
     return False
Example #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
Example #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