HTTPit Web Server

HTTPit is a tiny multi-threaded executable java based HTTP server (under 10kb). It was built as a simple challenge to myself, how much functionality could be coded into a .jar file under 10Kb in size. It supports SSI and CGI (to the point that PHP applications function correctly) and supports both GET and POST request, 52 document types, virtual hosting ….

:. System Requirements

This server uses the regular expressions support added in JDK1.4.x and therefore requires that version as a minimum.

:. Download

Click here to download:
HTTPit.zip (182 KB)

:. Features

• Very small executable (under 10kb).
• Virtual hosting support.
• Can deal with multiple requests at the same time.
• Support for 52 content-types (images, videos, HTML, etc).
• Directory browsing features.
• Index page retrieval without specifying full path.
• Request logging.
• Support for both GET and POST requests.
• Support for If-Modified-Since caching.
• Limited support for Server Side Includes.
• Support for CGI scripts (including /cgi-bin directory support).

:. Usage

java -jar HTTPit.jar [options]

Options include:

• port=8080 - the port the server will listen on
• timeout=10000 - the server socket timeout
• webroot=./webroot - the default root web directory
• webroot.[host_name]=./webroot - the root web directory for a virtual host
• index.files=index.html - comma separated list of default index files used when no file is passed
• dir.browsing=true - allow directory browsing
• admin=root@localhost - SERVER_ADMIN value passed as an env variable to CGI scripts
• cgi.[file_ext]=[executable] - file extensions that should be processed as CGI, followed by the executable that should be used to execute the file
• mime.[file_ext]=[mime type] - file extension followed by its mime type, if no mime type is found application/octet-stream will be used
• response.[code]=[reason phrase] - response code followed by its reason phrase
• response.[code].alt=[/path/to/err_page.html] - send alternate error page for 4xx and 5xx response codes

:. Example usages

java -jar HTTPit.jar mime.tar=application/x-tar

Launch with additional support for files of type .tar

java -jar HTTPit.jar cgi.php=/usr/local/bin/php index.files=index.html,index.php

Launch with support for .php files using CGI and include index.php as a valid index file.

java -jar HTTPit.jar webroot.www.foo.com=./webroot2

Virtual host www.foo.com using the ./webroot2 folder as its root directory.

:. Static Page Load Test

The static page load test results for this server detailed below involved testing 10 concurrent users against a simple html page (using the openload tool, http://openwebload.sourceforge.net/ ).

openload http://192.168.0.100:8000/index.html 10

  • Total TPS: 36.08 
  • Avg. Response time: 0.277 sec. 
  • Max Response time: 1.442 sec 
  • Total Requests: 68988 
  • Total Errors: 0

:. CGI Load Test

The CGI load test results for this server detailed below involved testing 10 concurrent users against a simple perl based CGI script (using the openload tool).

openload http://192.168.0.100:8000/cgi-bin/counter.cgi 10

  • Total TPS: 29.87 
  • Avg. Response time: 0.335 sec.
  • Max Response time: 1.760 sec
  • Total Requests: 57403
  • Total Errors: 0

Filed under  //

Comments [0]