Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
kelbon authored Oct 16, 2024
1 parent 6ff641c commit b1f1396
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

Complete implementation of HPACK (Header Compression for HTTP/2, fully compliant RFC 7541)

encode:

```cpp
#include <hpack/encoder.hpp>

void encode_my_headers(hpack::encoder& enc, std::vector<hpack::bytes>& bytes;) {
// memory effective by default
enc.encode("name", "value", std::back_inserter(bytes));
// or by hands
enc.encode_header_fully_indexed(hpack::static_table_t::status_200, std::back_inserter(bytes));
}

```
decode
```cpp
#include <hpack/decoder.hpp>
void decode_my_headers(hpack::decoder& d, std::span<const hpack::byte_t> bytes) {
hpack::decode_headers_block(e, bytes, [&](std::string_view name, std::string_view value) {
// use name/value somehow
});
}
```

adding with cmake:

Preferred way with [CPM](https://github.com/cpm-cmake/CPM.cmake)

```cmake
CPMAddPackage(
NAME HPACK
GIT_REPOSITORY https://github.com/kelbon/HPACK
GIT_TAG origin/master
)
target_link_libraries(MyTargetName hpacklib)
```

simple way with fetch content:

```cmake
include(FetchContent)
FetchContent_Declare(
HPACK
GIT_REPOSITORY https://github.com/kelbon/HPACK
GIT_TAG origin/master
)
FetchContent_MakeAvailable(HPACK)
target_link_libraries(MyTargetName hpacklib)
```

0 comments on commit b1f1396

Please sign in to comment.