| 1 |
#ifndef AWS_HTTP_H1_DECODER_H |
| 2 |
#define AWS_HTTP_H1_DECODER_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
#include <aws/http/private/http_impl.h> |
| 10 |
#include <aws/http/private/request_response_impl.h> |
| 11 |
|
| 12 |
struct aws_h1_decoded_header { |
| 13 |
|
| 14 |
enum aws_http_header_name name; |
| 15 |
|
| 16 |
|
| 17 |
struct aws_byte_cursor name_data; |
| 18 |
|
| 19 |
|
| 20 |
struct aws_byte_cursor value_data; |
| 21 |
|
| 22 |
|
| 23 |
struct aws_byte_cursor data; |
| 24 |
}; |
| 25 |
|
| 26 |
struct aws_h1_decoder_vtable { |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
int (*on_header)(const struct aws_h1_decoded_header *header, void *user_data); |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
int (*on_body)(const struct aws_byte_cursor *data, bool finished, void *user_data); |
| 40 |
|
| 41 |
|
| 42 |
int (*on_request)( |
| 43 |
enum aws_http_method method_enum, |
| 44 |
const struct aws_byte_cursor *method_str, |
| 45 |
const struct aws_byte_cursor *uri, |
| 46 |
void *user_data); |
| 47 |
|
| 48 |
|
| 49 |
int (*on_response)(int status_code, void *user_data); |
| 50 |
|
| 51 |
int (*on_done)(void *user_data); |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
struct aws_h1_decoder_params { |
| 58 |
struct aws_allocator *alloc; |
| 59 |
size_t scratch_space_initial_size; |
| 60 |
|
| 61 |
bool is_decoding_requests; |
| 62 |
void *user_data; |
| 63 |
struct aws_h1_decoder_vtable vtable; |
| 64 |
}; |
| 65 |
|
| 66 |
struct aws_h1_decoder; |
| 67 |
|
| 68 |
AWS_EXTERN_C_BEGIN |
| 69 |
|
| 70 |
AWS_HTTP_API struct aws_h1_decoder *aws_h1_decoder_new(struct aws_h1_decoder_params *params); |
| 71 |
AWS_HTTP_API void aws_h1_decoder_destroy(struct aws_h1_decoder *decoder); |
| 72 |
AWS_HTTP_API int aws_h1_decode(struct aws_h1_decoder *decoder, struct aws_byte_cursor *data); |
| 73 |
|
| 74 |
AWS_HTTP_API void aws_h1_decoder_set_logging_id(struct aws_h1_decoder *decoder, const void *id); |
| 75 |
AWS_HTTP_API void aws_h1_decoder_set_body_headers_ignored(struct aws_h1_decoder *decoder, bool body_headers_ignored); |
| 76 |
|
| 77 |
|
| 78 |
#define AWS_HTTP_TRANSFER_ENCODING_CHUNKED (1 << 0) |
| 79 |
#define AWS_HTTP_TRANSFER_ENCODING_GZIP (1 << 1) |
| 80 |
#define AWS_HTTP_TRANSFER_ENCODING_DEFLATE (1 << 2) |
| 81 |
#define AWS_HTTP_TRANSFER_ENCODING_DEPRECATED_COMPRESS (1 << 3) |
| 82 |
AWS_HTTP_API int aws_h1_decoder_get_encoding_flags(const struct aws_h1_decoder *decoder); |
| 83 |
|
| 84 |
AWS_HTTP_API uint64_t aws_h1_decoder_get_content_length(const struct aws_h1_decoder *decoder); |
| 85 |
AWS_HTTP_API bool aws_h1_decoder_get_body_headers_ignored(const struct aws_h1_decoder *decoder); |
| 86 |
AWS_HTTP_API enum aws_http_header_block aws_h1_decoder_get_header_block(const struct aws_h1_decoder *decoder); |
| 87 |
|
| 88 |
AWS_EXTERN_C_END |
| 89 |
|
| 90 |
#endif |