http-server icon indicating copy to clipboard operation
http-server copied to clipboard

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

Open Antosser opened this issue 1 year ago • 6 comments

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

Antosser avatar Feb 29 '24 19:02 Antosser

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.

LeoBorai avatar Mar 01 '24 01:03 LeoBorai

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

Antosser avatar Mar 01 '24 19:03 Antosser

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!

LeoBorai avatar Mar 02 '24 01:03 LeoBorai

@Antosser new smoke tests using pure Rust are in! Perhaps we can implement this as a feature on our most recent version using Hyper 1.x?

LeoBorai avatar Apr 25 '25 02:04 LeoBorai

Let's do that! Although I hear the term smoke test for the first time. Is it like rstest?

Antosser avatar Apr 25 '25 14:04 Antosser

Let's do that! Although I hear the term smoke test for the first time. Is it like rstest?

Hey @Antosser! Yeah so Smoke Tests is a CS concept which consists on simple tests to ensure basic behavior works as expected.

Here are more details: https://en.wikipedia.org/wiki/Smoke_testing_(software)

But basically in Basic Auth you could say that it doesn't panics when setting these fields.

LeoBorai avatar May 13 '25 00:05 LeoBorai