http-server-rs / http-server

Simple and configurable command-line HTTP server
https://crates.io/crates/http-server
Apache License 2.0
182 stars 20 forks source link

[Issue Report] Error when either `username`/`password` is used but its counterpart is missing #425

Open Antosser opened 8 months ago

Antosser commented 8 months ago

Right now, --username and --password are separate arguments that don't work without each other. Why not combine them into a single password? You can only have one username, so what's the point of even having them? If anyone wants, they can use a colon to separate the username and password. Also, no error is thrown if you only pass in one of them, which is confusing and actually tripped me up for a second a couple of months ago

EstebanBorai commented 8 months ago

This design is on purpose.

You can use NodeJS Http Server as example: https://www.npmjs.com/package/http-server.

In basic authentication, you use two inputs to build credentials for simplicity and at the same time flexibilty.

Any assumptions makes by app designer/developer would reflect on limitations.

Antosser commented 8 months ago

Alright! Haven't really looked into the standards. What do you think about throwing an error if only one of them is passed in?

EstebanBorai commented 8 months ago

Alright! Haven't really looked into the standards. What do you think about throwing an error if only one of them is passed in?

No worries! I agree with that! That validation is actually missing!