GithubHelp home page GithubHelp logo

litespeedtech / ls-hpack Goto Github PK

View Code? Open in Web Editor NEW
40.0 12.0 24.0 2.1 MB

LiteSpeed HPACK (RFC7541) Library

License: MIT License

CMake 0.07% C 99.42% C++ 0.52%
hpack encoder decoder http2 h2 rfc7541 rfc-7541

ls-hpack's Introduction

Build Status Build Status Build status

LS-HPACK: LiteSpeed HPACK Library

Description

LS-HPACK provides functionality to encode and decode HTTP headers using HPACK compression mechanism specified in RFC 7541.

Documentation

The API is documented in include/lshpack.h. To see usage examples, see the unit tests.

Requirements

To build LS-HPACK, you need CMake. The library uses XXHASH at runtime.

Platforms

The library has been tested on the following platforms:

  • Linux
  • FreeBSD
  • Windows

Copyright (c) 2018 - 2020 LiteSpeed Technologies Inc

ls-hpack's People

Contributors

alexpokotilo avatar evanmiller avatar gstrauss avatar gwanglst avatar litespeedtech avatar lucasrolff avatar markoborodov avatar michalbiesek avatar sevan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ls-hpack's Issues

I found an error when the value of the request header value is "zh-CN,zh;q=0.9".

I found an error when the value of the request header value is "zh-CN,zh;q=0.9".

headkey: "Accept-Language",
headvalue: "zh-CN,zh;q=0.9"

===========================displayHeader==============================
408b 8484 2d69 5b38 ea9a d1cc 5f8c f73a |
d7b4 fd7b 9fef b400 5dff
===========================printTable===========================
Dynamic Table :
[62] Accept-Language' = zh-CN,zh;q=0.9'
----------------------step for [recvReq01]----------------

Assertion failed: rc == 0

add xxhash.c into ls-hpack library to simplify dependent programs build

Hi,
if I build ls-hpack library running

cmake -DCMAKE_BUILD_TYPE=Release .

and then try to build simple program that use it running

g++ main.c -I "./include" -L "./" -lls-hpack

I get

.//libls-hpack.a(lshpack.c.o): In function lshpack_enc_encode': lshpack.c:(.text+0x70f): undefined reference to XXH32_reset'
lshpack.c:(.text+0x72b): undefined reference to XXH32_update' lshpack.c:(.text+0x733): undefined reference to XXH32_digest'
lshpack.c:(.text+0x752): undefined reference to XXH32_update' lshpack.c:(.text+0x75a): undefined reference to XXH32_digest'

I understand(and see in library examples) that I can build ./deps/xxhash/xxhash.c as part of my executable but may be we can add ./deps/xxhash/xxhash.c into ls-hpack library to simplify building dependent programs ?

I temporary added this to my CMakeList.txt
IF (SHARED EQUAL 1)
ADD_LIBRARY(ls-hpack SHARED src/lshpack.c ./deps/xxhash/xxhash.c)
ELSE()
ADD_LIBRARY(ls-hpack STATIC src/lshpack.c ./deps/xxhash/xxhash.c)
ENDIF()

and it works fine and I just include ls-hpack library. I understand that xxhash.c is external lib and may be used in target project as well. But we can introduce an option disabled by default to include xxhash.c into lshpack lib.
If it's ok I can create pull request

[Bug] Decoder returns 0 on failure.

Hello!

I found an incorrect behavior of decoder.
Example program:

#include <ls-hpack/lshpack.h>

#include <array>
#include <iostream>

int main()
{
    const unsigned char data[] = {0x40}; // 0100 0000 

    lshpack_dec decoder{};
    lshpack_dec_init(&decoder);

    const unsigned char* beginPtr = data;
    const unsigned char* endPtr = beginPtr + 1;

    std::array<char, 256> headerBuffer{};
    lsxpack_header_t header{};
    lsxpack_header_prepare_decode(&header, headerBuffer.data(), 0, headerBuffer.size());

    const int res = lshpack_dec_decode(&decoder, &beginPtr, endPtr, &header);

    std::cout << "res=" << res << ", (beginPtr == endPtr)=" << (beginPtr == endPtr) << std::endl;

    lshpack_dec_cleanup(&decoder);
    return 0;
}

Program output (ls-hpack v2.3.0):

res=0, (beginPtr == endPtr)=1

I put into decoder only one byte (0x40) that is the first byte of Literal Header Field with Incremental Indexing for new name (https://datatracker.ietf.org/doc/html/rfc7541#section-6.2.1).

This one byte is not enough to decode, and I expect that lshpack_dec_decode will return LSHPACK_ERR_BAD_DATA and not advance beginPtr. But it returned 0 and changed begin pointer.

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.