Skip to content

feature request: dynamic HTTP method - requests.send(url, method="GET") #67

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

Closed
bellam opened this issue Aug 9, 2020 · 1 comment · Fixed by #94
Closed

feature request: dynamic HTTP method - requests.send(url, method="GET") #67

bellam opened this issue Aug 9, 2020 · 1 comment · Fixed by #94

Comments

@bellam
Copy link

bellam commented Aug 9, 2020

There are a lot of cases where the HTTP method (GET, POST etc) needs to be dynamic, especially in scripts. This would be a good feature to have.

Something like requests.send(url, method="GET")

For example, in javascript's fetch, there's
await fetch('/article/user/update', { method: 'POST',
or
in jquery, there's
$.ajax({ url: "/article/post/get", method: 'POST',

@lihaoyi
Copy link
Member

lihaoyi commented Dec 10, 2021

This can be done via

requests.Requester("GET", requests.Session()).apply("https://www.google.com")

@lihaoyi lihaoyi closed this as completed Dec 10, 2021
@lihaoyi lihaoyi reopened this Dec 10, 2021
@lihaoyi lihaoyi closed this as completed Dec 10, 2021
lihaoyi added a commit that referenced this issue Dec 10, 2021
Fixes #67
Fixes #52

This was always possible in a roundabout way via


```scala
requests.Requester("get", requests.Session()).apply("https://www.google.com")
```

But this PR adds a convenient alias and documents it for discoverability

```scala
requests.send("get")("https://www.google.com")
```
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

Successfully merging a pull request may close this issue.

2 participants