Reimplement http -> https redirects. Remove request phases. With just a little extra storage, it wasn't needed.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4723 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
14
src/http.h
14
src/http.h
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef struct _tf_http_connection_t tf_http_connection_t;
|
||||
@ -8,18 +9,13 @@ typedef struct _tf_http_t tf_http_t;
|
||||
typedef struct _tf_tls_context_t tf_tls_context_t;
|
||||
typedef struct uv_loop_s uv_loop_t;
|
||||
|
||||
typedef enum _tf_http_callback_phase_t
|
||||
{
|
||||
k_http_callback_phase_headers_received,
|
||||
k_http_callback_phase_request_done,
|
||||
} tf_http_callback_phase_t;
|
||||
|
||||
typedef void (tf_http_message_callback)(tf_http_request_t* request, int op_code, const void* data, size_t size);
|
||||
|
||||
typedef struct _tf_http_request_t
|
||||
{
|
||||
tf_http_callback_phase_t phase;
|
||||
tf_http_t* http;
|
||||
tf_http_connection_t* connection;
|
||||
bool is_tls;
|
||||
const char* method;
|
||||
const char* path;
|
||||
const char* query;
|
||||
@ -34,6 +30,7 @@ typedef struct _tf_http_request_t
|
||||
} tf_http_request_t;
|
||||
|
||||
typedef void (tf_http_callback_t)(tf_http_request_t* request);
|
||||
typedef void (tf_http_cleanup_t)(void* user_data);
|
||||
|
||||
tf_http_t* tf_http_create(uv_loop_t* loop);
|
||||
int tf_http_listen(tf_http_t* http, int port, tf_tls_context_t* tls);
|
||||
@ -42,6 +39,9 @@ void tf_http_respond(tf_http_request_t* request, int status, const char** header
|
||||
size_t tf_http_get_body(const tf_http_request_t* request, const void** out_data);
|
||||
void tf_http_destroy(tf_http_t* http);
|
||||
|
||||
void tf_http_set_user_data(tf_http_t* http, void* user_data, tf_http_cleanup_t* cleanup);
|
||||
void* tf_http_get_user_data(tf_http_t* http);
|
||||
|
||||
void tf_http_request_ref(tf_http_request_t* request);
|
||||
void tf_http_request_release(tf_http_request_t* request);
|
||||
const char* tf_http_request_get_header(tf_http_request_t* request, const char* name);
|
||||
|
Reference in New Issue
Block a user