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

Wget footers : hostname:port is repeated #1350

Open
jgranduel opened this issue Feb 20, 2024 · 5 comments
Open

Wget footers : hostname:port is repeated #1350

jgranduel opened this issue Feb 20, 2024 · 5 comments

Comments

@jgranduel
Copy link

The possibility to use wget for downloading a folder is a very valuable feature. I've tried miniserve-0.26 today and I see that hostname:port is written twice,like below:

Download folder:
 'https://<IP>:8080https://<IP>:8080/folder/?raw=true'

I think, but I am not 100% sure, that it happens when I use autogenerated certificates

./miniserve --tls-cert miniserve.cert --tls-key miniserve.key  -W   /path/to/my/folder
@maxlivi
Copy link

maxlivi commented Jun 19, 2024

Same here with letsencrypt certicate:

wget -rcnHp -R 'index.html*' --cut-dirs=1 --ask-password --user 'user' 'https://IP:8080https://IP:8080/?raw=true'

The QR code has the same issue

@svenstaro
Copy link
Owner

Ah, this is odd. I don't really have the time to look into this right now. Would you like to see whether you can find and fix this?

@jgranduel
Copy link
Author

jgranduel commented Jul 8, 2024

Hi,
thanks for your answer. I am not a Rust coder, but I tried to follow the functions calls. I think the error appears in listing.rs .

let abs_uri = {
    let res = Uri::builder()
        .scheme(req.connection_info().scheme())
        .authority(req.connection_info().host())
        .path_and_query(req.uri().to_string())
        .build();

    let abs_uri_string = req.uri().to_string();
    println!("listing abs_uri = {}", abs_uri_string);

    println!("listing scheme {}", req.connection_info().scheme().to_string());
    println!("listing host {}", req.connection_info().host().to_string());
    println!("listing uri {}", req.uri().to_string());

    match res {
        Ok(uri) => uri,
        Err(err) => return Ok(ServiceResponse::from_err(err, req.clone())),
    }
};
let abs_uri_string = abs_uri.to_string();
println!("listing abs_uri = {}", abs_uri_string);

I get :

git\miniserve> cargo build
   Compiling miniserve v0.27.1 (C:\git\miniserve)
    Finished dev [unoptimized + debuginfo] target(s) in 4.88s
    
git\miniserve> .\target\debug\miniserve.exe --tls-cert miniserve.cert --tls-key miniserve.key --auth-file ./authentications -z -W .
miniserve v0.27.1
Bound to [::]:8080, 0.0.0.0:8080
Serving path ...git\miniserve
Available at (non-exhaustive list):
    https://127.0.0.1:8080
    [...]

Quit by pressing CTRL-C
listing abs_uri = https://127.0.0.1:8080/
listing scheme https
listing host 127.0.0.1:8080
listing uri https://127.0.0.1:8080/
listing abs_uri = https://127.0.0.1:8080https://127.0.0.1:8080/

If I comment out

  // .authority(req.connection_info().host())

I get

git\miniserve> .\target\debug\miniserve.exe --tls-cert miniserve.cert --tls-key miniserve.key --auth-file ./authentications -z -W .
miniserve v0.27.1
Bound to [::]:8080, 0.0.0.0:8080
Serving path \\?\C:\git\miniserve
Available at (non-exhaustive list):
    https://127.0.0.1:8080

Quit by pressing CTRL-C
listing abs_uri = https://127.0.0.1:8080/
listing scheme https
listing host 127.0.0.1:8080
listing uri https://127.0.0.1:8080/

URL is correct, but I get a

500 Internal Server Error

authority missing

which needs more investigation and knowledge on my side 😉 !

IINW the issue is linked to authority as a simpler run is correct:

git\miniserve> .\target\debug\miniserve.exe  .
miniserve v0.27.1
Bound to [::]:8080, 0.0.0.0:8080
Serving path \\?\C:\git\miniserve
Available at (non-exhaustive list):
    http://127.0.0.1:8080

Quit by pressing CTRL-C
listing abs_uri = /
listing scheme http
listing host 127.0.0.1:8080
listing uri /
listing abs_uri = http://127.0.0.1:8080/

As uri above is '/' and abs_uri seems correct, the issue might rather be related to .path_and_query(req.uri().to_string()) 🤔.
Shouldn't we use .path_and_query(req.uri().path().to_string()) in Uri::builder() in some conditions ? I am not fully sure...

@maxlivi would .path_and_query(req.uri().path().to_string()) solve your issue? I don't know how to test.

@maxlivi
Copy link

maxlivi commented Jul 12, 2024

Hello @jgranduel

Just tested with .path_and_query(req.uri().path().to_string())

unfortunately it did not fix it

@jgranduel
Copy link
Author

@maxlivi Thank you for testing. I haven't seen any notification about your trial. No other idea as this issue is kind of annoying ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants