Beispiel #1
0
    def log_curl_request(self, method, url, kwargs):
        curl = ['curl -i -X %s' % method]

        for (key, value) in kwargs['headers'].items():
            header = '-H \'%s: %s\'' % (strutils.safe_decode(key),
                                        strutils.safe_decode(value))
            curl.append(header)

        conn_params_fmt = [
            ('key_file', '--key %s'),
            ('cert_file', '--cert %s'),
            ('ca_file', '--cacert %s'),
        ]
        for (key, fmt) in conn_params_fmt:
            value = self.ssl_connection_params.get(key)
            if value:
                curl.append(fmt % value)

        if self.ssl_connection_params.get('insecure'):
            curl.append('-k')

        if 'data' in kwargs:
            curl.append('-d \'%s\'' % kwargs['data'])

        curl.append('%s%s' % (self.endpoint, url))
        LOG.debug(' '.join(curl))
Beispiel #2
0
    def log_curl_request(self, method, url, kwargs):
        curl = ['curl -i -X %s' % method]

        for (key, value) in kwargs['headers'].items():
            header = '-H \'%s: %s\'' % (strutils.safe_decode(key),
                                        strutils.safe_decode(value))
            curl.append(header)

        conn_params_fmt = [
            ('key_file', '--key %s'),
            ('cert_file', '--cert %s'),
            ('ca_file', '--cacert %s'),
        ]
        for (key, fmt) in conn_params_fmt:
            value = self.ssl_connection_params.get(key)
            if value:
                curl.append(fmt % value)

        if self.ssl_connection_params.get('insecure'):
            curl.append('-k')

        if 'data' in kwargs:
            curl.append('-d \'%s\'' % kwargs['data'])

        curl.append('%s%s' % (self.endpoint, url))
        LOG.debug(' '.join(curl))
Beispiel #3
0
 def safe_header(self, name, value):
     if name in SENSITIVE_HEADERS:
         # because in python3 byte string handling is ... ug
         v = value.encode('utf-8')
         h = hashlib.sha1(v)
         d = h.hexdigest()
         return strutils.safe_decode(name), "{SHA1}%s" % d
     else:
         return strutils.safe_decode(name), strutils.safe_decode(value)
Beispiel #4
0
 def safe_header(self, name, value):
     if name in SENSITIVE_HEADERS:
         # because in python3 byte string handling is ... ug
         v = value.encode('utf-8')
         h = hashlib.sha1(v)
         d = h.hexdigest()
         return strutils.safe_decode(name), "{SHA1}%s" % d
     else:
         return strutils.safe_decode(name), strutils.safe_decode(value)