Git Product home page Git Product logo

simple-http-2-web-server's Introduction

Simple-HTTP-2-Web-Server

This is a simple HTTP2.0(h2c) web server library for Linux. This library uses only the c++ standard template library and some C functions.

Included features:

  • HTTP1.1 to HTTP2 upgrade.
  • HTTP2 Settings sent and received by clients and server upon connection.
  • Sending HTML files.
  • Decoding of HTTP2 frames.
  • Management of HTTP2 streams.
  • Error handling of streams and connections.
  • Partial header decoding.

Useful methods:

  • ServerLib(int port); - Create a server object with specified port number.
  • int startServer(); - Binds the socket and starts the server.
  • int webBind(std::string webDir, std::string diskDir); - Binds a path on the web server to a directory on the disk.
  • int webUnbind(std::string webDir); - Unbinds a path on the web server

Current limitations:

  • No support for TLS yet.
  • No support for UDP communication.
  • Huffman encoding is incomplete.
  • Binding of a function to a web path.

Example:

The file webserver.cpp is an example of how to use this libary.

Testing:

Test the server with nghttp or similar programs. There is a shellscript (./serverTesting/get.sh) to run a HTTP2 get request to the server. You can test the HTTP1.1 portion of the server with curl or a web browser.

Compiling and running:

git clone https://github.com/trygve55/Simple-HTTP-2-Web-Server`
cd Simple-HTTP-2-Web-Server
mkdir build
cd build
cmake ..
make
./webserver

Libary usage:

POSIX standard library:

  • netinet/in.h
  • unistd.h
  • stdint.h

C++ Standard Library:

  • Containers:
    • bitset
    • map
    • vector
  • General:
    • chrono
  • Strings:
    • string
    • regex
  • Streams and input/output:
    • fstream
    • iostream
    • sstream
  • Language support:
    • stdexcept
  • Thread support library:
    • thread(pthread)

Documentation used:

HTTP2 Specification: Hypertext Transfer Protocol Version 2 (HTTP/2) - https://http2.github.io/http2-spec/ HPACK: Header Compression for HTTP/2 - https://http2.github.io/http2-spec/compression.html

C++ specific: https://stackoverflow.com http://www.cplusplus.com http://en.cppreference.com

simple-http-2-web-server's People

Contributors

cybercabal avatar trygve55 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

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.