aio-libs / aio-libs/aiohttp

prepared URL API

Đang mở
#2,516 6 bình luận 3 reaction 0 người được giao Xem trên GitHub
client enhancement
Ngôn ngữ chính
Python
Star
16.5k
Fork
2.4k
Merge trung bình
17 giờ 22 phút
Pull request đã merge (30 ngày)
212

Mô tả

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?

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.