Giter VIP home page Giter VIP logo

http-server's People

Contributors

ampych avatar antosser avatar dependabot[bot] avatar estebanborai avatar fmfigueroa avatar github-actions[bot] avatar johan-smits avatar palyzambrano avatar phosphorus-m avatar softmoth avatar stackinspector avatar ttys3 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

http-server's Issues

[Feature Request]

Description

Elaborate a bit on the feature you would like to have implemented on this project,
what does this feature brings to the project?

Why is this useful?

Why do we need this?

How should this work?

Steps on how to use this feature, what is the expected behavior?
Please provide as much detail as possible in order to have a fructiful
discussion on how to implement this.

CORS | Support for multiple origins

Description

Capability to allow several origins, instead of providing wildcard (*), a list of origins could be configured to be accepted
by the server.

When a request is gathered from the client, the origin is checked against the provided list and if such origin belongs
to the list, then the CORS Allow-Origin header would have such origin settled as value.

Why is this useful?

This could help for serving files to multiple front-ends but not any

How should this work?

  1. CORS configuration is provided via TOML config file
  2. A list of origins is set to the allowed_origins list in the configuration file
  3. When a request hits this server, the origin from the HTTP Request is checked against the allowed_origins setting
    3.1. If the origin of the HTTP Request belongs to the list, the Access-Control-Allow-Origin header is set to such origin
    3.2. Otherwise the Access-Control-Allow-Origin header is not included in the HTTP Response

This feature request was originally mentioned by @morenol in the following PR comment:

#7 (comment)

Filesystem paths are not urlencoded

Description

File paths are templated into the html verbatim. Handlebars inserts html escape characters, but this doesn't handle things like filenames containing spaces correctly.

Steps to reproduce

  1. touch 'file with spaces.txt'
  2. Execute `http-server -h 127.0.0.1 -p 8080
  3. Open http://127.0.0.1:8080
  4. Click the files with spaces.txt link
  5. The url is http://127.0.0.1:8080/files, which returns a 404

Environment

HTTP Server Version: v0.1.0
Operative System: Linux

Implement CORS support

Description

Implement support for CORS headers. By default this server will not provide CORS headers on responses.

Why is this useful?

CORS headers would allow arbitrary front-ends to request resources to an instance of this server.
By default websites doesn't allow cross origin requests.

By providing CORS headers front-ends will be able to make request to the server and load such resources.

For more details refer to: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

How should this work?

When running the HTTP server as:

http-server

Responses won't include any of CORS headers. Causing browsers to complain about missing
CORS headers when request are executed.

If the user runs the HTTP server specifying the cors option with the correct values, such browser
will be able to load such resources.

# Specifies CORS headers Origin to be "*" with all methods allowed and all headers allowed
http-server --cors

# Specifies CORS headers for the provided URL as origin
http-server --cors https://www.mywebsite.com

For further configuration the TOML configuration file must be used.

[cors]
origin = "https://www.mywebsite.com"
methods = ["GET", "POST", "PUT", "DELETE"]
headers = ["Content-Type"]
max-age = 3400

Access declined opening files on Windows

Description

I tried to start this server on my two Windows machines (one runs Windows Server and the other runs Windows 10) and found that it could not access any files on both machines, any request to access files and directories (include /) returned status 403 with content Access declined. (os error 5).

Steps to reproduce

  1. Execute `http-server -h 127.0.0.1 -p 8080
  2. Open http://127.0.0.1:8080.
  3. Visit any file through the file explorer.

Environment

  • Windows Server
  • Windows 10

HTTP Server Version: v0.7.0
Operative System: Windows

Screenshots

N/A

[Feature Request] Provide binaries for download

Description

Provide github releases with binaries to download

Why is this useful?

Provides the ability to use the project without installing rust on the machine and then compiling it.

How should this work?

Upload binaries for linux/amd64 and possible other targets. These can be made with CI with some available GH actions workflows

Support for Logging

Provides logging to stdout support.
The logger line info must include:

  • Date time
  • Method
  • Request URI
  • HTTP Version
  • Response status code
  • Request User-Agent
[2021-12-12T14:03:48.841116Z] "GET /favicon.ico HTTP/1.1 404 Not Found" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15"

Better Proxy Support

Description

Like this:

Request from the front end: /api/something

To the backend API: localhost:8000/something

Requests should be forwarded to the backend (without the path prefix /api)

Why is this useful?

It is useful in the most of the web applications 😄

File Explorer | Breadcrumb Navigation

Description

Support for Breadcrumb Navigation in the File Explorer's UI.

Example from Bootstrap: https://getbootstrap.com/docs/5.0/components/breadcrumb/#example

image

Why is this useful?

This would enhance UX by having shortcuts to travel to previous directories in the same path.

How should this work?

As a user I should be able to navigate deep into directories and click on certain breadcrumb parts to go back to previous directories without having to use the "Back" button from the browser.

Step 1 of 2 – Free trial – Google Cloud console

Capability to run from Config file

It would be nice to have a HttpServer.toml we could use to spin up server.

When running the server as:

http-server --config ./HttpServer.toml

The Configuration would be read on init to build server with desired configuration.

  1. Abstract Cli into a Config struct
  2. Provide an initialization process to read HttpServer.toml and build a Config from it
  3. Build server with such implementation

Setup Tracing for Axum

We need tracing to produce logs for debugging and monitoring.
Tracing is a library we can use given that is developed by Tokio,
the same organization behind Axum.

Cannot read any Certificate/Key files using RSA

Description

