skyfireandJarvis-AI-42 687d7bcac5 fix: support IPv6 zone IDs in http commands (#19213)
Fixes #9065

## Description

`http get 'http://[fe80::13%eth0]'` (and the other `http *` commands)
fail because `url::Url::parse` does not support IPv6 zone IDs (e.g.
`%eth0`), per the WHATWG URL standard. `curl` handles these URLs fine.

The fix now validates and drives requests with `http::Uri`, the same
parser ureq uses, so nushell and ureq agree on which URLs are valid.

1. **`crates/nu-command/src/network/http/client.rs`**
- `http_parse_url` validates with `http::Uri` instead of `url::Url`
(which rejects zone IDs). It returns the raw URL string; the
`strip_ipv6_zone_id` helper and the returned `Url` are gone.
- A new `authority_is_well_formed` check rejects URLs that `http::Uri`
would otherwise accept leniently, e.g. trailing garbage after an IPv6
literal (`[fe80::13%eth0]foo`) or non-numeric/out-of-range ports
(`host:abc`, `host:99999`). These would silently send the request to a
different host or port.
- `request_set_host_header` sets the `Host` header without the zone ID
(matching curl) when the authority contains one, so strict servers don't
reject the request. A user-provided `Host` header is left untouched.
- `transform_response_using_content_type` derives the `text/plain` file
extension from `http::Uri::path()` so zone-ID URLs no longer fail after
the request has been sent.
2. **`crates/nu-command/src/network/http/resolver.rs`**
- `uri.host()` returns IPv6 addresses wrapped in square brackets (e.g.
`[fe80::13%eth0]`), which `dns_lookup::getaddrinfo` cannot resolve. The
brackets are stripped before resolution, so `getaddrinfo` handles the
zone ID natively (converting the interface name to a scope ID).
- The RFC 6874 `%25` form (e.g. `[fe80::1%25lo0]`) is decoded to a
literal `%` before `getaddrinfo`.
   - `host` stays an `Option` and is passed to `getaddrinfo` as-is.

## User-facing changes (Release notes)

`http get`, `http post`, and the other `http *` commands now accept
**`http://`** URLs with IPv6 literals and link-local zone IDs, e.g.
`http get 'http://[fe80::13%eth0]'`. Plain IPv6 literals (e.g. `http get
'http://[::1]:8080/a.txt'`) work as well. Previously these URLs failed
to parse or resolve.

Note: `https://` URLs with a zone ID are **not** supported. ureq builds
the rustls `ServerName` from the bracket-stripped host, and
`fe80::13%eth0` is neither a valid IP nor a valid DNS name, so TLS
handshakes fail. This is a ureq/rustls limitation and cannot be fixed
from nushell.

## Tests

- `cargo check -p nu-command` passes
- `cargo test -p nu-command --lib network::http` — 20 tests pass,
including:
  - `test_http_parse_url_with_ipv6_zone_id`
  - `test_http_parse_url_rejects_invalid_ipv6_with_zone_id`
  - `test_authority_is_well_formed`
  - `test_request_set_host_header_strips_zone_id`
  - `test_request_set_host_header_leaves_other_urls_alone`
- `cargo test -p nu-command --test tests -- commands::network::http` —
87 tests pass, including the new `http_get_ipv6_literal`, which binds
`[::1]` and makes a real `text/plain` request through
`DnsLookupResolver`.
- `cargo fmt --all -- --check`, `cargo clippy -p nu-command
--all-targets -D warnings` and `typos` are clean.

## Review feedback

All findings from the review have been addressed:

1. **Text/plain responses fail after the request is sent** —
`transform_response_using_content_type` now uses `http::Uri::path()`
instead of `url::Url::parse`.
2. **Zone ID ends up in the `Host` header** — `request_set_host_header`
strips it (like curl); a user-set `Host` header is respected.
3. **Validate with `http::Uri` instead of strip-and-reparse** — done;
`strip_ipv6_zone_id` and the returned `Url` are removed. URLs that ureq
rejects (e.g. `http://[fe80::1%lo 0]:18913/`) are now rejected up front
by `http_parse_url`.
4. **RFC 6874 `%25` form can't resolve** — the resolver decodes `%25` to
`%` before `getaddrinfo`.
5. **No test makes a real request to an IPv6 literal** — added
`http_get_ipv6_literal`.
6. **Keep `host` as an `Option`** — done.
7. **HTTPS zone-ID URLs still fail** — a ureq/rustls limitation; the
release notes above are now scoped to `http://`.

---------

Co-authored-by: Jarvis-AI-42 <skyfireitdiy@gmail.com>
2026-10-13 07:54:55 -05:00
2026-05-14 22:40:32 +03:00
2024-06-06 08:53:34 +08:00
2026-04-08 06:58:29 -05:00
2026-04-07 09:56:38 -05:00

Nushell

Crates.io Build Status Nightly Build Discord The Changelog #363 GitHub commit activity GitHub contributors

A new type of shell.

Example of nushell

Table of Contents

Status

This project has reached a minimum-viable-product level of quality. Many people use it as their daily driver, but it may be unstable for some commands. Nu's design is subject to change as it matures.

Learning About Nu

The Nushell book is the primary source of Nushell documentation. You can find a full list of Nu commands in the book, and we have many examples of using Nu in our cookbook.

We're also active on Discord; come and chat with us!

Installation

To quickly install Nu:

# Linux and macOS
brew install nushell
# Windows
winget install nushell

To use Nu in GitHub Action, check setup-nu for more detail.

Detailed installation instructions can be found in the installation chapter of the book. Nu is available via many package managers:

Packaging status

For details about which platforms the Nushell team actively supports, see our platform support policy.

Configuration

The default configurations can be found at sample_config which are the configuration files one gets when they start up Nushell for the first time.

It sets all of the default configuration to run Nushell. From here one can then customize this file for their specific needs.

To see where config.nu is located on your system simply type this command.

$nu.config-path

Please see our book for all of the Nushell documentation.

Philosophy

Nu draws inspiration from projects like PowerShell, functional programming languages, and modern CLI tools. Rather than thinking of files and data as raw streams of text, Nu looks at each input as something with structure. For example, when you list the contents of a directory what you get back is a table of rows, where each row represents an item in that directory. These values can be piped through a series of steps, in a series of commands called a 'pipeline'.

Pipelines

In Unix, it's common to pipe between commands to split up a sophisticated command over multiple steps. Nu takes this a step further and builds heavily on the idea of pipelines. As in the Unix philosophy, Nu allows commands to output to stdout and read from stdin. Additionally, commands can output structured data (you can think of this as a third kind of stream). Commands that work in the pipeline fit into one of three categories:

  • Commands that produce a stream (e.g., ls)
  • Commands that filter a stream (e.g., where type == "dir")
  • Commands that consume the output of the pipeline (e.g., table)

Commands are separated by the pipe symbol (|) to denote a pipeline flowing left to right.

ls | where type == "dir" | table
# => ╭────┬──────────┬──────┬─────────┬───────────────╮
# => │ #  │   name   │ type │  size   │   modified    │
# => ├────┼──────────┼──────┼─────────┼───────────────┤
# => │  0 │ .cargo   │ dir  │     0 B │ 9 minutes ago │
# => │  1 │ assets   │ dir  │     0 B │ 2 weeks ago   │
# => │  2 │ crates   │ dir  │ 4.0 KiB │ 2 weeks ago   │
# => │  3 │ docker   │ dir  │     0 B │ 2 weeks ago   │
# => │  4 │ docs     │ dir  │     0 B │ 2 weeks ago   │
# => │  5 │ images   │ dir  │     0 B │ 2 weeks ago   │
# => │  6 │ pkg_mgrs │ dir  │     0 B │ 2 weeks ago   │
# => │  7 │ samples  │ dir  │     0 B │ 2 weeks ago   │
# => │  8 │ src      │ dir  │ 4.0 KiB │ 2 weeks ago   │
# => │  9 │ target   │ dir  │     0 B │ a day ago     │
# => │ 10 │ tests    │ dir  │ 4.0 KiB │ 2 weeks ago   │
# => │ 11 │ wix      │ dir  │     0 B │ 2 weeks ago   │
# => ╰────┴──────────┴──────┴─────────┴───────────────╯

Because most of the time you'll want to see the output of a pipeline, table is assumed. We could have also written the above:

ls | where type == "dir"

Being able to use the same commands and compose them differently is an important philosophy in Nu. For example, we could use the built-in ps command to get a list of the running processes, using the same where as above.

ps | where cpu > 0
# => ╭───┬───────┬──────┬───────────┬──────┬─────────┬───────┬────────────┬──────────╮
# => │ # │  pid  │ ppid │   name    │ user │ status  │  cpu  │  cpu_time  │   mem    │
# => ├───┼───────┼──────┼───────────┼──────┼─────────┼───────┼────────────┼──────────┤
# => │ 0 │  2240 │ 9872 │ Slack.exe │ dev  │ Running │ 16.40 │ 1min 12sec │ 178.3 MB │
# => │ 1 │ 16948 │ 9872 │ Slack.exe │ dev  │ Running │ 16.32 │      48sec │ 205.0 MB │
# => │ 2 │ 17700 │ 4632 │ nu.exe    │ dev  │ Running │  3.77 │       2sec │  26.1 MB │
# => ╰───┴───────┴──────┴───────────┴──────┴─────────┴───────┴────────────┴──────────╯

Opening files

Nu can load file and URL contents as raw text or structured data (if it recognizes the format). For example, you can load a .toml file as structured data and explore it:

open Cargo.toml
# => ╭──────────────────┬────────────────────╮
# => │ bin              │ [table 1 row]      │
# => │ dependencies     │ {record 25 fields} │
# => │ dev-dependencies │ {record 8 fields}  │
# => │ features         │ {record 10 fields} │
# => │ package          │ {record 13 fields} │
# => │ patch            │ {record 1 field}   │
# => │ profile          │ {record 3 fields}  │
# => │ target           │ {record 3 fields}  │
# => │ workspace        │ {record 1 field}   │
# => ╰──────────────────┴────────────────────╯

We can pipe this into a command that gets the contents of one of the columns:

open Cargo.toml | get package
# => ╭───────────────┬────────────────────────────────────╮
# => │ authors       │ [list 1 item]                      │
# => │ default-run   │ nu                                 │
# => │ description   │ A new type of shell                │
# => │ documentation │ https://www.nushell.sh/book/       │
# => │ edition       │ 2018                               │
# => │ exclude       │ [list 1 item]                      │
# => │ homepage      │ https://www.nushell.sh             │
# => │ license       │ MIT                                │
# => │ metadata      │ {record 1 field}                   │
# => │ name          │ nu                                 │
# => │ repository    │ https://github.com/nushell/nushell │
# => │ rust-version  │ 1.60                               │
# => │ version       │ 0.72.0                             │
# => ╰───────────────┴────────────────────────────────────╯

And if needed we can drill down further:

open Cargo.toml | get package.version
# => 0.72.0

Plugins

Nu supports plugins that offer additional functionality to the shell and follow the same structured data model that built-in commands use. There are a few examples in the crates/nu_plugins_* directories.

Plugins are binaries that are available in your path and follow a nu_plugin_* naming convention. These binaries interact with nu via a simple JSON-RPC protocol where the command identifies itself and passes along its configuration, making it available for use. If the plugin is a filter, data streams to it one element at a time, and it can stream data back in return via stdin/stdout. If the plugin is a sink, it is given the full vector of final data and is given free reign over stdin/stdout to use as it pleases.

The awesome-nu repo lists a variety of nu-plugins while the showcase repo shows off informative blog posts that have been written about Nushell along with videos that highlight technical topics that have been presented.

Goals

Nu adheres closely to a set of goals that make up its design philosophy. As features are added, they are checked against these goals.

  • First and foremost, Nu is cross-platform. Commands and techniques should work across platforms and Nu has first-class support for Windows, macOS, and Linux.

  • Nu ensures compatibility with existing platform-specific executables.

  • Nu's workflow and tools should have the usability expected of modern software in 2022 (and beyond).

  • Nu views data as either structured or unstructured. It is a structured shell like PowerShell.

  • Finally, Nu views data functionally. Rather than using mutation, pipelines act as a means to load, change, and save data without mutable state.

Officially Supported By

Please submit an issue or PR to be added to this list.

Contributing

See Contributing for details. Thanks to all the people who already contributed!

License

The project is made available under the MIT license. See the LICENSE file for more information.

Languages
Rust 97.2%
Nushell 2.6%