Skip to content

Commit 6ea40ab

Browse files
authored
HPACK Static & Dynamic Tables (#41)
1 parent e8078b6 commit 6ea40ab

File tree

11 files changed

+3571
-1
lines changed

11 files changed

+3571
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ target_include_directories(${CMAKE_PROJECT_NAME} PUBLIC
5757
$<INSTALL_INTERFACE:include>)
5858

5959
find_package(aws-c-io REQUIRED)
60-
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC AWS::aws-c-io)
60+
find_package(aws-c-compression REQUIRED)
61+
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC AWS::aws-c-io AWS::aws-c-compression)
6162

6263
aws_prepare_shared_lib_exports(${CMAKE_PROJECT_NAME})
6364

codebuild/common-posix.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ if [ "$TRAVIS_OS_NAME" != "osx" ]; then
4343
fi
4444
install_library aws-c-common
4545
install_library aws-c-io
46+
install_library aws-c-compression
4647

4748
mkdir -p build
4849
pushd build

codebuild/common-windows.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mkdir %INSTALL_DIR%
1111

1212
CALL :install_library aws-c-common
1313
CALL :install_library aws-c-io
14+
CALL :install_library aws-c-compression
1415

1516
mkdir %BUILDS_DIR%\aws-c-http-build
1617
cd %BUILDS_DIR%\aws-c-http-build

include/aws/http/private/hpack.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef AWS_HTTP_HPACK_H
2+
#define AWS_HTTP_HPACK_H
3+
4+
/*
5+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License").
8+
* You may not use this file except in compliance with the License.
9+
* A copy of the License is located at
10+
*
11+
* http://aws.amazon.com/apache2.0
12+
*
13+
* or in the "license" file accompanying this file. This file is distributed
14+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
15+
* express or implied. See the License for the specific language governing
16+
* permissions and limitations under the License.
17+
*/
18+
19+
#include <aws/common/byte_buf.h>
20+
21+
AWS_EXTERN_C_BEGIN
22+
23+
struct aws_http_header;
24+
struct aws_hpack_context;
25+
26+
/* Library-level init and shutdown */
27+
void aws_hpack_static_table_init(struct aws_allocator *allocator);
28+
void aws_hpack_static_table_clean_up(void);
29+
30+
/* General HPACK API */
31+
struct aws_hpack_context *aws_hpack_context_new(struct aws_allocator *allocator, size_t max_dynamic_elements);
32+
void aws_hpack_context_destroy(struct aws_hpack_context *context);
33+
struct aws_http_header *aws_hpack_get_header(struct aws_hpack_context *context, size_t index);
34+
int aws_hpack_find_index(struct aws_hpack_context *context, const struct aws_http_header *header, size_t *index);
35+
int aws_hpack_insert_header(struct aws_hpack_context *context, const struct aws_http_header *header);
36+
int aws_hpack_resize_dynamic_table(struct aws_hpack_context *context, size_t new_max_elements);
37+
38+
/* Public for testing purposes */
39+
int aws_hpack_encode_integer(uint64_t integer, uint8_t prefix_size, struct aws_byte_buf *output);
40+
int aws_hpack_decode_integer(struct aws_byte_cursor *to_decode, uint8_t prefix_size, uint64_t *integer);
41+
int aws_hpack_encode_string(
42+
struct aws_hpack_context *context,
43+
struct aws_byte_cursor *to_encode,
44+
bool huffman_encode,
45+
struct aws_byte_buf *output);
46+
47+
AWS_EXTERN_C_END
48+
49+
#endif /* AWS_HTTP_HPACK_H */
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
#ifndef HEADER
17+
#error "Macro HEADER(index, name) must be defined before including this header file!"
18+
#endif
19+
20+
#ifndef HEADER_WITH_VALUE
21+
#error "Macro HEADER_WITH_VALUE(index, name, value) must be defined before including this header file!"
22+
#endif
23+
24+
HEADER(1, ":authority")
25+
HEADER_WITH_VALUE(2, ":method", "GET")
26+
HEADER_WITH_VALUE(3, ":method", "POST")
27+
HEADER_WITH_VALUE(4, ":path", "/")
28+
HEADER_WITH_VALUE(5, ":path", "/index.html")
29+
HEADER_WITH_VALUE(6, ":scheme", "http")
30+
HEADER_WITH_VALUE(7, ":scheme", "https")
31+
HEADER_WITH_VALUE(8, ":status", "200")
32+
HEADER_WITH_VALUE(9, ":status", "204")
33+
HEADER_WITH_VALUE(10, ":status", "206")
34+
HEADER_WITH_VALUE(11, ":status", "304")
35+
HEADER_WITH_VALUE(12, ":status", "400")
36+
HEADER_WITH_VALUE(13, ":status", "404")
37+
HEADER_WITH_VALUE(14, ":status", "500")
38+
HEADER(15, "accept-charset")
39+
HEADER_WITH_VALUE(16, "accept-encoding", "gzip,deflate")
40+
HEADER(17, "accept-language")
41+
HEADER(18, "accept-ranges")
42+
HEADER(19, "accept")
43+
HEADER(20, "access-control-allow-origin")
44+
HEADER(21, "age")
45+
HEADER(22, "allow")
46+
HEADER(23, "authorization")
47+
HEADER(24, "cache-control")
48+
HEADER(25, "content-disposition")
49+
HEADER(26, "content-encoding")
50+
HEADER(27, "content-language")
51+
HEADER(28, "content-length")
52+
HEADER(29, "content-location")
53+
HEADER(30, "content-range")
54+
HEADER(31, "content-type")
55+
HEADER(32, "cookie")
56+
HEADER(33, "date")
57+
HEADER(34, "etag")
58+
HEADER(35, "expect")
59+
HEADER(36, "expires")
60+
HEADER(37, "from")
61+
HEADER(38, "host")
62+
HEADER(39, "if-match")
63+
HEADER(40, "if-modified-since")
64+
HEADER(41, "if-none-match")
65+
HEADER(42, "if-range")
66+
HEADER(43, "if-unmodified-since")
67+
HEADER(44, "last-modified")
68+
HEADER(45, "link")
69+
HEADER(46, "location")
70+
HEADER(47, "max-forwards")
71+
HEADER(48, "proxy-authenticate")
72+
HEADER(49, "proxy-authorization")
73+
HEADER(50, "range")
74+
HEADER(51, "referer")
75+
HEADER(52, "refresh")
76+
HEADER(53, "retry-after")
77+
HEADER(54, "server")
78+
HEADER(55, "set-cookie")
79+
HEADER(56, "strict-transport-security")
80+
HEADER(57, "transfer-encoding")
81+
HEADER(58, "user-agent")
82+
HEADER(59, "vary")
83+
HEADER(60, "via")
84+
HEADER(61, "www-authenticate")

0 commit comments

Comments
 (0)