Revision 023230b5 kamaki/clients/connection/kamakicon.py

b/kamaki/clients/connection/kamakicon.py
46 46
from httplib import ResponseNotReady
47 47

  
48 48

  
49
def _encode(v):
50
    if v and isinstance(v, unicode):
51
        return quote(v.encode('utf-8'))
52
    return v
53

  
54

  
49 55
class KamakiHTTPResponse(KamakiResponse):
50 56

  
51 57
    def _get_response(self):
......
135 141
        params = dict(self.params)
136 142
        params.update(extra_params)
137 143
        for i, (key, val) in enumerate(params.items()):
138
            if isinstance(val, unicode):
139
                val = quote(val.encode('utf-8'))
144
            val = _encode(val)
140 145
            url += '%s%s' % ('&' if i else '?', key)
141 146
            if val:
142 147
                url += '=%s' % val
......
171 176
        (scheme, netloc) = self._retrieve_connection_info(async_params)
172 177
        headers = dict(self.headers)
173 178
        for k, v in async_headers.items():
174
            v = quote(v.encode('utf-8')) if isinstance(v, unicode) else str(v)
179
            v = _encode(v)
175 180
            headers[k] = v
176 181

  
177 182
        #de-unicode headers to prepare them for http
178 183
        http_headers = {}
179 184
        for k, v in headers.items():
180
            v = quote(v.encode('utf-8')) if isinstance(v, unicode) else str(v)
185
            v = _encode(v)
181 186
            http_headers[k] = v
182 187

  
183 188
        #get connection from pool

Also available in: Unified diff