Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make HTTP request directly from URL object #281

Closed
Kilo59 opened this issue Jan 10, 2019 · 7 comments
Closed

Make HTTP request directly from URL object #281

Kilo59 opened this issue Jan 10, 2019 · 7 comments

Comments

@Kilo59
Copy link

Kilo59 commented Jan 10, 2019

The urlpath library has this convienent feature. Would it be possible to implement this in yarl?

Maybe have this installable as an extra?

pip install yarl[requests]

Do HTTP requests:

>>> url = URL('https://httpbin.org/get')
>>> url.get()
<Response [200]>

>>> url = URL('https://httpbin.org/post')
>>> url.post(data={'key': 'value'})
<Response [200]>

>>> url = URL('https://httpbin.org/delete')
>>> url.delete()
<Response [200]>

>>> url = URL('https://httpbin.org/patch')
>>> url.patch(data={'key': 'value'})
<Response [200]>

>>> url = URL('https://httpbin.org/put')
>>> url.put(data={'key': 'value'})
<Response [200]>
@aio-libs-bot
Copy link

GitMate.io thinks possibly related issues are #33 (Parse URL parameter), #272 (bool(URL()) should be False), #24 (TypeError in URL.with_query), #84 (Incorrect handling of '..' in url path), and #196 (Use custom URL parser).

@kxepal
Copy link
Member

kxepal commented Jan 10, 2019

I think this is out of the scope of this project. Also, which framework will it use behind the scenes? Why it's synchronous? How it will get manage sessions, keep-alives, cookies and the rest things which aren't related to URL object?

@Kilo59
Copy link
Author

Kilo59 commented Jan 10, 2019

I would say Requests with the requests defaults.
I'm not imagining it being anything more complicated than a convience wrapper around requests HTTP calls.

@kxepal
Copy link
Member

kxepal commented Jan 10, 2019

Ok. Then what stops you from writing:

>>> requests.get(URL('https://github.com'))
<Response [200]>

? In this case you gain full power of http client while URL remains about urls.

@Kilo59
Copy link
Author

Kilo59 commented Jan 10, 2019

Absolutely nothing.
Like I said, it would be a convenience feature.
And something I would be willing to work on if I thought it would be accepted.

@kxepal
Copy link
Member

kxepal commented Jan 10, 2019

That feature will cost a lot for this project with oblivious limitations, while it's all about to save you 9 chars from typing. Does it worth it?

@asvetlov
Copy link
Member

@Kilo59 sorry.
I/O is out of the project scope.
Feature requests like yours are never going to land here, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants