litespeedtech / ls-hpack Goto Github PK
View Code? Open in Web Editor NEWLiteSpeed HPACK (RFC7541) Library
License: MIT License
LiteSpeed HPACK (RFC7541) Library
License: MIT License
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.
Such a cool library should be available for everyone!
A little suggestion about CMakeLists
File:
Is it possible to use a macro to decide whether to ignore RPATH
?
To determine whether xxhash
can consider using find_package
?
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
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 toXXH32_update' lshpack.c:(.text+0x733): undefined reference to
XXH32_digest'
lshpack.c:(.text+0x752): undefined reference toXXH32_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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.