Repository: thecoshman/http (language: rust)

Issue:
x86_64-unknown-linux-musl build failed
src/util/os/non_windows_non_macos.rs:39:47

# mismatched type
```
error[E0308]: mismatched types
  --> src/util/os/non_windows_non_macos.rs:39:47
   |
39 |             let ok = unsafe { ioctl(dev_file, BLKGETSIZE, &mut block_count as *mut c_ulong) } == 0;
   |                                               ^^^^^^^^^^ expected `i32`, found `u64`
```
I change it to this:
```
let ok = unsafe { ioctl(dev_file, BLKGETSIZE as i32, &mut block_count as *mut c_ulong) } == 0;
```

# can't find ssl/crypto
```
= note: rust-lld: error: unable to find library -lssl
        rust-lld: error: unable to find library -lcrypto
```
OS: CentOS 7.8 x86_64
I have installed the openssl-devel.x86_64 and openssl-static.x86_64 library.
Compile Command:
```
CC=x86_64-linux-musl-gcc cargo build --release --target=x86_64-unknown-linux-musl
```


Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 6a63c61..6f68df4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,7 +9,7 @@ categories = ["network-programming", "web-programming::http-server"]
 license = "MIT"
 build = "build.rs"
 # Remember to also update in appveyor.yml
-version = "1.10.0"
+version = "1.10.1"
 # Remember to also update in http.md
 authors = ["thecoshman <rust@thecoshman.com>",
            "nabijaczleweli <nabijaczleweli@nabijaczleweli.xyz>",
diff --git a/appveyor.yml b/appveyor.yml
index 000ab6d..3aca73a 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,4 +1,4 @@
-version: 1.10.0-{build}
+version: 1.10.1-{build}
 
 skip_tags: false
 
@@ -11,7 +11,11 @@ install:
   - set PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%;C:\Users\appveyor\.cargo\bin
   # https://www.msys2.org/news/#2020-05-17-32-bit-msys2-no-longer-actively-supported
   - curl -SL http://repo.msys2.org/msys/x86_64/msys2-keyring-r21.b39fb11-1-any.pkg.tar.xz -oC:\msys2-keyring.txz
+  - curl -SL http://repo.msys2.org/msys/x86_64/zstd-1.4.4-1-x86_64.pkg.tar.xz -oC:\zstd.txz
+  - curl -SL http://repo.msys2.org/msys/x86_64/pacman-5.2.2-5-x86_64.pkg.tar.xz -oC:\pacman.txz
   - pacman --noconfirm -U C:\msys2-keyring.txz
+  - pacman --noconfirm -U C:\zstd.txz
+  - pacman --noconfirm -U C:\pacman.txz
   - bash -lc "pacman --needed --noconfirm -Sy pacman-mirrors"
   - bash -lc "pacman --noconfirm -Sy pacman"
   - bash -lc "pacman --noconfirm -Su"
@@ -28,21 +32,21 @@ build: off
 build_script:
   - git submodule update --init --recursive
   - cargo build --verbose --release
-  - cp target\release\http.exe http-v1.10.0.exe
-  - strip --strip-all --remove-section=.comment --remove-section=.note http-v1.10.0.exe
-  - makensis -DHTTP_VERSION=v1.10.0 install.nsi
+  - cp target\release\http.exe http-v1.10.1.exe
+  - strip --strip-all --remove-section=.comment --remove-section=.note http-v1.10.1.exe
+  - makensis -DHTTP_VERSION=v1.10.1 install.nsi
 
 test: off
 test_script:
   - cargo test --verbose --release
 
 artifacts:
-  - path: http-v1.10.0.exe
-  - path: http v1.10.0 installer.exe
+  - path: http-v1.10.1.exe
+  - path: http v1.10.1 installer.exe
 
 deploy:
   provider: GitHub
-  artifact: /http.*v1.10.0.*\.exe/
+  artifact: /http.*v1.10.1.*\.exe/
   auth_token:
     secure: ZTXvCrv9y01s7Hd60w8W7NaouPnPoaw9YJt9WhWQ2Pep8HLvCikt9Exjkz8SGP9P
   on:
diff --git a/build.rs b/build.rs
index c3cc83c..4f46851 100644
--- a/build.rs
+++ b/build.rs
@@ -27,12 +27,6 @@ static IOCTL_INCLUDE_SKELETON: &str = r#"
 static BLKGETSIZE: {type} = {expr} as {type};
 "#;
 
-#[cfg(all(not(any(target_os = "windows", target_os = "macos")), not(target_env = "musl")))]
-static IOCTL_REQUEST_TYPE: &str = "libc::c_ulong";
-
-#[cfg(all(not(any(target_os = "windows", target_os = "macos")), target_env = "musl"))]
-static IOCTL_REQUEST_TYPE: &str = "libc::c_int";
-
 
 fn main() {
     embed_resources();
@@ -57,9 +51,14 @@ fn get_ioctl_data() {
     let ioctl_preprocessed = String::from_utf8(cc::Build::new().file(ioctl_source).expand()).unwrap();
     let blkgetsize_expr = ioctl_preprocessed.lines().next_back().unwrap().replace("U", "");
 
+    let ioctl_request_type = match &env::var("CARGO_CFG_TARGET_ENV").expect("CARGO_CFG_TARGET_ENV")[..] {
+        "musl" => "libc::c_int",
+        _ => "libc::c_ulong",
+    };
+
     let ioctl_include = ioctl_dir.join("ioctl.rs");
     File::create(&ioctl_include)
         .unwrap()
-        .write_all(IOCTL_INCLUDE_SKELETON.replace("{type}", IOCTL_REQUEST_TYPE).replace("{expr}", &blkgetsize_expr).as_bytes())
+        .write_all(IOCTL_INCLUDE_SKELETON.replace("{type}", ioctl_request_type).replace("{expr}", &blkgetsize_expr).as_bytes())
         .unwrap();
 }
diff --git a/src/ops/mod.rs b/src/ops/mod.rs
index 1221f96..4ffa1ed 100644
--- a/src/ops/mod.rs
+++ b/src/ops/mod.rs
@@ -740,7 +740,7 @@ impl HttpHandler {
         //     https://cloud.githubusercontent.com/assets/6709544/21442017/9eb20d64-c89b-11e6-8c7b-888b5f70a403.png
         //   - With following slash:
         //     https://cloud.githubusercontent.com/assets/6709544/21442028/a50918c4-c89b-11e6-8936-c29896947f6a.png
-        Ok(Response::with((status::MovedPermanently, Header(headers::Server(USER_AGENT.to_string())), Header(headers::Location(new_url)))))
+        Ok(Response::with((status::SeeOther, Header(headers::Server(USER_AGENT.to_string())), Header(headers::Location(new_url)))))
     }
 
     fn handle_get_mobile_dir_listing(&self, req: &mut Request, req_p: PathBuf) -> IronResult<Response> {
@@ -763,7 +763,7 @@ impl HttpHandler {
                     file_time_modified_p(req_p.parent().expect("Failed to get requested directory's parent directory"))
                         .strftime("%F %T")
                         .unwrap(),
-                    up_path = slash_idx.map(|i| &rel_noslash[0..i]).unwrap_or(""),
+                    up_path = slash_idx.map(|i| &rel_noslash[0..i]).unwrap_or("").replace('%', "%25").replace('#', "%23").replace('[', "%5B").replace(']', "%5D"),
                     up_path_slash = if slash_idx.is_some() { "/" } else { "" })
         };
         let list_s = req_p.read_dir()
@@ -815,8 +815,8 @@ impl HttpHandler {
                         } else {
                             DisplayThree("", String::new(), "")
                         },
-                        path = format!("/{}", relpath).replace("//", "/").replace('%', "%25").replace('#', "%23"),
-                        fname = fname.replace('%', "%25").replace('#', "%23"))
+                        path = format!("/{}", relpath).replace("//", "/").replace('%', "%25").replace('#', "%23").replace('[', "%5B").replace(']', "%5D"),
+                        fname = fname.replace('%', "%25").replace('#', "%23").replace('[', "%5B").replace(']', "%5D"))
             });
 
         self.handle_generated_response_encoding(req,
@@ -866,7 +866,7 @@ impl HttpHandler {
                          <td><a href=\"/{up_path}{up_path_slash}\">&nbsp;</a></td> \
                          <td><a href=\"/{up_path}{up_path_slash}\">&nbsp;</a></td></tr>",
                     file_time_modified_p(req_p.parent().expect("Failed to get requested directory's parent directory")).strftime("%F %T").unwrap(),
-                    up_path = slash_idx.map(|i| &rel_noslash[0..i]).unwrap_or(""),
+                    up_path = slash_idx.map(|i| &rel_noslash[0..i]).unwrap_or("").replace('%', "%25").replace('#', "%23").replace('[', "%5B").replace(']', "%5D"),
                     up_path_slash = if slash_idx.is_some() { "/" } else { "" })
         };
 
@@ -930,8 +930,8 @@ impl HttpHandler {
                         } else {
                             DisplayThree("", "", "")
                         },
-                        path = format!("/{}", relpath).replace("//", "/").replace('%', "%25").replace('#', "%23"),
-                        fname = fname.replace('%', "%25").replace('#', "%23"))
+                        path = format!("/{}", relpath).replace("//", "/").replace('%', "%25").replace('#', "%23").replace('[', "%5B").replace(']', "%5D"),
+                        fname = fname.replace('%', "%25").replace('#', "%23").replace('[', "%5B").replace(']', "%5D"))
             });
 
         self.handle_generated_response_encoding(req,


Test patch: