#ifndef _HYPER_H
#define _HYPER_H
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#define HYPER_ITER_CONTINUE 0
#define HYPER_ITER_BREAK 1
#define HYPER_HTTP_VERSION_NONE 0
#define HYPER_HTTP_VERSION_1_0 10
#define HYPER_HTTP_VERSION_1_1 11
#define HYPER_HTTP_VERSION_2 20
#define HYPER_IO_PENDING 4294967295
#define HYPER_IO_ERROR 4294967294
#define HYPER_POLL_READY 0
#define HYPER_POLL_PENDING 1
#define HYPER_POLL_ERROR 3
typedef enum hyper_code {
HYPERE_OK,
HYPERE_ERROR,
HYPERE_INVALID_ARG,
HYPERE_UNEXPECTED_EOF,
HYPERE_ABORTED_BY_CALLBACK,
HYPERE_FEATURE_NOT_ENABLED,
HYPERE_INVALID_PEER_MESSAGE,
} hyper_code;
typedef enum hyper_task_return_type {
HYPER_TASK_EMPTY,
HYPER_TASK_ERROR,
HYPER_TASK_CLIENTCONN,
HYPER_TASK_RESPONSE,
HYPER_TASK_BUF,
} hyper_task_return_type;
typedef struct hyper_body hyper_body;
typedef struct hyper_buf hyper_buf;
typedef struct hyper_clientconn hyper_clientconn;
typedef struct hyper_clientconn_options hyper_clientconn_options;
typedef struct hyper_context hyper_context;
typedef struct hyper_error hyper_error;
typedef struct hyper_executor hyper_executor;
typedef struct hyper_headers hyper_headers;
typedef struct hyper_io hyper_io;
typedef struct hyper_request hyper_request;
typedef struct hyper_response hyper_response;
typedef struct hyper_task hyper_task;
typedef struct hyper_waker hyper_waker;
typedef int (*hyper_body_foreach_callback)(void*, const struct hyper_buf*);
typedef int (*hyper_body_data_callback)(void*, struct hyper_context*, struct hyper_buf**);
typedef void (*hyper_request_on_informational_callback)(void*, struct hyper_response*);
typedef int (*hyper_headers_foreach_callback)(void*, const uint8_t*, size_t, const uint8_t*, size_t);
typedef size_t (*hyper_io_read_callback)(void*, struct hyper_context*, uint8_t*, size_t);
typedef size_t (*hyper_io_write_callback)(void*, struct hyper_context*, const uint8_t*, size_t);
#ifdef __cplusplus
extern "C" {
#endif
const char *hyper_version(void);
struct hyper_body *hyper_body_new(void);
void hyper_body_free(struct hyper_body *body);
struct hyper_task *hyper_body_data(struct hyper_body *body);
struct hyper_task *hyper_body_foreach(struct hyper_body *body,
hyper_body_foreach_callback func,
void *userdata);
void hyper_body_set_userdata(struct hyper_body *body, void *userdata);
void hyper_body_set_data_func(struct hyper_body *body, hyper_body_data_callback func);
struct hyper_buf *hyper_buf_copy(const uint8_t *buf, size_t len);
const uint8_t *hyper_buf_bytes(const struct hyper_buf *buf);
size_t hyper_buf_len(const struct hyper_buf *buf);
void hyper_buf_free(struct hyper_buf *buf);
struct hyper_task *hyper_clientconn_handshake(struct hyper_io *io,
struct hyper_clientconn_options *options);
struct hyper_task *hyper_clientconn_send(struct hyper_clientconn *conn, struct hyper_request *req);
void hyper_clientconn_free(struct hyper_clientconn *conn);
struct hyper_clientconn_options *hyper_clientconn_options_new(void);
void hyper_clientconn_options_set_preserve_header_case(struct hyper_clientconn_options *opts,
int enabled);
void hyper_clientconn_options_set_preserve_header_order(struct hyper_clientconn_options *opts,
int enabled);
void hyper_clientconn_options_free(struct hyper_clientconn_options *opts);
void hyper_clientconn_options_exec(struct hyper_clientconn_options *opts,
const struct hyper_executor *exec);
enum hyper_code hyper_clientconn_options_http2(struct hyper_clientconn_options *opts, int enabled);
enum hyper_code hyper_clientconn_options_http1_allow_multiline_headers(struct hyper_clientconn_options *opts,
int enabled);
void hyper_error_free(struct hyper_error *err);
enum hyper_code hyper_error_code(const struct hyper_error *err);
size_t hyper_error_print(const struct hyper_error *err, uint8_t *dst, size_t dst_len);
struct hyper_request *hyper_request_new(void);
void hyper_request_free(struct hyper_request *req);
enum hyper_code hyper_request_set_method(struct hyper_request *req,
const uint8_t *method,
size_t method_len);
enum hyper_code hyper_request_set_uri(struct hyper_request *req,
const uint8_t *uri,
size_t uri_len);
enum hyper_code hyper_request_set_uri_parts(struct hyper_request *req,
const uint8_t *scheme,
size_t scheme_len,
const uint8_t *authority,
size_t authority_len,
const uint8_t *path_and_query,
size_t path_and_query_len);
enum hyper_code hyper_request_set_version(struct hyper_request *req, int version);
struct hyper_headers *hyper_request_headers(struct hyper_request *req);
enum hyper_code hyper_request_set_body(struct hyper_request *req, struct hyper_body *body);
enum hyper_code hyper_request_on_informational(struct hyper_request *req,
hyper_request_on_informational_callback callback,
void *data);
void hyper_response_free(struct hyper_response *resp);
uint16_t hyper_response_status(const struct hyper_response *resp);
const uint8_t *hyper_response_reason_phrase(const struct hyper_response *resp);
size_t hyper_response_reason_phrase_len(const struct hyper_response *resp);
int hyper_response_version(const struct hyper_response *resp);
struct hyper_headers *hyper_response_headers(struct hyper_response *resp);
struct hyper_body *hyper_response_body(struct hyper_response *resp);
void hyper_headers_foreach(const struct hyper_headers *headers,
hyper_headers_foreach_callback func,
void *userdata);
enum hyper_code hyper_headers_set(struct hyper_headers *headers,
const uint8_t *name,
size_t name_len,
const uint8_t *value,
size_t value_len);
enum hyper_code hyper_headers_add(struct hyper_headers *headers,
const uint8_t *name,
size_t name_len,
const uint8_t *value,
size_t value_len);
struct hyper_io *hyper_io_new(void);
void hyper_io_free(struct hyper_io *io);
void hyper_io_set_userdata(struct hyper_io *io, void *data);
void hyper_io_set_read(struct hyper_io *io, hyper_io_read_callback func);
void hyper_io_set_write(struct hyper_io *io, hyper_io_write_callback func);
const struct hyper_executor *hyper_executor_new(void);
void hyper_executor_free(const struct hyper_executor *exec);
enum hyper_code hyper_executor_push(const struct hyper_executor *exec, struct hyper_task *task);
struct hyper_task *hyper_executor_poll(const struct hyper_executor *exec);
void hyper_task_free(struct hyper_task *task);
void *hyper_task_value(struct hyper_task *task);
enum hyper_task_return_type hyper_task_type(struct hyper_task *task);
void hyper_task_set_userdata(struct hyper_task *task, void *userdata);
void *hyper_task_userdata(struct hyper_task *task);
struct hyper_waker *hyper_context_waker(struct hyper_context *cx);
void hyper_waker_free(struct hyper_waker *waker);
void hyper_waker_wake(struct hyper_waker *waker);
#ifdef __cplusplus
} #endif
#endif