Host These Things Please - a basic http server for hosting a folder fast and simply

Overview

http Travis build status AppVeyor build status Licence Crates.io version

Host These Things Please - a basic HTTP server for hosting a folder fast and simply

Selected features

See the manpage for full list.

  • Symlinks followed by default (disableable via -s option)
  • Index generation for directories
  • Sane defaults (like hosted dir (.) and port (first free one from range 8000-9999))
  • Correct MIME type for served files
  • Handled request methods: OPTIONS, GET, PUT, DELETE, HEAD and TRACE ("writing" methods are off by default, enable via -w switch)
  • Proper handling of percent-encoded URLs (like асдф fdsa)
  • Good symlink handling compatible with Windows
  • Multitude of information in directory indices
  • Serving index files like index.{html,htm,shtml} from directories (disableable via -i switch)
  • Drag&Drop to upload files (with -w specified)
  • Smart encoding of generated and filesystem-originating responses (disableable via -e switch)
  • Full Range header support
  • Hosting with an (optional) optionally autogenerated TLS certificate
  • Arbitrarily nested username/password authentication
  • Per-request bandwidth cap
  • Per-extension-overridable MIME-types with reasonable guesses
  • WebDAV/RFC2518 support, tested with the Linux davfs2 helper, Windows network filesystem support (out-of-box), and the Total Commander WebDAV plugin
  • RFSAPI support (format spec) (explorable from commandline with D'Oh)

Manpage

Installation

If you have cargo installed (you're a Rust developer) all you need to do is:

cargo install https

Which will install http and httplz (identical, disable one or another if they clash) in the folder where all other binaries go.

If, however, you're not a Rust developer, but you have sh-like shell, you can use an installer (works on Windows and Linux):

curl -SsL https://cdn.rawgit.com/thecoshman/http/master/install.sh | sh
# or, if you like taking precautions
sh -c "$(curl -SsL https://cdn.rawgit.com/thecoshman/http/master/install.sh)"

You can change the installation directory by setting the PREFIX environment variable (default - /usr/bin):

PREFIX=$HOME/bin curl -SsL https://cdn.rawgit.com/thecoshman/http/master/install.sh | sh
# Windows:
set PREFIX=D:\Akces
curl -SsL https://cdn.rawgit.com/thecoshman/http/master/install.sh | sh

If you're on a Debian-based amd64 machine, you can also grab a .deb package from the latest release page.

If you're on Windows and prefer a more guided installation (or you don't have a shell), you can download the Windows installer from the latest release's page. (Note: you can add /D INSTALLDIR to installer command line to change the installation directory.)

Aims

The idea is to make a program that can compile down to a simple binary that can be used via Linux CLI to quickly take the current directory and serve it over HTTP. Everything should have sensible defaults such that you do not have to pass parameters like what port to use.

  • Sub directories would be automatically hosted.
  • Symlinks will not be followed by default (in my opinion, this is more likely to be a problem than an intended thing).
  • Root should not be required.
  • If an index file isn't provided, one will be generated (in memory, no touching the disk, why would you do that you dirty freak you), that will list the current files and folders (and then sub directories will have index files generated as required)
  • Changes made to files should be reflected instantly, as I don't see why anything would be cached... you request a file, a file will be looked for

It's not going to be a 'production ready' tool, it's a quick and dirty way of hosting a folder, so whilst I'll try to make it secure, it is not going to be a serious goal.

Comments
  • Larger, highlighted, click target for opening folders/files

    Larger, highlighted, click target for opening folders/files

    Rather than just the text, for the file/folder name itself, the link should be of a larger html element so that there is more to click. It should also have a hover effect that highlights what you are over so it's clear

    improvement 
    opened by thecoshman 21
  • Installing with

    Installing with "cargo install" fails on Ubuntu

    cargo install https on Ubuntu gives me a

    error: failed to run custom build command for `openssl v0.9.24`                                     
    process didn't exit successfully: `/tmp/cargo-installbaFa52/release/build/openssl-28365257436483ab/build-script-build` (exit code: 101)
    --- stderr
    thread 'main' panicked at 'Unable to detect OpenSSL version', /home/zelda/.cargo/registry/src/github.
    com-1ecc6299db9ec823/openssl-0.9.24/build.rs:16:14
    note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
    
    question external 
    opened by Apromixately 20
  • Support Range request header (Ability to stream videos from random positions)

    Support Range request header (Ability to stream videos from random positions)

    Feature request: Ability to stream videos from random positions in the middle.

    Expected behaviour

    • Share a directory containing a big(ish) video file;
    • Connect to the server with a browser (It should better be from a computer different than the one hosting the server to add some network latency);
    • Click the video name; The browser will start loading and displaying the video;
    • You will notice in the video progress-bar that the browser shows how much it has pre-fetched (downloaded);
    • Jump (by clicking/tapping in the progress-bar) to a position in the video that is not loaded yet;
    • The browser should start displaying the video from that position.

    Observed behaviour

    Jumping to the middle doesn't work with and without the -e flag. I tested it in my mobile's Firefox with a >2h video. It can't jump to positions that are not loaded:

    • I can jump to positions in the video that was already loaded or pre-fetched by firefox. This is always the case with small files and when I use Firefox from the same laptop as the server since the file is ~instantly downloaded.
    • What I can't do is jump to a position which is not yet loaded. For example, when I open a 2hours long video, it starts from 0h00. if I try to jump to 1h00, it will fail to do so and it will jump instead to 1min xy seconds (or wherever the download is so far).

    From inspecting what http headers are sent when firefox tries to jump to a not-loaded position in this youtube video (the link should die soon), firefox sends few video-specific http-options, and the server responds respectively:

    1st Request
    ===========
    
    Host: r5---sn-hgn7zn7s.googlevideo.com
    User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0
    Accept: video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5
    Accept-Language: en-US,en;q=0.5
    Range: bytes=7798784-
    Referer: https://r5---sn-hgn7zn7s.googlevideo.com/videoplayback?key=cms1&gir=yes&mime=video%2Fmp4&requiressl=yes&ratebypass=yes&dur=346.046&lmt=1484123052879736&source=youtube&clen=15053869&id=o-ANabftMGPfGu6vXOHu9TF_px2mY-v7HUAwzfaC8UZLYb&expire=1484193348&ei=46l2WM2VOsfycuTGo9AN&pl=17&ipbits=0&ip=41.109.236.221&sparams=clen,dur,ei,expire,gir,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,nh,pl,ratebypass,requiressl,source,upn&signature=5C096A27A1D5D53A18742D85F324ECF71C482C2E.6D9B3D096D2DF27DDB8B2B677050721D92743F76&itag=18&upn=OURRDchDiSI&cmbypass=yes&redirect_counter=1&req_id=b284bf5a3f79a3ee&cms_redirect=yes&mm=30&mn=sn-hgn7zn7s&ms=nxu&mt=1484171710&mv=m&nh=IgpwcjAyLm1yczAyKg8yMTMuMTQ0LjE3Ni4yMjA
    DNT: 1
    Connection: keep-alive
    
    
    1st response
    ============
    
    Accept-Ranges: bytes
    Alt-Svc: quic=":443"; ma=2592000
    Cache-Control: private, max-age=21234
    Connection: close
    Content-Length: 7255085
    Content-Range: bytes 7798784-15053868/15053869
    Content-Type: video/mp4
    Date: Wed, 11 Jan 2017 21:56:54 GMT
    Expires: Wed, 11 Jan 2017 21:56:54 GMT
    Last-Modified: Wed, 11 Jan 2017 08:24:12 GMT
    Server: gvs 1.0
    X-Content-Type-Options: nosniff
    
    Middle request
    ==============
    
    Host: r5---sn-hgn7zn7s.googlevideo.com
    User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0
    Accept: video/webm,video/ogg,video/*;q=0.9,application/ogg;q=0.7,audio/*;q=0.6,*/*;q=0.5
    Accept-Language: en-US,en;q=0.5
    Range: bytes=11075584-
    Referer: https://r5---sn-hgn7zn7s.googlevideo.com/videoplayback?key=cms1&gir=yes&mime=video%2Fmp4&requiressl=yes&ratebypass=yes&dur=346.046&lmt=1484123052879736&source=youtube&clen=15053869&id=o-ANabftMGPfGu6vXOHu9TF_px2mY-v7HUAwzfaC8UZLYb&expire=1484193348&ei=46l2WM2VOsfycuTGo9AN&pl=17&ipbits=0&ip=41.109.236.221&sparams=clen,dur,ei,expire,gir,id,initcwndbps,ip,ipbits,itag,lmt,mime,mm,mn,ms,mv,nh,pl,ratebypass,requiressl,source,upn&signature=5C096A27A1D5D53A18742D85F324ECF71C482C2E.6D9B3D096D2DF27DDB8B2B677050721D92743F76&itag=18&upn=OURRDchDiSI&cmbypass=yes&redirect_counter=1&req_id=b284bf5a3f79a3ee&cms_redirect=yes&mm=30&mn=sn-hgn7zn7s&ms=nxu&mt=1484171710&mv=m&nh=IgpwcjAyLm1yczAyKg8yMTMuMTQ0LjE3Ni4yMjA
    DNT: 1
    Connection: keep-alive
    
    
    Response
    ========
    Accept-Ranges: bytes
    Alt-Svc: quic=":443"; ma=2592000
    Cache-Control: private, max-age=21214
    Connection: close
    Content-Length: 3978285
    Content-Range: bytes 11075584-15053868/15053869
    Content-Type: video/mp4
    Date: Wed, 11 Jan 2017 21:57:14 GMT
    Expires: Wed, 11 Jan 2017 21:57:14 GMT
    Last-Modified: Wed, 11 Jan 2017 08:24:12 GMT
    Server: gvs 1.0
    X-Content-Type-Options: nosniff
    
    feature 
    opened by NawfelBgh 17
  • x86_64-unknown-linux-musl build failed

    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
    
    question 
    opened by zydxhs 15
  • Last modification time is shown in GMT+0 which is confusing

    Last modification time is shown in GMT+0 which is confusing

    Currently, last modification time is always displayed in GMT+0 which is a little confusing. I think that we should either:

    • Write "xx-xx-xx xx:xx:xx (GMT)" to clarify, or
    • Display time in the timezone of the client.
    improvement 
    opened by NawfelBgh 12
  • Authentication mechanism

    Authentication mechanism

    Some kind of authentication could be nice.

    My use case for this software is to allow people to get or upload a file on my LAN or with the internet. I would run the program just for a couple of minutes.

    In my case it would be cool to have http generate a random token (maybe with expiration if people run http 24/24).

    feature 
    opened by bbigras 10
  • WASM files not being sent

    WASM files not being sent

    I have a folder with the following files

    • bootstrap.js
    • projectname_bg.js
    • projectname_bg.wasm
    • projectname_bg.wasm.d.ts
    • projectname.d.ts
    • projectname.js
    • index.html
    • index.js

    When I run http, it does start up a server and when you visit localhost:8000, it gives you the following files

    • index.html
    • bootstrap.js
    • projectname.js
    • index.js

    I do want those to be sent, this is good. It's not sending the .d.ts files, this is good. The probelm is it's not sending projectname_bg.wasm and projectname_bg.js. I understand it not sending projectname_bg.js, since it doesn't seemed to be called in anywhere. Idk why wasm-pack made it. But projectname_bg.wasm does get called in in projectname.js. The wasm file isn't being sent, and it should be.

    invalid 
    opened by zperk13 9
  • webpage not responding when there are thousands of files in a directory

    webpage not responding when there are thousands of files in a directory

    While other solutions (miniserve) works fine. Maybe related to there are too many "icons" on the page (in httplz each line has some image icons).

    Test on firefox, chromium and vivaldi on linux.

    external 
    opened by NOBLES5E 9
  • Port scan

    Port scan

    If the server can't secure the desired port, it should start to increment one at a time until it finds a free port to listen on. This can loop around from max port back to the lowest port that doesn't require privilege escalation. If it loops back to the starting port, it should print an error message and quit

    feature 
    opened by thecoshman 9
  • Write URL to access server to console

    Write URL to access server to console

    Can you write an URL to access the server to the console during startup? Other local servers do that, for example Jekyll or wasm-pack test, and modern terminals support clicking on that URL to open a browser window.

    duplicate 
    opened by starblue 8
  • Colour the log output

    Colour the log output

    Nice pretty colours are pretty and nice. Some sort of highlighting should be added. The different elements of the log messages should be highlighted individually. For ease of understand what is going on with the colours, they should be defined in one concise location

    improvement 
    opened by thecoshman 7
  • Cross-platform symlink

    Cross-platform symlink

    I couldn't figure out how cross-platform symlinks work. It states under features:

    Good symlink handling compatible with Windows

    I simply used ls -s, but the creates symlink only worked on Linux and MacOS. Using the usual shortcut creation on Windows, didn't work at all, not on Windows and, as expected, not on Linux or MacOS.

    Is there something I'm missing? I couldn't find documentation on it in any case.

    bug 
    opened by daxpedda 12
  • Multiple dependencies with known security vulnerabilities

    Multiple dependencies with known security vulnerabilities

    Running cargo audit on the repository reports 4 known vulnerabilities in the dependency tree:

    Crate:         brotli-sys
    Version:       0.3.2
    Title:         Integer overflow in the bundled Brotli C library
    Date:          2021-12-20
    ID:            RUSTSEC-2021-0131
    URL:           https://rustsec.org/advisories/RUSTSEC-2021-0131
    Solution:      No safe upgrade is available!
    Dependency tree: 
    brotli-sys 0.3.2
    └── brotli2 0.3.2
        └── https 1.12.2
    
    Crate:         hyper
    Version:       0.10.16
    Title:         Integer overflow in `hyper`'s parsing of the `Transfer-Encoding` header leads to data loss
    Date:          2021-07-07
    ID:            RUSTSEC-2021-0079
    URL:           https://rustsec.org/advisories/RUSTSEC-2021-0079
    Solution:      Upgrade to >=0.14.10
    Dependency tree: 
    hyper 0.10.16
    ├── rfsapi 0.1.0
    │   └── https 1.12.2
    ├── iron 0.6.1
    │   └── https 1.12.2
    └── hyper-native-tls 0.3.0
        ├── iron 0.6.1
        └── https 1.12.2
    
    Crate:         hyper
    Version:       0.10.16
    Title:         Lenient `hyper` header parsing of `Content-Length` could allow request smuggling
    Date:          2021-07-07
    ID:            RUSTSEC-2021-0078
    URL:           https://rustsec.org/advisories/RUSTSEC-2021-0078
    Solution:      Upgrade to >=0.14.10
    
    Crate:         time
    Version:       0.1.43
    Title:         Potential segfault in the time crate
    Date:          2020-11-18
    ID:            RUSTSEC-2020-0071
    URL:           https://rustsec.org/advisories/RUSTSEC-2020-0071
    Solution:      Upgrade to >=0.2.23
    Dependency tree: 
    time 0.1.43
    ├── rfsapi 0.1.0
    │   └── https 1.12.2
    ├── hyper 0.10.16
    │   ├── rfsapi 0.1.0
    │   ├── iron 0.6.1
    │   │   └── https 1.12.2
    │   └── hyper-native-tls 0.3.0
    │       ├── iron 0.6.1
    │       └── https 1.12.2
    └── https 1.12.2
    
    error: 4 vulnerabilities found!
    
    external 
    opened by Shnatsel 2
  • Handle redirection

    Handle redirection

    Hello,

    Do you think it's possible to add a redirection option for a path/subpath ?

    Expected:

    http --redirect /some:http://localhost:4000
    

    Thanks, Marc-Antoine

    feature 
    opened by MarcAntoine-Arnaud 5
  • Fancy CLI to show what's going on

    Fancy CLI to show what's going on

    Rather than just a scrolling log of what actions are requested... perhaps a swish console could be started that can show the status of things like what folder is being hosted, where temp files are, the progress of any ongoing transfers.

    This may be more than should be done in this project, perhaps a separate project can wrap this one to provide this console mode

    feature question 
    opened by thecoshman 1
Releases(v1.12.5)
Owner
thecoshman
thecoshman
OxHTTP is a very simple synchronous HTTP client and server

OxHTTP is a very simple synchronous implementation of HTTP 1.1 in Rust. It provides both a client and a server.

Oxigraph 13 Nov 29, 2022
Operator is a web server. You provide a directory and Operator serves it over HTTP.

Operator Operator is a web server. You provide a directory and Operator serves it over HTTP. It serves static files the way you'd expect, but it can a

Matt Kantor 6 Jun 6, 2022
Completely OBSOLETE Rust HTTP library (server and client)

OBSOLETION NOTICE This library is DEAD. It was a useful experiment and is now being replaced under the scope of the Teepee (experimentation grounds at

Chris Morgan 390 Dec 1, 2022
Archibald is my attempt at learning Rust and writing a HTTP 1.1 web server.

Archibald To be a butler, is to be able to maintain an even-temper, at all times. One must have exceptional personal hygiene and look sharp and profes

Daniel Cuthbert 4 Jun 20, 2022
Simple http server in Rust (Windows/Mac/Linux)

How it looks like? Screenshot Command Line Arguments Simple HTTP(s) Server 0.6.1 USAGE: simple-http-server [FLAGS] [OPTIONS] [--] [root] FLAGS:

LinFeng Qian 788 Dec 28, 2022
Fully async-await http server framework

Saphir is a fully async-await http server framework for rust The goal is to give low-level control to your web stack (as hyper does) without the time

Richer Archambault 83 Dec 19, 2022
Low level HTTP server library in Rust

tiny-http Documentation Tiny but strong HTTP server in Rust. Its main objectives are to be 100% compliant with the HTTP standard and to provide an eas

null 785 Dec 29, 2022
Node.js http server framework powered by Hyper native binding.

hnsjs POC project. Install this test package yarn add @hnsjs/core Support matrix node10 node12 node14 node15 Windows x64 ✓ ✓ ✓ ✓ Windows x32 ✓ ✓ ✓ ✓

LongYinan 18 Nov 23, 2022
Akasio is a simple HTTP server that redirects traffic based on a JSON redirect table. This is its Rust implementation.

This page is inaccurate and is pending updates. Akasio (Rust) Description Akasio is a simple HTTP server that redirects traffic based on a JSON redire

K4YT3X 5 May 2, 2022
RUSTENGINE is the high-assurance HTTP server.

RUSTENGINE Table of Contents RUSTENGINE Table of Contents About RUSTENGINE Inspiration with Rust Features Compares with Nginx Build & Run About this R

FUNNY SYSTEMS 10 Aug 27, 2021
A synchronous HTTP server built on hyper.

Astra Astra is a synchronous HTTP server built on top of hyper. use astra::{Body, Response, Server}; fn main() { Server::bind("localhost:3000")

Ibraheem Ahmed 23 Nov 27, 2022
:zap: fast http framework for rust

zap ⚡ The mission of zap is, to deliver a basic, but fast rust web server library. Documentation About This code is based on tokio's minihttp project,

Daniel Oltmanns 51 Jun 7, 2022
Basic Actix + Diesel + Postgres REST API

Actix-Crud Basic Actix + Diesel + Postgres REST API Setup Install and setup PostgreSQL Set DATABASE_URL environment variable or specify in .env file g

Aathif Naseer 4 Sep 23, 2022
Live Server - Launch a local network server with live reload feature for static pages

Live Server - Launch a local network server with live reload feature for static pages

Lomirus 18 Nov 30, 2022
A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. :zap::crab:

binserve ⚡ ?? A blazingly fast static web server with routing, templating, and security in a single binary you can set up with zero code. ?? UPDATE: N

Mufeed VH 722 Dec 27, 2022
Simple and fast web server

see Overview Simple and fast web server as a single executable with no extra dependencies required. Features Built with Tokio and Hyper TLS encryption

null 174 Dec 9, 2022
Add Facebook and Google authentication to your HTTP REST API in Actix-web

I created this project while learning Rust. Project shows how to handle Facebook and Google token verification in Rust using Actix-Web. Hope this help

null 37 Dec 31, 2022
🌟 For when you really just want to serve some files over HTTP right now!

miniserve - a CLI tool to serve files and dirs over HTTP For when you really just want to serve some files over HTTP right now! miniserve is a small,

Sven-Hendrik Haase 4.1k Dec 31, 2022
An HTTP library for Rust

hyper A fast and correct HTTP implementation for Rust. HTTP/1 and HTTP/2 Asynchronous design Leading in performance Tested and correct Extensive produ

null 11k Jan 7, 2023