Skip to content

Commit

Permalink
Add list of select features. Add manpage
Browse files Browse the repository at this point in the history
Also package up the manpage with release
  • Loading branch information
nabijaczleweli committed Dec 21, 2016
1 parent 21d8b65 commit 69ea8ff
Show file tree
Hide file tree
Showing 3 changed files with 183 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ matrix:
- env: LANGUAGE=Rust CLIPPY=true
language: rust
rust: nightly
- env: LANGUAGE=Ruby DEPLOY=true DEPLOY_FILE="$TRAVIS_BUILD_DIR/../http-man-$TRAVIS_TAG.tbz2"
language: ruby
rust: []
rvm: "2.2"
allow_failures:
- rust: beta
- rust: nightly

install:
- if [ "$LANGUAGE" == "Ruby" ]; then gem install ronn; fi

script:
- if [ "$LANGUAGE" == "Rust" ]; then cargo build --verbose; fi
- if [ "$LANGUAGE" == "Rust" ]; then cargo test --verbose; fi
Expand All @@ -28,12 +35,26 @@ script:
cargo install-update -a;
cargo clippy;
fi
-
- if [ "$LANGUAGE" == "Ruby" ] && [ "$DEPLOY" ] && [ "$TRAVIS_TAG" ]; then
mkdir man; pushd man;
cp ../http.md .;
ronn --organization="http developers" http.md;
popd;
fi

after_success:
- if [ "$LANGUAGE" == "Rust" ] && [ "$DEPLOY" ] && [ "$TRAVIS_TAG" ]; then
cp target/release/http "$DEPLOY_FILE";
strip --strip-all --remove-section=.comment --remove-section=.note "$DEPLOY_FILE";
fi
- if [ "$LANGUAGE" == "Ruby" ] && [ "$DEPLOY" ] && [ "$TRAVIS_TAG" ]; then
cp -r man "$TRAVIS_BUILD_DIR/../http-man-$TRAVIS_TAG";
pushd "$TRAVIS_BUILD_DIR/..";
tar -caf "http-man-$TRAVIS_TAG.tbz2" "http-man-$TRAVIS_TAG";
rm -rf "http-man-$TRAVIS_TAG";
popd;
fi

deploy:
provider: releases
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# http [![Build status](https://travis-ci.org/thecoshman/http.svg)](https://travis-ci.org/thecoshman/http) [![Licence](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE) [![Crates.io version](http://meritbadge.herokuapp.com/https)](https://crates.io/crates/https)
Host These Things Please - a basic HTTP server for hosting a folder fast and simply

## Selected features

See [the manpage](http.md) for full list.

* [x] Optional following of symlinks (`-s` option)
* [x] Index generation for directories (all for now)
* [x] Sane defaults (like hosted dir (`.`) and port (forst free one from range `8000`-`9999`))
* [x] Correct MIME type for served files
* [x] Handled request methods: OPTIONS, GET, PUT, DELETE, HEAD and TRACE ("writing" methods are off by default, enable via `-w` switch)
* [x] Proper handling of percent-encoded URLs (like `асдф fdsa`)
* [x] Good symlink handling compatible with Windows

## [Manpage](http.md)

## 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.

Expand Down
148 changes: 148 additions & 0 deletions http.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
http(1) -- a basic HTTP server for hosting a folder fast and simply
===================================================================

## SYNOPSIS

`http` [OPTIONS] [DIRECTORY]

## DESCRIPTION

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

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.

## OPTIONS

[DIR]

Directory to host. Must exist.

Default: current working directory.

-p --port [PORT]

Port to host the server on.

Must be between 1 and 65'535. Value of 0 will assign a random port,
chosen by the OS.

Default: first free port from 8000 up.

-t --temp-dir [TEMP]

Temporary directory to use to store data to write.

Only matters if --allow-write is also specified.

Default: $TEMP.

-s --follow-symlinks

Follow symlinks when requesting file access.

This is false by default because it is most likely a problem (according to
thecoshman anyway).

If a symlink is requested and this is not on it will be treated as if it
didn't exist.

-w --allow-write

Allow for write operations.

Currently supported write operations: PUT and DELETE.

This is false by default because it's most likely not something you
want to do.

## EXAMPLES

`http`

Host the current directory on the first free port upwards of 8000,
don't follow symlinks, don't allow writes.

Example output:
p:\Rust\http> http
Hosting "." on port 8000...
Ctrl-C to stop.

127.0.0.1:47880 was served directory listing for \\?\P:\Rust\http
127.0.0.1:47902 was served file \\?\P:\Rust\http\http.1.html as text/html
127.0.0.1:47916 requested to GET nonexistant entity S:\Rust-target\doc\main.css
127.0.0.1:48049 asked for options
127.0.0.1:47936 used disabled request method DELETE
127.0.0.1:48222 used disabled request method PUT
^C

Assuming that `P:\Rust\http\target` is a symlink to `S:\Rust-target`,
the following requests have been made, in order:

GET /
GET /http.1.html
GET /target/doc/main.css
OPTIONS
DELETE <path doesn't matter>
PUT <path doesn't matter>

The above output snippet is used as a reference for other examples.

`http -s`

As in the first example, but follow symlinks.

Example output change:
127.0.0.1:47916 was served file S:\Rust-target\doc\main.css as text/css

`http -w`

As in the first example, but allow writes.

Example output change:
127.0.0.1:47936 deleted file \\?\P:\Rust\http\http.1.html
127.0.0.1:48222 created \\?\P:\Rust\http\index.html, size: 1033554B

Corresponding request:
DELETE /http.1.html
PUT /index.html with request body containing roughly 1MB of data

Another behavioral change is that, in this case, the folder (and file)
named "T:/-=- TEMP -=-/http-P-Rust-http/" and
"T:/-=- TEMP -=-/http-P-Rust-http/index.html" were created while the file
"P:\Rust\http\http.1.html" was deleted (also works on directories).

`http -w -t "../TEMP"`

As in the previous example, but use a different temp dir.

Behavioral changes: the created folder and file are
named "P:/Rust/TEMP/http-P-Rust-http/" and
"P:/Rust/TEMP/http-P-Rust-http/index.html".

`http -p 6969`

As in the first example, but host on port 6969.

Assuming the port is free, example output change:
Hosting "." on port 6969...

If the port is taken, example output change:
Starting server failed: port taken.
<EOF>

## AUTHOR

Written by thecoshman &lt;<thecoshman@gmail.com>&gt;,
and nabijaczleweli &lt;<nabijaczleweli@gmail.com>&gt;.

## REPORTING BUGS

&lt;<https://github.com/thecoshman/http/issues>&gt;

## SEE ALSO

&lt;<https://github.com/thecoshman/http>&gt;

0 comments on commit 69ea8ff

Please sign in to comment.