mirror of
https://github.com/Mailu/Mailu.git
synced 2025-01-30 04:30:49 +02:00
Merge pull request #3 from Nebukadneza/add_key_url_quoting
URL-Quote the key in HTTP requests
This commit is contained in:
parent
080e76f972
commit
6fadd39aea
@ -3,7 +3,7 @@
|
||||
|
||||
import aiohttp
|
||||
import logging
|
||||
|
||||
from urllib.parse import quote
|
||||
|
||||
class UrlTable(object):
|
||||
""" Resolve an entry by querying a parametrized GET URL.
|
||||
@ -23,7 +23,8 @@ class UrlTable(object):
|
||||
if ns is not None:
|
||||
key += "/" + ns
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get(self.url_pattern.format(key)) as request:
|
||||
quoted_key = quote(key)
|
||||
async with session.get(self.url_pattern.format(quoted_key)) as request:
|
||||
if request.status == 200:
|
||||
result = await request.json()
|
||||
logging.debug("Table get {} is {}".format(key, result))
|
||||
@ -40,7 +41,8 @@ class UrlTable(object):
|
||||
if ns is not None:
|
||||
key += "/" + ns
|
||||
async with aiohttp.ClientSession() as session:
|
||||
await session.post(self.url_pattern.format(key), json=value)
|
||||
quoted_key = quote(key)
|
||||
await session.post(self.url_pattern.format(quoted_key), json=value)
|
||||
|
||||
async def iter(self, cat):
|
||||
""" Iterate the given key (experimental)
|
||||
|
Loading…
x
Reference in New Issue
Block a user