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

use axios instead of got for sending request #179

Closed
Gxmadix opened this issue Feb 18, 2023 · 7 comments
Closed

use axios instead of got for sending request #179

Gxmadix opened this issue Feb 18, 2023 · 7 comments

Comments

@Gxmadix
Copy link

Gxmadix commented Feb 18, 2023

Is it possible to use httpyac, with another library than got, got does not support body on get requests, but axios does.

This make these kinds of requests impossible to perform, it is not a good choice to pass the data in query params neither it is to make it a post request, a QUERY method is in study, but we are not there yet, so in the meantime a good workaround is to keep using libraries that support body with get method.

request

### find person list
# @name findPersonList
# @ref authSignin
GET {{Endpoint}}
Authorization: Bearer {{ authSignin.token }}

{
  "email": ["[email protected]", "[email protected]"]
}

Error message:

RequestError: The GET method cannot be used with a body at Gk._destroy

@Gxmadix
Copy link
Author

Gxmadix commented Feb 18, 2023

Finally, I found a way to make this work with got, by passing this option allowGetBody.

"httpyac.requestGotOptions": {
    "allowGetBody": true
  }

I am keeping this issue open, to let you decide guys if that's still worth keeping in mind as an option.

@AnWeber
Copy link
Owner

AnWeber commented Feb 19, 2023

The decision for got was deliberate. My POC had still used axios. The main reason was that got also supports HTTP/2 and I wanted to be as close as possible to the actual browser call. But I left it open to implement a axios plugin on your own. You would just to implement httpClientProvider which wraps all calls to got. But I didn't implement the interface cleanly, because in some places I still use the Got Request Options myself (like in digestVariableProvider).
I will put this on my bucket list for improvements.

I did not know the setting and I add it. Even if I would rather not use it myself on the server side.

@AnWeber AnWeber closed this as completed Feb 19, 2023
@Kaarel
Copy link

Kaarel commented Mar 7, 2023

https://github.com/sindresorhus/got/blob/main/documentation/2-options.md#allowgetbody

"However, the HTTP/2 specification says:
An HTTP GET request includes request header fields and no payload body"

Doesn't sound like GET requests were designed to do this...

@AnWeber
Copy link
Owner

AnWeber commented Mar 7, 2023

@Kaarel I agree with you that it is not part of the specification, and for that reason I will not use it myself in any way. It is not worth the trouble. However, it shouldn't be a problem to allow it in for use in httpyac. Or do you know constellations where this can become a problem ?

@Kaarel
Copy link

Kaarel commented Mar 10, 2023

Nah, just noticed this thread and started wondering about bodies with GET requests :)

@Gxmadix
Copy link
Author

Gxmadix commented Mar 10, 2023

@Kaarel, in fact in the front side, it is much easier to work with a get request when handling a request like a search, principally for caching, and on the back side I am much more comfortable with a get since the request is not changing any database or server state, last time I honestly searched some hours on this topic, and I can say that the number of people not seeing any problem with using a body in get is increasing with years, there will be some old servers that will ignore the body on gets, but the risk is still small.
There are a lot of debates around this topic and surely at the end, we will have a new protocol that can have a body without editing the server state, I am waiting for it.

@AnWeber
Copy link
Owner

AnWeber commented Mar 10, 2023

@Gxmadix I fully agree with your arguments. I am just a lame duck. I fear that a firewall, Ingress or reverse proxy will remove my body. I have never tried it though. But maybe this would be a topic to bring up in my environment. I know the problem only too well.

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

3 participants