summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/http_decoder.h71
1 files changed, 37 insertions, 34 deletions
diff --git a/include/http_decoder.h b/include/http_decoder.h
index 9ee6ff4..7439016 100644
--- a/include/http_decoder.h
+++ b/include/http_decoder.h
@@ -1,10 +1,12 @@
-#ifndef _HTTP_DECODER_H_
-#define _HTTP_DECODER_H_
+#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
+#include <bits/types/struct_iovec.h>
+
+typedef struct iovec hstring;
enum http_message_type {
HTTP_TRANSACTION_NEW,
@@ -22,87 +24,88 @@ enum http_message_type {
HTTP_MESSAGE_RES_BODY_END,
HTTP_TRANSACTION_FREE,
-
- HTTP_MESSAGE_MAX
-};
-struct hstring {
- char *str;
- size_t str_len;
+ HTTP_MESSAGE_MAX
};
struct http_header {
- struct hstring key;
- struct hstring val;
+ struct iovec key;
+ struct iovec val;
};
struct http_request_line {
- struct hstring method;
- struct hstring uri;
- struct hstring version;
+ struct iovec method;
+ struct iovec uri;
+ struct iovec version;
int major_version;
int minor_version;
};
struct http_response_line {
- struct hstring version;
- struct hstring status;
+ struct iovec version;
+ struct iovec status;
int major_version;
int minor_version;
int status_code;
};
struct http_message;
-#define HTTP_DECODER_TOPIC "HTTP_DECODER_MESSAGE"
+#define HTTP_DECODER_TOPIC "HTTP_DECODER_MESSAGE"
enum http_message_type http_message_type_get(const struct http_message *msg);
-void http_message_get_request_line(const struct http_message *msg,
- struct http_request_line *line);
+void http_message_get_request_line(const struct http_message *msg, struct http_request_line *line);
-void http_message_get_response_line(const struct http_message *msg,
- struct http_response_line *line);
+void http_message_get_response_line(const struct http_message *msg, struct http_response_line *line);
/*
* Pay attention: key->str is case-insensitive.
*/
-void http_message_get_header(const struct http_message *msg,
- const struct hstring *key,
- struct http_header *hdr_result);
+void http_message_get_header(const struct http_message *msg, const struct iovec *key, struct http_header *hdr_result);
/**
* @brief loop reading all headers.
*
* @retval succeed( >= 0) failed(-1)
*/
-int http_message_header_next(const struct http_message *msg,
- struct http_header *header);
+int http_message_header_next(const struct http_message *msg, struct http_header *header);
/**
* @retval succeed( >= 0) failed(-1)
*/
int http_message_reset_header_iter(struct http_message *msg);
-
-void http_message_get_raw_body(const struct http_message *msg,
- struct hstring *body);
+void http_message_get_raw_body(const struct http_message *msg, struct iovec *body);
/**
* @brief If the body hasn't been compressed, same as http_message_get_raw_body().
*
*/
-void http_message_get_decompress_body(const struct http_message *msg,
- struct hstring *body);
+void http_message_get_decompress_body(const struct http_message *msg, struct iovec *body);
-void http_message_get_url(const struct http_message *msg,
- struct hstring *url);
+void http_message_get_url(const struct http_message *msg, struct iovec *url);
/**
* @retval succeed( >= 0) failed(-1)
*/
int http_message_get_transaction_seq(const struct http_message *msg);
+
+
+/************************************************************
+* HTTP TUNNEL WITH CONNECT METHOD.
+*************************************************************/
+struct http_tunnel_message;
+#define HTTP_DECODER_TUNNEL_TOPIC "HTTP_DECODER_TUNNEL_MESSAGE"
+
+enum http_tunnel_message_type {
+ HTTP_TUNNEL_OPENING,
+ HTTP_TUNNEL_ACTIVE,
+ HTTP_TUNNEL_CLOSING,
+ HTTP_TUNNEL_MSG_MAX
+};
+enum http_tunnel_message_type http_tunnel_message_type_get(const struct http_tunnel_message *tmsg);
+void http_tunnel_message_get_payload(const struct http_tunnel_message *tmsg, struct iovec *tunnel_payload);
+
#ifdef __cplusplus
}
#endif
-
-#endif \ No newline at end of file