On both Linux and Windows it cannot read any certificate and key files (standard RSA certificate and key in plain text which works properly with Nginx), prompting the provided certificate is empty.

I checked the code and found that maybe it is a problem with reading buffers. To both problems I have no clue until present, and can't determine whether it's a problem with the project or my environment.

Steps to reproduce

N/A

Environment

HTTP Server Version: v0.7.0
Operative System:

  • Linux
  • Windows

Screenshots

N/A

CORS Policy Configuration Support

Description

Would like to define cors policy

{ "key": "Cross-Origin-Embedder-Policy", "value": "require-corp" },
{ "key": "Cross-Origin-Opener-Policy", "value": "same-origin" }

Why is this useful?

To run multithreaded web assembly using wasm_bindgen_ryon

failed to build on windows 10

it's built on linux just fine, but very hard to cross compile for windows from Linux, so I just installed rust on windows and start building, then it failed:

   Compiling http-server v0.7.4 (C:\Users\Test\rust\http-server)
error[E0515]: cannot return value referencing local variable `bytes`
  --> src\utils\url_encode.rs:50:13
   |
39 |                             &bytes
   |                             ------ `bytes` is borrowed here
...
50 |             std::iter::once("/").chain(segment)
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returns a value referencing data owned by the current function
   |
   = help: use `.collect()` to allocate the iterator

For more information about this error, try `rustc --explain E0515`.
error: could not compile `http-server` due to previous error
warning: build failed, waiting for other jobs to finish...

[Feature Request] Make app verbose by default

When you just start the application, it prints nothing. You have no idea which port the app is on and which host it's hosted on. It is also much more practical to just click the link in the terminal than to manually write it in the browser.

So, why not make it verbose by default? New users won't get confused and others will save a couple keystrokes on -v.

Completely remove the -v flag and instead add a -q flag, which stands for quiet

Migrate to Axum

Axum has increased popularity lately, it would be nice to begin migrating this
solution to Axum.

Axum already provides compatibility with Tower middleware which is great given
that tower has a mature community, so most of the features can be built out of the box!

TLS fails with SSL_ERROR_RX_RECORD_TOO_LONG

Description

I installed with cargo install and followed the instructions in the readme to get TLS working. However, I'm getting the following errors:

  • chrome: ERR_SSL_PROTOCOL_ERROR
  • firefox: SSL_ERROR_RX_RECORD_TOO_LONG

Steps to reproduce

  1. cargo install http-server
  2. tls-cert.sh
  3. http-server --tls --tls-cert localhost.crt --tls-key localhost.key --tls-key-algorithm pkcs8
  4. Open https://localhost:7878 in browser
  5. Error happens

Environment
Linux
http-server 0.8.5
OpenSSL 3.1.1 30 May 2023 (Library: OpenSSL 3.1.1 30 May 2023)

File Explorer | UI styles are a broken, missing alignment and padding/margin issues

Description

Theres some issues in relation to the File Explorer UI, most of them are related to padding, margin of some elements.

  1. The table header have some alignment/size issues.

image

  1. The name of the directory is not aligned to the icon in the files list

image

  1. The table header and rows are not responsive

image

Steps to reproduce

  1. Execute `http-server -h 127.0.0.1 -p 8080
  2. Open http://127.0.0.1:8080
  3. Check on the elements rendered in the DOM

Environment

HTTP Server Version: v0.3.4
Operative System: MacOS/Linux/Windows

Screenshots

Binary is now called "main" instead of "http-server" after cargo install

Description

I tried to follow the readme: I ran cargo install http-server. But then I couldn't run http-server because no binary with that name was installed. Instead, the installed binary's name is main.

% cargo --version
cargo 1.50.0 (f04e7fab7 2021-02-04)
% cargo install --list
http-server v0.3.0:
    main

Environment

HTTP Server Version: v0.3.0
Operative System: macOS 11.3.1 on M1

Migrate to Axum | v1.0.0

Roadmap

The following list includes all todos to complete migration, on main branch we still have Hyper version running which
is tagged as v0.x.

  • Debug/Tracing Logging (Debugging)
  • #314
  • #315
    • Modified Date
    • File Size
    • Breadcrumb Navigation
    • File Upload
    • Filtering
    • Sorting
      • Sort By: File Name
      • Sort By: File Size
      • Sort By: File Modified Date
      • Directories First
      • Files First
  • #316
    • HTTPS/TLS Support
  • #317
    • gzip/deflate Compression
    • brotli Compression
  • #318
    • Cross Origin Resource Sharing
      • Allow Credentials
      • Allow Headers
      • Allow Methods
      • Allow Origin
      • Expose Headers
      • Max Age
      • Request Headers
      • Request Methods
      • Multiple Origins
  • #319
    • Last-Modified and ETag
    • Respond with 304 to If-Modified-Since
  • #320
    • Accept-Ranges
    • Content-Range
    • If-Range
    • If-Match
    • Range
  • #321
    • macOS
    • Linux
    • Windows
  • #322
    • Live Reload
  • #323
    • URL Configuration
  • #324
    • Username
    • Password
  • Graceful Shutdown

Upload Files using POST Requests

Description

Implement capability to upload files, using HTTP POST requests.
A POST along with a file attached to the request body should create such file in the provided path.

Why is this useful?

Improve HTTP Server capabilities by enabling the user to create new files in the specific

How should this work?

curl -i -X POST host:port/:root-dir-relative-path \
    -H "Content-Type: text/xml" \
    --data-binary "@path/to/file"

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.