|
13 | 13 | from email.parser import Parser |
14 | 14 | from http.client import HTTPResponse |
15 | 15 | from io import BytesIO |
| 16 | +from urllib.parse import urlencode |
16 | 17 |
|
17 | | -try: |
18 | | - # For Python 3.0 and later |
19 | | - from urllib.parse import quote |
20 | | -except ImportError: |
21 | | - # Fallback to urllib2 |
22 | | - from urllib2 import quote |
23 | 18 |
|
24 | 19 | from pyodata.exceptions import HttpError, PyODataException, ExpressionError, ProgramError |
25 | 20 | from . import model |
@@ -54,7 +49,7 @@ def encode_multipart(boundary, http_requests): |
54 | 49 |
|
55 | 50 | # request line (method + path + query params) |
56 | 51 | line = f'{req.get_method()} {req.get_path()}' |
57 | | - query_params = '&'.join(['{}={}'.format(key, val) for key, val in req.get_query_params().items()]) |
| 52 | + query_params = urlencode(req.get_query_params()) |
58 | 53 | if query_params: |
59 | 54 | line += '?' + query_params |
60 | 55 | line += ' HTTP/1.1' |
@@ -316,7 +311,7 @@ def execute(self): |
316 | 311 | if body: |
317 | 312 | self._logger.debug(' body: %s', body) |
318 | 313 |
|
319 | | - params = "&".join("%s=%s" % (k, v) for k, v in self.get_query_params().items()) |
| 314 | + params = urlencode(self.get_query_params()) |
320 | 315 | response = self._connection.request( |
321 | 316 | self.get_method(), url, headers=headers, params=params, data=body) |
322 | 317 |
|
@@ -1216,7 +1211,7 @@ def _build_expression(self, field_name, operator, value): |
1216 | 1211 | def __str__(self): |
1217 | 1212 | expressions = self._process_expressions() |
1218 | 1213 | result = self._combine_expressions(expressions) |
1219 | | - return quote(result) |
| 1214 | + return result |
1220 | 1215 |
|
1221 | 1216 |
|
1222 | 1217 | class GetEntitySetRequest(QueryRequest): |
|
0 commit comments