Skip to content

ittybitty is a simple webserver library targetting small, resource constrained TCP/IP enabled embedded systems.

Notifications You must be signed in to change notification settings

raybejjani/ittybitty

Repository files navigation

ittybitty - The little webserver framework that could.

Ittybitty is a simple webserver library targetting small, resource 
constrained TCP/IP enabled embedded systems. It is designed to allow an 
integrator to run a simple webserver while specialising 
system/implementation specific code through linking pre-defined callbacks to
and from ittybitty.
It provides services to: 
- [Incomplete] Parse HTTP requests with header options and dispatch to handlers
- [Incomplete] Easily send back HTTP responses with appropriate headers
- [Incomplete] Utilities to prepare, lookup and serve static and dynamic content


Dependencies & Assumptions
- Berkeley Sockets
- Ragel http://www.complang.org/ragel/
- CUnit & Siege (included in repo)


Current Status
- Dummy server that serves content matched responses
- Basic HTTP/1.0 GET parser. Will skip headers.
- Minimal response construction tools
- Basic tests for parser
- ittyfs.py to build state machine to match url for content lookup and content storage.


Design Goals
- Defer policy to user layer.
- Minimise pointers/runtime resolution. Attempt to resolve at link time.
- Minimise RAM usage.
- Maximise speed (even at the expense of ROM/.text)

Design Overview
* Integrator Provided  *    |      +      Ittybitty        +

************************           +++++++++++++++++++++++++
* socket event handler *  ------>  + http request dispatch +
************************    + ---  +                       +
                            |      +++++++++++++++++++++++++
************************    |
* http dispatch        *  <-+
************************
         |
	 v
************************           +++++++++++++++++++++++++
* itty generated       *  <----->  + content lookup        +
* content data         *           + utilities             +
************************           +++++++++++++++++++++++++
         |
	 +-------------------+
************************     |     +++++++++++++++++++++++++
* socket output        *  <--+-->  + http response         +
*                      *           + utilities             +
************************           +++++++++++++++++++++++++

HTTP requests are detected by integrator provided code (with select, epoll
etc.) and accepted. The resulting socket is passed to ittybitty's http
request parsing tools. Ittybitty will read the request in and make the
appropriate callbacks at various points in the parsing of the request. When
parsing is complete the content is looked up, possibly utilising some of the
content lookup utilities ittybitty provides (hash based lookup, state
machine path matching) and static content is served using ittybitty http
response utilities while dynamic content is constructed as needed. All
output is put out on the stream. Socket closure is left to the integrator
code.


Directory Structure
itty_core: The ittybitty implementation and headers that export the API.
examples: Example implementations. Currently only simpleserve.
tools: Contains utility tools like ittyfs and templates.
tests: Implementation of test code. Tests implicitly provide some usage examples of 
	ittybitty.
CUnit-2.1-2, siege-2.70: unarchived libraries used to test and benchmark, respectively.


Ittyfs.py Tool
ittyfs is a basic tool that takes a directory of static files and prepares a C 
file that implements itty_get_content and provides a pointer to the file data. 
It generates a ragel file with rules to match each file path that return 
statically allocated struct itty_content pointers contain the matching file 
information. It also takes an extra path to be the root index file.


Future Work
- HTTP/1.1 support with more codes
  - More robust handling of errors in state machines
- PUT, POST, HEAD DELETE verb support
- Header option dispatch support
- Utilities to do (verb, url) tuple hash based content lookup
  - md5 based hash
  - gperf for content set known apriori
- Utilities to generate linkable binary blobs with content lookup
  - Ability to gzip static content and mark it as such when served
- Optional Metrics and Statistics service
  - protobuf, Thrift or MessagePack based


Style & Conventions
FILLME

About

ittybitty is a simple webserver library targetting small, resource constrained TCP/IP enabled embedded systems.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published