Bug 264757 - fetch: Show correct port number in -vv output
Summary: fetch: Show correct port number in -vv output
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: easy, needs-qa
Depends on:
Blocks:
 
Reported: 2022-06-18 20:37 UTC by Mallory
Modified: 2024-05-06 00:25 UTC (History)
2 users (show)

See Also:
koobs: maintainer-feedback? (kevans)
koobs: mfc-stable13?
koobs: mfc-stable12?


Attachments
usr.bin/fetch: Show correct port number in -vv output (1.04 KB, text/plain)
2022-06-18 20:37 UTC, Mallory
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mallory 2022-06-18 20:37:34 UTC
Created attachment 234771 [details]
usr.bin/fetch: Show correct port number in -vv output

The code in libfetch only sets the port number in `-vv` output when there's a `:` before the path component. This patch sets the port number based on the URL scheme.

Old behavior:

```
% fetch -vv https://www.freebsd.org/
scheme:   "https"
user:     ""
password: ""
host:     "www.freebsd.org"
port:     "0"
document: "/"
---> www.freebsd.org:443
```

New behavior:

```
% fetch -vv https://www.freebsd.org/
scheme:   "https"
user:     ""
password: ""
host:     "www.freebsd.org"
port:     "443"
document: "/"
---> www.freebsd.org:443
```
Comment 1 Kyle Ambroff-Kao 2024-05-06 00:25:58 UTC
I tried this, and it does work for HTTP and HTTPS URls. But fetch supports other protocols, so a fix for this should work no matter which scheme you use. ftp for example would not be covered by this.