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

Add support for HTTP OPTIONS method #9344

Closed
bgmort opened this issue Jun 2, 2023 · 6 comments · Fixed by #9365
Closed

Add support for HTTP OPTIONS method #9344

bgmort opened this issue Jun 2, 2023 · 6 comments · Fixed by #9365
Labels
enhancement New feature or request needs-triage An issue that hasn't had any proper look
Milestone

Comments

@bgmort
Copy link
Contributor

bgmort commented Jun 2, 2023

Related problem

There is no http options command, and no way to specify a custom HTTP verb. OPTIONS is useful for testing CORS implementations.

Describe the solution you'd like

A new http options command that is implemented the same way as the other http commands

Describe alternatives you've considered

No response

Additional context and details

No response

@bgmort bgmort added enhancement New feature or request needs-triage An issue that hasn't had any proper look labels Jun 2, 2023
@fdncred
Copy link
Collaborator

fdncred commented Jun 2, 2023

No clue what this means, please excuse my ignorance. Do you have examples and or pseudo code of how that would work in nushell?

@bgmort
Copy link
Contributor Author

bgmort commented Jun 2, 2023

I'm not familiar with Rust or the nushell codebase, but it's just like any other HTTP method/verb. For example, with curl you can use -X to supply the method, so a POST looks like this: curl -X POST url. An OPTIONS request looks like this: curl -X OPTIONS url.

@fdncred
Copy link
Collaborator

fdncred commented Jun 2, 2023

oh, interesting. i wonder if we could combine all our http subcommand and make it work like that?

@WindSoilder
Copy link
Collaborator

i wonder if we could combine all our http subcommand and make it work like that?

We can support that, but TBH I don't think it's a good idea, take http post as an example, it requires data to post, so it has an extra required arg. But http get don't need that arg.

@amtoine
Copy link
Member

amtoine commented Jun 8, 2023

TBH I don't think it's a good idea

with that in mind, i do not feel comfortable approving #9365 🤔

and on the other hand, if it's just another supported HTTP method, why not?

i've never seen all these methods, so i do not have a strong opinion at all on this 😌

fdncred pushed a commit that referenced this issue Jun 9, 2023
# Description
closes: #9344

Different to other http commands, `http options` command always returns
header, according to
[MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS),
the response information is included in header.

# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A
clippy::needless_collect -A clippy::result_large_err` to check that
you're using the standard code style
- `cargo test --workspace` to check that all tests pass
- `cargo run -- crates/nu-std/tests/run.nu` to run the tests for the
standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->
@hustcer hustcer added this to the v0.82.0 milestone Jun 9, 2023
@bgmort
Copy link
Contributor Author

bgmort commented Jun 30, 2023

Thanks for the quick turnaround on this! I have submitted a PR to improve the documented usage and examples: #9576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs-triage An issue that hasn't had any proper look
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants