Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
dw5 authored May 7, 2024
1 parent 1938316 commit 13ff5e8
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ lazy_static! {
}

fn main() {
let matches = clap::App::new("Simple HTTP(s) Server")
let matches = clap::App::new("Simpler HTTP(s) Server")
.setting(clap::AppSettings::ColoredHelp)
.version(crate_version!())
.arg(clap::Arg::with_name("root")
Expand All @@ -70,7 +70,7 @@ fn main() {
.arg(clap::Arg::with_name("upload")
.short("u")
.long("upload")
.help("Enable upload files. (multiple select) (CSRF token required)"))
.help("Enable upload files. (multiple select)"))
.arg(clap::Arg::with_name("redirect").long("redirect")
.takes_value(true)
.validator(|url_string| iron::Url::parse(url_string.as_str()).map(|_| ()))
Expand Down Expand Up @@ -214,7 +214,7 @@ fn main() {
.long("base-url")
.default_value("/")
.takes_value(true)
.help("Base URL to prepend in directory indexes. For reverse proxying. This prefix is supposed to be pre-stripped when reaching simple-http-server."))
.help("Base URL to prepend in directory indexes. For reverse proxying. This prefix is supposed to be pre-stripped when reaching simpler-http-server."))
.get_matches();

let root = matches
Expand Down Expand Up @@ -273,7 +273,7 @@ fn main() {
let host = format!("http://{}", &addr);

match open::that(&host) {
Ok(_) => println!("Openning {} in default browser", &host),
Ok(_) => println!("Opening {} in default browser", &host),
Err(err) => eprintln!("Unable to open in default browser {}", err),
}
}
Expand All @@ -282,11 +282,7 @@ fn main() {
let base_url: &str = matches.value_of("base-url").unwrap();

let upload: Option<Upload> = if upload_arg {
let token: String = thread_rng()
.sample_iter(&Alphanumeric)
.take(10)
.map(char::from)
.collect();
let token: String = "notoken";

Check failure on line 285 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

mismatched types

error[E0308]: mismatched types --> src/main.rs:285:29 | 285 | let token: String = "notoken"; | ------ ^^^^^^^^^- help: try using a conversion method: `.to_string()` | | | | | expected `String`, found `&str` | expected due to this

Check failure on line 285 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

mismatched types

error[E0308]: mismatched types --> src/main.rs:285:29 | 285 | let token: String = "notoken"; | ------ ^^^^^^^^^- help: try using a conversion method: `.to_string()` | | | | | expected `String`, found `&str` | expected due to this

Check failure on line 285 in src/main.rs

View workflow job for this annotation

GitHub Actions / Unitest (ubuntu-latest)

mismatched types

Check failure on line 285 in src/main.rs

View workflow job for this annotation

GitHub Actions / Build release Executable (ubuntu-latest)

mismatched types

Check failure on line 285 in src/main.rs

View workflow job for this annotation

GitHub Actions / Build release Executable (ubuntu-latest)

mismatched types

Check failure on line 285 in src/main.rs

View workflow job for this annotation

GitHub Actions / Build release Executable (ubuntu-latest)

mismatched types
Some(Upload { csrf_token: token })
} else {
None
Expand Down Expand Up @@ -402,7 +398,7 @@ fn main() {
let rv = if cert.is_some() {
printer
.println_err(
"{}: TLS support is not enabled during compilation of simple-http-server",
"{}: TLS support is not enabled during compilation of simpler-http-server",
&[("ERROR", &Some(build_spec(Some(Color::Red), true)))],
)
.unwrap();
Expand Down Expand Up @@ -567,12 +563,12 @@ impl MainHandler {
.unwrap();

// Check if they match
if self.upload.as_ref().unwrap().csrf_token != token {
/*if self.upload.as_ref().unwrap().csrf_token != token {
return Err((
status::BadRequest,
String::from("csrf token does not match"),
));
}
}*/

// Grab all the fields named files
let files_fields = match entries.fields.get("files") {
Expand Down

0 comments on commit 13ff5e8

Please sign in to comment.