<commit_before># HTTP streaming decoder in C++ #

http://akinaru.github.io/http-streaming-decoder-cpp/

<i>Last update 10/05/2015</i>

HTTP protocol decoder

* parse any HTTP data streaming
* non-blocking process
* compatible with non-blocking or blocking socket architecture
* http decoding monitoring

<hr/>

<b>Generality</b>

This repo features source code and test project for http decoder library.

Library is generated as a shared library (.dll or .so)

This project uses QtCore and is build with qmake utility (you can use QtCreator to build it)

<hr/>

<b>PROGRAM SYNTAX for decoding HTTP frames</b>

First you have to declare the ``HttpDecoder`` object

``HttpDecoder decoder;``

Then instantiate a new ``httpConsumer`` : this object will monitor your data streaming decoding and will contain decoded frame(s)

``httpConsumer *consumer = new httpConsumer;``

For both of them you'll need these import : <br/>
``#include "protocol/http/HttpDecoder.h"``<br/>
``#include "protocol/inter/http/Httpconsumer.h"``<br/>


Your data streaming will be put to a ``QByteArray *`` to be sent to http decoder :<br/>
``QByteArray *httpFrame = new QByteArray("POST /rest/help/todo HTTP/1.1\r\nheaders1:  value1\r\nheaders2:  value2\r\nContent-Length:  15\r\n\r\nbodyTobeWritten\r\n")``

Eventually decode with : 

``decoder.httpDecode(consumer,httpFrame);``

Result of decoding will be in your pointer to consumer object you have just created

You can access to decoded frame with ``consumer->getHttpFrameList()`` which is a ``vector<httpConsumer*>`` you can iterate

Then you can remove frame you have treated and re-loop to decode again with the same object if you want to

Complete exemple in ./http-decoder-test/launcher.cpp

<hr/>

<b>How to build</b>

This is composed of 2 projects:
* http decoder library project
* http decoder test 

You can open .pro file of both with qtcreator and build project

<hr/>

<b>Exemple</b>

``HttpDecoder decoder;``

``httpConsumer *consumer = new httpConsumer;``

``QByteArray *httpFrame = "POST /rest/help/todo HTTP/1.1\r\nheaders1:  value1\r\nheaders2:  value2\r\nContent-Length:  15\r\n\r\nbodyTobeWritten\r\nHTTP/1.1 200 OK\r\n\r\n";``

``httpFrame = new QByteArray(data1);``

``decoder.httpDecode(consumer,httpFrame);``<commit_msg>update readme for class name changes<commit_after># HTTP streaming decoder in C++ #

http://akinaru.github.io/http-streaming-decoder-cpp/

<i>Last update 10/05/2015</i>

HTTP protocol decoder

* parse any HTTP data streaming
* non-blocking process
* compatible with non-blocking or blocking socket architecture
* http decoding monitoring

<hr/>

<b>Generality</b>

This repo features source code and test project for http decoder library.

Library is generated as a shared library (.dll or .so)

This project uses QtCore and is build with qmake utility (you can use QtCreator to build it)

<hr/>

<b>PROGRAM SYNTAX for decoding HTTP frames</b>

First you have to declare the ``httpdecoder`` object

``httpdecoder decoder;``

Then instantiate a new ``httpconsumer`` : this object will monitor your data streaming decoding and will contain decoded frame(s)

``httpconsumer *consumer = new httpconsumer;``

For both of them you'll need these import : <br/>
``#include "protocol/http/httpdecoder.h"``<br/>
``#include "protocol/inter/http/httpconsumer.h"``<br/>


Your data streaming will be put to a ``QByteArray *`` to be sent to http decoder :<br/>
``QByteArray *httpframe = new QByteArray("POST /rest/help/todo HTTP/1.1\r\nheaders1:  value1\r\nheaders2:  value2\r\nContent-Length:  15\r\n\r\nbodyTobeWritten\r\n")``

Eventually decode with : 

``decoder.httpdecode(consumer,httpFrame);``

Result of decoding will be in your pointer to consumer object you have just created

You can access to decoded frame with ``consumer->getHttpFrameList()`` which is a ``vector<httpconsumer*>`` you can iterate

Then you can remove frame you have treated and re-loop to decode again with the same object if you want to

Complete exemple in ./http-decoder-test/launcher.cpp

<hr/>

<b>How to build</b>

This is composed of 2 projects:
* http decoder library project
* http decoder test 

You can open .pro file of both with qtcreator and build project

<hr/>

<b>Exemple</b>

``httpdecoder decoder;``

``httpconsumer *consumer = new httpconsumer;``

``QByteArray *httpframe = "POST /rest/help/todo HTTP/1.1\r\nheaders1:  value1\r\nheaders2:  value2\r\nContent-Length:  15\r\n\r\nbodyTobeWritten\r\nHTTP/1.1 200 OK\r\n\r\n";``

``httpframe = new QByteArray(data1);``

``decoder.httpdecode(consumer,httpframe);``
{'fraction_non_alphanumeric': 0.11610076670317634, 'fraction_numerical': 0.013581599123767798, 'mean_word_length': 4.595588235294118, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6212269', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1430, 'n_words': 520}