aio-libs / aio-libs/aiohttp

prepared URL API

未关闭
#2,516 6 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看
client enhancement
主要语言
Python
星标
16.5k
派生
2.4k
平均合并
17 小时 22 分钟
30 天内合并 PR
212

描述

Is there a way to get prepared URL, which will be used in a query? Something like:
```
req = ClientSession().Request(method='GET', url='http://path.org', data={'a':1, 'b':2})
url = req.prepared_url() -> 'http://path.org?a=1&b=2'
req.headers.update({'auth': auth_fun(url)})
```
I need this for authentication purposes.
Till now I used `requests.Request.prepare().path_url` for the URL and yet sent aiohttp request, but I just found out that sometimes the argument ordering in the output URL will differ between the libraries. Nasty bug.

My first reflex was to try with `ClientRequest` but it requries YARL's URL object (I think?), which is doable I guess, but maybe there's something short and sweet already available.

Can you please help me out?

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。