Simple-Web-Server

Simple-Web-Server: a fast and flexible HTTP/1.1 C++ client and server library - Published in JOSS (2019)

https://gitlab.com/eidheim/Simple-Web-Server

Science Score: 89.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in JOSS metadata
  • Academic publication links
  • Committers with academic emails
    1 of 61 committers (1.6%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
    Published in Journal of Open Source Software
Last synced: 4 months ago · JSON representation

Repository

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.

Basic Info
  • Host: gitlab.com
  • Owner: eidheim
  • License: mit
  • Default Branch: master
Statistics
  • Stars: 266
  • Forks: 118
  • Open Issues: 102
  • Releases: 0
Created over 7 years ago

https://gitlab.com/eidheim/Simple-Web-Server/blob/master/

# Simple-Web-Server

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Asio (both Boost.Asio and standalone Asio can be used). Created to be an easy way to make REST resources available from C++ applications. 

See https://gitlab.com/eidheim/Simple-WebSocket-Server for an easy way to make WebSocket/WebSocket Secure endpoints in C++. Also, feel free to check out the new C++ IDE supporting C++11/14/17: https://gitlab.com/cppit/jucipp. 

## Features

* Asynchronous request handling
* Thread pool if needed
* Platform independent
* HTTP/1.1 supported, including persistent connections
* HTTPS supported
* Chunked transfer encoding and server-sent events
* Can set timeouts for request/response and content
* Can set max request/response size
* Sending outgoing messages is thread safe
* Client creates necessary connections and perform reconnects when needed

See also [benchmarks](https://gitlab.com/eidheim/Simple-Web-Server/blob/master/docs/benchmarks.md) for a performance comparisons to a few other HTTP libraries.

## Usage

See [http_examples.cpp](https://gitlab.com/eidheim/Simple-Web-Server/blob/master/http_examples.cpp) or
[https_examples.cpp](https://gitlab.com/eidheim/Simple-Web-Server/blob/master/https_examples.cpp) for example usage.
The following server resources are setup using regular expressions to match request paths:
* `POST /string` - responds with the posted string.
* `POST /json` - parses the request content as JSON, and responds with some of the parsed values.
* `GET /info` - responds with information extracted from the request.
* `GET /match/([0-9]+)` - matches for instance `/match/123` and responds with the matched number `123`.
* `GET /work` - starts a thread, simulating heavy work, and responds when the work is done.
* `GET` - a special default_resource handler is called when a request path does not match any of the above resources.
This resource responds with the content of files in the `web/`-folder if the request path identifies one of these files.

[Documentation](https://eidheim.gitlab.io/Simple-Web-Server/annotated.html) is also available, generated from the master branch.

## Dependencies

* Boost.Asio or standalone Asio
* Boost is required to compile the examples
* For HTTPS: OpenSSL libraries

Installation instructions for the dependencies needed to compile the examples on a selection of platforms can be seen below.
Default build with Boost.Asio is assumed. Turn on CMake option `USE_STANDALONE_ASIO` to instead use standalone Asio.

### Debian based distributions

```sh
sudo apt-get install libssl-dev libboost-filesystem-dev libboost-thread-dev
```

### Arch Linux based distributions

```sh
sudo pacman -S boost
```

### MacOS

```sh
brew install openssl boost
```

## Compile and run

Compile with a C++11 compliant compiler:
```sh
cmake -H. -Bbuild
cmake --build build
```

### HTTP

Run the server and client examples: `./build/http_examples`

Direct your favorite browser to for instance http://localhost:8080/

### HTTPS

Before running the server, an RSA private key (server.key) and an SSL certificate (server.crt) must be created.

Run the server and client examples: `./build/https_examples`

Direct your favorite browser to for instance https://localhost:8080/

## Contributing

Contributions are welcome, either by creating an issue or a merge request.
However, before you create a new issue or merge request, please search for previous similar issues or requests.
A response will normally be given within a few days.

Owner

  • Name: Ole Christian Eidheim
  • Login: eidheim
  • Kind: user
  • Location: Trondheim, Norway

JOSS Publication

Simple-Web-Server: a fast and flexible HTTP/1.1 C++ client and server library
Published
August 26, 2019
Volume 4, Issue 40, Page 1592
Authors
Ole Christian Eidheim ORCID
Department of Computer Science, Norwegian University of Science and Technology
Editor
George K. Thiruvathukal ORCID
Tags
web http client server library asio

Committers

Last synced: 4 months ago

All Time
  • Total Commits: 632
  • Total Committers: 61
  • Avg Commits per committer: 10.361
  • Development Distribution Score (DDS): 0.172
Past Year
  • Commits: 2
  • Committers: 2
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.5
Top Committers
Name Email Commits
eidheim e****m@g****m 523
Hermann von Kleist s****n@y****m 10
Seth Hamilton s****n@g****m 9
Sébastien Huss s****s@g****m 6
Arash A****v@u****m 4
Christophe Meessen m****n@c****r 4
David Wedderwille d****e@p****e 4
gavin.smith@coralbay.tv g****h@c****v 4
ProTrack a****r@p****l 3
knowledge4igor k****r@y****m 3
woe S****e@g****m 3
Øyvind Saltvik o****k@g****m 3
Jørgen Lien Sellæg j****n@g****g 3
Jens Moeller J****r@s****m 2
Mathieu Schroeter m****u@s****h 2
NeroBurner p****l@g****m 2
Vlad Lipskiy v****y@e****m 2
waga-git w****a@s****p 2
Addy a****e@g****m 1
Alex Fraser a****r@t****m 1
Alfredo Luque a****o@b****l 1
Andrei Gheorghe g****i@y****m 1
Andrey Potapov a****s@y****u 1
Andrey Potapov a****v@t****m 1
Antoine Villeret a****t@g****m 1
Aviral Singh a****h@p****m 1
Breeze Chen b****6@g****m 1
Cameron Gutman a****r@g****m 1
Craig Minihan c****g@r****m 1
David Björkevik d****d@b****e 1
and 31 more...

Issues and Pull Requests

Last synced: 4 months ago