Coder Social home page Coder Social logo

tempbottle / libuhttp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zhaojh329/libuhttpd

1.0 2.0 2.0 118 KB

a very tiny and fast HTTP library based on libev and http-parser for Embedded Linux.

License: GNU General Public License v3.0

CMake 16.13% C 83.65% Shell 0.22%

libuhttp's Introduction

libuhttp

A very tiny and fast HTTP library based on libev and http-parser for Embedded Linux. Support HTTPS(alternative OpenSSL and CyaSSl(wolfssl)) and if you're sensitive to size, you can choose CyaSSl(wolfssl).

Keep Watching for More Actions on This Space

Features

  • use libev as its event backend
  • tiny and fast
  • support HTTPS: Alternative OpenSSL and CyaSSl(wolfssl)
  • flexible and you can easily extend your application to have HTTP/HTTPS services
  • code structure is concise and understandable, also suitable for learning

Why use libev as its backend?

libev tries to do one thing only (POSIX event library), and this in the most efficient way possible. Libevent tries to give you the full solution (event lib, non-blocking I/O library, http server, DNS client).

libev tries to follow the UNIX toolbox philosophy of doing one thing only, as good as possible.

How to Build

Install dependency Tools and Libraries

Ubuntu

~$ sudo apt install gcc cmake libev-dev libhttp-parser-dev libssl-dev libwolfssl-dev

CentOS

~$ sudo yum install gcc cmake libev-devel http-parser-devel openssl-devel

Clone the repository

~$ git clone https://github.com/zhaojh329/libuhttp.git
~$ cd libuhttp

Create the build directory

~/libuhttp$ mkdir build
~/libuhttp$ cd build

Configure

See which configuration are supported

~/libuhttp/build$ cmake .. -L
~/libuhttp/build$ cmake .. -LH

Default configure: automatically select the SSL library as its SSL backend(If there is a SSL library available).

~/libuhttp/build$ cmake ..

Disable SSl support

~/libuhttp/build$ cmake .. -DUHTTP_DISABLE_SSL=1

Explicit use OpenSSL as its SSL backend

~/libuhttp/build$ cmake .. -DUHTTP_USE_OPENSSL=1

Explicit use CyaSSl(wolfssl) as its SSL backend

~/libuhttp/build$ cmake .. -DUHTTP_USE_CYASSL=1

Turn on debug

~/libuhttp/build$ cmake .. -DUHTTP_DEBUG=1

Build and install libuhttp

~/libuhttp/build$ make && sudo make install

Run the Example

First generate the SSL certificate file

~/libuhttp/build$ cd ..
~/libuhttp$ ./gen_cert.sh

Run

~/libuhttp$ ./build/example/helloworld

Then use the command curl or browser to test

$ curl -k 'https://127.0.0.1:8000/test?name=context%3d%7b"nid"%3a"test"%7d' -v

If use browser to test, it will be show

Hello World
Libuhttp v0.1
Url: /test?name=context%3d%7b%22nid%22%3a%22test%22%7d
Path: /test
Name: context%3d%7b%22nid%22%3a%22test%22%7d
Unescaped Name: context={"nid":"test"}
Host: 192.168.0.100:8000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36

Contributing

If you would like to help making libuhttp better, see the CONTRIBUTING.md file.

Thanks for the following project

If the project is helpful to you, please do not hesitate to star. Thank you!

libuhttp's People

Stargazers

 avatar

Watchers

 avatar  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.