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

The http commands in the Network category don't seem to respect system HTTP/S proxy settings #8847

Closed
yonkeltron opened this issue Apr 10, 2023 · 5 comments · Fixed by #10401
Labels
networking All about our `http` and `url` commands and everything going accross the network.
Milestone

Comments

@yonkeltron
Copy link

Describe the bug

Sometimes I use nushell in environments where web traffic must be routed through a specific proxy in order to reach the internet. This is usually fine since most tools support proxy-specific configuration either through system-level configs or through environment variables. As such, my personal config has variables set such as HTTP_PROXY, HTTPS_PROXY, and NO_PROXY along with their lower-case equivalents. Unfortunately, it seems that http commands in the Network category do not respect any of these variables nor could I uncover how to make them aware of a proxy by some other means.

I did want to point out that I did see a half-filled out issue (now closed) which mentioned this matter, which would be #8743.

How to reproduce

From behind a proxy, even with environment variables set, the following fails:

> http get "https://google.com"
Error: nu::shell::network_failure

  × Network failure
   ╭─[entry #39:1:1]
 1 │ http get "https://google.com"
   ·          ──────────┬─────────
   ·                    ╰── Cannot make request to "https://google.com". Error is"...snip...,: status code 401 (redirected from https://google.com/)"

This happens every time but does not happen from machines which are not behind such web proxies.

Expected behavior

Given correct configuration, I would have expected the http get invocation to have succeeded and produced the same output as it does when not behind a proxy.

Screenshots

No response

Configuration

> version | transpose key value | to md --pretty
| key                | value                                                             |
| ------------------ | ----------------------------------------------------------------- |
| version            | 0.78.0                                                            |
| branch             |                                                                   |
| commit_hash        |                                                                   |
| build_os           | macos-x86_64                                                      |
| build_target       | x86_64-apple-darwin                                               |
| rust_version       | rustc 1.68.2 (9eb3afe9e 2023-03-27) (built from a source tarball) |
| cargo_version      | cargo 1.68.1 (6feb7c9cf 2023-03-26)                               |
| build_time         | 2023-04-04 18:47:00 +00:00                                        |
| build_rust_channel | release                                                           |
| features           | default, zip                                                      |
| installed_plugins  |                                                                   |

Additional context

Happy to provide more info wherever I can, and/or work to help test things. I'm a huge fan of the project and grateful for everyone's efforts.

Thanks,
+Jonathan

@sholderbach sholderbach added the networking All about our `http` and `url` commands and everything going accross the network. label Apr 17, 2023
@hinricht
Copy link

hinricht commented Sep 5, 2023

Same here, with nu 0.84.0. curl i.e. works beeing connected to the proxy, while http doesn't.

@hinricht
Copy link

hinricht commented Sep 5, 2023

Is there a workaround in which I can use i.e. curl to pipe fetched data into nushell structured format in the mean time ?

@sholderbach
Copy link
Member

Is there a workaround in which I can use i.e. curl to pipe fetched data into nushell structured format in the mean time ?

If you are for example dealing with a JSON API endpoint you can run curl ... | from json without too much trouble.

If we can inherit system proxy settings without too much trouble, we should probably look into fixing this but we certainly should not grow nushells networking commands to the configuration flexibility of curl. They already figured out the messy rough edges etc.

@hinricht
Copy link

hinricht commented Sep 6, 2023

Yeah, I didn't want to propose to get feature complete with curl :)
But beeing able to use http / all networking cmds honoring proxy env vars would be great, otherwise they are completely useless to me in my work environment.

@PyAntony
Copy link

PyAntony commented Sep 8, 2023

I agree. I was trying to make http work but I cant pass proxy options in any way. Hope this gets resolved. curl command works by the way.

fnuttens added a commit to fnuttens/nushell that referenced this issue Sep 17, 2023
fnuttens added a commit to fnuttens/nushell that referenced this issue Sep 23, 2023
WindSoilder pushed a commit that referenced this issue Sep 27, 2023
Closes #8847

# Description

If the `HTTP_PROXY` variable is found, use its value to setup ureq
proxy. I haven't implemented `NO_PROXY` at the moment.

# User-Facing Changes

No breaking change for the user, the network commands simply use an
environment variable.

# Tests + Formatting

The existing tests seem to run fine, although I can't think of a new
test to add.
@hustcer hustcer added this to the v0.86.0 milestone Sep 27, 2023
hardfau1t pushed a commit to hardfau1t/nushell that referenced this issue Dec 14, 2023
Closes nushell#8847

# Description

If the `HTTP_PROXY` variable is found, use its value to setup ureq
proxy. I haven't implemented `NO_PROXY` at the moment.

# User-Facing Changes

No breaking change for the user, the network commands simply use an
environment variable.

# Tests + Formatting

The existing tests seem to run fine, although I can't think of a new
test to add.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
networking All about our `http` and `url` commands and everything going accross the network.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants