Code Monkey home page Code Monkey logo

basic-http-server's People

Contributors

brson avatar derekdreery avatar djc avatar prasad83 avatar rylev avatar sanxiyn avatar skade avatar tailhook avatar tcr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

basic-http-server's Issues

Cache files

At the moment it seems that on every request, a file is loaded from disk. Can this be cached?

Custom headers support to enable features like SharedArrayBuffer

I'm using a wasm compiled version of Stockfish for a chess game I'm working on and it requires SharedArrayBuffer which requires these headers to be sent in order to use it:

Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp

Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#security_requirements

I assume there are or will be other features gated by headers like this and it would be very useful to be able to easily test these on local machines. Would you be interested in a PR to support setting these headers?

For implementation, I was thinking just a command line argument like --header/-h that can be specified multiple times and takes a string like "Cross-Origin-Opener-Policy: same-origin". I'd also be fine with something like a --sharedarraybuffer flag if that's preferred, I just figured setting headers might be useful for other use cases. Would appreciate input on any of this.

Serve wasm?

Preface: this is fabulous, and I really appreciate that the code is a good source as well as this having great functionality.

Feature request: it'd be great if this supported serving wasm with the correct MIME type!

The server fails when mpv downloads HLS parts from it

# RUST_BACKTRACE=1 rnn ~rust/.multirust/toolchains/nightly/cargo/bin/basic-http-server  -a '127.0.0.1:80'
addr: 127.0.0.1:80
root dir: "."
server threads: 4
file threads: 100

listening on 127.0.0.1:80
listening on 127.0.0.1:80
listening on 127.0.0.1:80
listening on 127.0.0.1:80
thread '<unnamed>' panicked at 'Called write_body() method on message in a state IgnoredBody', .multirust/toolchains/nightly/cargo/registry/src/github.com-48ad6e4054423464/rotor-http-0.6.0/src/message.rs:368
stack backtrace:
   1: 0x566ea59c - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
   2: 0x566edbd1 - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
   3: 0x566ed811 - std::panicking::default_hook::hc2c969e7453d080c
   4: 0x566de731 - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e25
   5: 0x566df6f7 - std::sys_common::unwind::begin_unwind_fmt::hb2de8a9968d38523
   6: 0x5668c64e - rotor_http::message::Message::write_body::hb9825fc1585197ed
   7: 0x5668c3bb - rotor_http::server::response::Response::write_body::hd82d8f206e8c2fb7
   8: 0x5667f76a - _<RequestState as rotor_http..server..Server>::wakeup::hd4c2460d23f61854
   9: 0x5667a1c8 - rotor::handler::machine_loop::h0bbf68048047d20a
  10: 0x5665f749 - basic_http_server::run_server::hd44294626e68af33
  11: 0x56658e89 - std::sys_common::unwind::try::try_fn::h7a084651e7e45c71
  12: 0x566e96b7 - __rust_try
  13: 0x566e9636 - std::sys_common::unwind::inner_try::h47a4d9cd4a369dcd
  14: 0x5665afab - _<F as std..boxed..FnBox<A>>::call_box::h942bb108389dc8b5
  15: 0x566ec349 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
  16: 0xf7714d96 - start_thread
  17: 0xf765374d - clone
  18:        0x0 - <unknown>
^C

The server continues to work, but after 3 more such errors it hangs.

Reported version is still '0.1'

   Compiling basic-http-server v0.2.0
    Finished release [optimized] target(s) in 170.55 secs
   Replacing /home/rust/.cargo/bin/basic-http-server
$ /home/rust/.cargo/bin/basic-http-server --version
basic-http-server 0.1

Asset reloading

Some other small(-ish) dev servers like live-server support watching served files and automatically reloading any connected browsers.

This is super handy for development! It could also serve as a good example for how add WebSockets into a Rust project, something that can be finnicky in web frameworks that don't account for it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.