Code Monkey home page Code Monkey logo

http's Introduction

http

A simple multi-threaded HTTP/1.0-ish file server. Single file, 300 LOC.

Handles only GET requests, serving files below the directory in which the server is started. Does Content-Type inference based on file extensions (e.g. html, js, png, jpg).

Currently disables any type of cacheing as I use it mostly for local development and want to avoid versioning mistakes.

Also has fledgling SSL support that has occasionally worked.

To run:

java net.http.Server

or if you can't run on priviledged ports (<1024), pick a high one:

java -Dport=8080 net.http.Server
java -Dport=8080 -Dssl=true net.http.Server

Good performance using Java's Native IO. Loadtest using acme.com's http_load:

> cat /proc/cpuinfo
... Intel(R) Xeon(R) CPU           X5679  @ 3.20GHz ...
... Intel(R) Xeon(R) CPU           X5679  @ 3.20GHz ...
... Intel(R) Xeon(R) CPU           X5679  @ 3.20GHz ...
> dd if=/dev/zero of=10k.dat bs=1024 count=10
> echo "http://localhost:8080/10k.dat" > test.url
> ./http_load -p 10 -f 10000 test.url
# Throwaway
> ./http_load -p 10 -f 100000 test.url
100000 fetches, 10 max parallel, 1.024e+09 bytes, in 34.9176 seconds
10240 mean bytes/connection
2863.88 fetches/sec, 2.93262e+07 bytes/sec
msecs/connect: 0.0995282 mean, 2.717 max, 0.037 min
msecs/first-response: 3.18724 mean, 202.23 max, 0.315 min
HTTP response codes:
  code 200 -- 100000

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.