-
Notifications
You must be signed in to change notification settings - Fork 0
/
hpacktest.c
82 lines (75 loc) · 5.39 KB
/
hpacktest.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <string.h>
#include "hpack.h"
uint8_t in[] = {
0x20, 0x82, 0x05, 0x89, 0x62, 0x51, 0xf7, 0x31, 0x0f, 0x52, 0xe6, 0x21, 0xff, 0x01, 0x8d, 0x08, 0x17, 0x08, 0x19, 0x5c,
0x2d, 0x2e, 0x17, 0x1b, 0xb8, 0xf3, 0xcd, 0x35, 0x87, 0x0f, 0x2b, 0xbc, 0xd0, 0x7f, 0x66, 0xa2, 0x81, 0xb0, 0xda, 0xe0,
0x53, 0xfa, 0xe4, 0x6a, 0xa4, 0x3f, 0x84, 0x29, 0xa7, 0x7a, 0x81, 0x02, 0xe0, 0xfb, 0x53, 0x91, 0xaa, 0x71, 0xaf, 0xb5,
0x3c, 0xb8, 0xd7, 0xda, 0x96, 0x77, 0xb8, 0x10, 0x32, 0xb8, 0x3f, 0xb5, 0x31, 0x14, 0x9d, 0x4e, 0xc0, 0x80, 0x10, 0x00,
0x20, 0x0a, 0x98, 0x4d, 0x61, 0x65, 0x3f, 0x96, 0x02, 0x06, 0x57, 0x07, 0x0f, 0x04, 0x93, 0x35, 0x23, 0x98, 0xac, 0x0f,
0xb9, 0xa5, 0xfa, 0x35, 0x23, 0x98, 0xac, 0x78, 0x2c, 0x75, 0xfd, 0x7c, 0xb1, 0xf3, 0x0f, 0x02, 0x8b, 0x2d, 0x4b, 0x70,
0xdd, 0xf4, 0x5a, 0xbe, 0xfb, 0x40, 0x05, 0xdb, 0x0f, 0x01, 0x8d, 0x9b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0xde, 0x03, 0x4b,
0xb1, 0x56, 0x6f, 0xaa, 0xcd, 0xf5, 0xf4, 0x60, 0xe7, 0x7b, 0x26, 0xcb, 0xf9, 0xc3, 0x47, 0xb6, 0xbc, 0x6b, 0xd7, 0x54,
0x98, 0x3d, 0x74, 0x54, 0x57, 0x75, 0xcb, 0xc5, 0x37, 0x61, 0xfd, 0x1f, 0x0c, 0xd8, 0x4d, 0xcb, 0xd3, 0x5b, 0xae, 0xc6,
0x2b, 0xc6, 0xfd, 0xcf, 0xd3, 0x86, 0x00, 0x06, 0x1c, 0x93, 0xc3, 0x97, 0xbd, 0x7b, 0x9d, 0xf1, 0x53, 0xfa, 0xeb, 0xa6,
0x6d, 0xff, 0x9c, 0x1d, 0x9a, 0xf6, 0x9d, 0xac, 0xd3, 0x8d, 0xc0, 0xbf, 0xcd, 0x51, 0x61, 0xc7, 0xee, 0x9f, 0x37, 0x4b,
0xc9, 0xa7, 0xa7, 0xf7, 0xdb, 0x9e, 0x9d, 0x3f, 0x00, 0x8a, 0x41, 0x48, 0xb4, 0xa5, 0x49, 0x27, 0x5a, 0x42, 0xa1, 0x3f,
0x84, 0x35, 0x23, 0x98, 0xbf, 0x00, 0x8a, 0x41, 0x48, 0xb4, 0xa5, 0x49, 0x27, 0x5a, 0x93, 0xc8, 0x5f, 0x85, 0xa8, 0xeb,
0x10, 0xf6, 0x23, 0x00, 0x8a, 0x41, 0x48, 0xb4, 0xa5, 0x49, 0x27, 0x59, 0x06, 0x49, 0x7f, 0x88, 0x40, 0xe9, 0x2a, 0xc7,
0xb0, 0xd3, 0x1a, 0xaf, 0x00, 0x82, 0x49, 0x7f, 0x86, 0x4d, 0x83, 0x35, 0x05, 0xb1, 0x1f};
int main() {
size_t read, encode_len;
uint8_t buffer[4096], buffer2[4096];
uint8_t encode[4096];
int huffman_decoder_error;
huffman_decoder_error = hpack_decode(in, sizeof in, buffer, 4096);
if (huffman_decoder_error) {
fprintf(stderr, "Error decoding string: %d\n", huffman_decoder_error);
} else {
printf("%s\n", buffer);
}
huffman_decoder_error = hpack_encode(buffer, strlen(buffer), encode, 4096, &encode_len);
if (huffman_decoder_error) {
fprintf(stderr, "Error decoding string: %d\n", huffman_decoder_error);
} else {
huffman_decoder_error = hpack_decode(encode, encode_len, buffer2, 4096);
if (huffman_decoder_error) {
fprintf(stderr, "Error decoding string: %d\n", huffman_decoder_error);
} else {
printf("%s\n", buffer2);
printf("%d vs %d", strlen(buffer), strlen(buffer2));
printf("strcmp %d\n", strcmp(buffer, buffer2));
}
}
// size_t read, consumed;
// uint8_t buffer[4096];
// int huffman_decoder_error;
// struct hpack_table *hpack = hpack_table_new(1);
// struct hpack_headerblock * hdr = NULL;
// hpack_init();
// hdr = hpack_decode(in, sizeof in, hpack);
// if (hdr) {
// hpack_header_print(hdr);
// }
}