Coder Social home page Coder Social logo

bashttp's Introduction

Bash Http

A web server written in Bash

Description

A simple command-line http server written in Bash. It is useful for testing and local development. It could be run everywhere where Bash is used. There is no need to install huge dependencies or programming languages.

Run

This application uses ucspi-tcp for socket listening.

Ubuntu

  1. Before running execute sudo apt-get install ucspi-tcp
  2. Change your directory to the application root
  3. Run the application: ./app.sh start

Docker

  1. Change your directory to the application root
  2. Build a container docker build -t bashttp .
  3. Run the application in the container: docker run --rm -ti -v $(pwd):/usr/src/app -w /usr/src/app -p 3000:3000 bashttp ./app.sh start
  4. Run benchmarking in the container: docker run --rm -ti -v $(pwd):/usr/src/app -w /usr/src/app bashttp ./bench.sh

Benchmarks

Bashttp

Running 10s test @ http://127.0.0.1:3000/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    91.32ms   50.19ms 479.86ms   92.04%
    Req/Sec    45.84     18.08    80.00     73.22%
  866 requests in 10.02s, 279.98KB read
  Socket errors: connect 0, read 0, write 0, timeout 4
Requests/sec:     86.40
Transfer/sec:     27.93KB

Python embedded server

Running 10s test @ http://127.0.0.1:3001/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     6.73ms   46.63ms 837.32ms   98.58%
    Req/Sec     1.02k     0.94k    3.67k    80.50%
  20315 requests in 10.09s, 7.54MB read
Requests/sec:   2012.69
Transfer/sec:    764.59KB

PHP embedded server

Running 10s test @ http://127.0.0.1:3002/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   344.43us   98.10us   5.33ms   93.63%
    Req/Sec    13.37k   620.60    14.78k    65.84%
  268717 requests in 10.10s, 81.75MB read
Requests/sec:  26605.69
Transfer/sec:      8.09MB

node-http-server

Running 10s test @ http://127.0.0.1:3003/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   792.97us  417.15us  17.19ms   98.88%
    Req/Sec     6.49k   509.57     6.83k    96.00%
  129067 requests in 10.00s, 46.90MB read
Requests/sec:  12904.60
Transfer/sec:      4.69MB

TODO

The main idea of the project is a simple API implementation. I am moving towards this direction now.

bashttp's People

Contributors

igtulm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bashttp's Issues

Bug: Host header MUST be required

According to RFC 2616 "19.6.1.1 Changes to Simplify Multi-homed Web Servers and Conserve IP Addresses":
"The requirements that clients and servers support the Host request-header, report an error if the Host request-header (section 14.23) is missing from an HTTP/1.1 request, and accept absolute URIs (section 5.1.2) are among the most important changes defined by this specification."

Bug: server response code is incorrect

Functions (such as 'try_route') return a code for server response. But this code is a function's own exit status which could be a 8-bit value from 0 to 255, where 0 means "success". Now it is unable to return, for example, 404 response code. Need to fix and improve that logic.

Feature: Content type for html files

Edge browser tries to download html files without correct content-type header received from bashttp.
Need to add content type for html files.

Refactoring: Split functionality to modules

There is a need to split the functionality to modules as the application grows. Bash doesn't provide any convenient includes. To include different parts of the application 'source' is used. It pastes a text of a file specified to main program. So, we can have functions with the same names. To prevent this we can simulate namespaces by adding prefix, for instance, module name to each function in current module.

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.