Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Commit

Permalink
🔨 Resolved some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
diazmartin committed Sep 9, 2020
1 parent 165e7b1 commit 04a2ee0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions meli/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,24 @@ def request(self, method, url, query_params=None, headers=None,
if 'Content-Type' not in headers:
headers['Content-Type'] = 'application/json'

encode_url = url
url=url.replace('%3F','?')
url=url.replace('%3D','=')
url=url.replace('%26','&')
url=url.replace('%7B','{')
url=url.replace('%7D','}')
url=url.replace('%2C',',')
already_querys = (encode_url == url)
url=url.replace('%2F','/')

try:
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
if query_params:
url += '?' + urlencode(query_params)
if already_querys:
url += '?' + urlencode(query_params)
else:
url += '&' + urlencode(query_params)
if re.search('json', headers['Content-Type'], re.IGNORECASE):
request_body = None
if body is not None:
Expand Down Expand Up @@ -205,8 +218,11 @@ def request(self, method, url, query_params=None, headers=None,
raise ApiException(status=0, reason=msg)
# For `GET`, `HEAD`
else:
if already_querys:
url += '?' + urlencode(query_params)
else:
url += '&' + urlencode(query_params)
r = self.pool_manager.request(method, url,
fields=query_params,
preload_content=_preload_content,
timeout=timeout,
headers=headers)
Expand Down

0 comments on commit 04a2ee0

Please sign in to comment.