Fix compiler errors
This commit is contained in:
+4
-4
@@ -311,7 +311,7 @@ void http_request_line(HTTP_RequestHandle handle, HTTP_Method method, HTTP_Strin
|
||||
http_engine_url(&conn->engine, method, url, 1);
|
||||
}
|
||||
|
||||
void http_request_header(HTTP_RequestHandle handle, char *header, int len)
|
||||
void http_request_header(HTTP_RequestHandle handle, HTTP_String str)
|
||||
{
|
||||
ClientConnection *conn = handle2clientconn(handle);
|
||||
if (conn == NULL)
|
||||
@@ -319,10 +319,10 @@ void http_request_header(HTTP_RequestHandle handle, char *header, int len)
|
||||
if (conn->state != CLIENT_CONNECTION_INIT)
|
||||
return;
|
||||
|
||||
http_engine_header(&conn->engine, header, len);
|
||||
http_engine_header(&conn->engine, str);
|
||||
}
|
||||
|
||||
void http_request_body(HTTP_RequestHandle handle, char *body, int len)
|
||||
void http_request_body(HTTP_RequestHandle handle, HTTP_String str)
|
||||
{
|
||||
ClientConnection *conn = handle2clientconn(handle);
|
||||
if (conn == NULL)
|
||||
@@ -330,7 +330,7 @@ void http_request_body(HTTP_RequestHandle handle, char *body, int len)
|
||||
if (conn->state != CLIENT_CONNECTION_INIT)
|
||||
return;
|
||||
|
||||
http_engine_body(&conn->engine, body, len);
|
||||
http_engine_body(&conn->engine, str);
|
||||
}
|
||||
|
||||
void http_request_submit(HTTP_RequestHandle handle)
|
||||
|
||||
+2
-6
@@ -65,15 +65,11 @@ void http_request_line(HTTP_RequestHandle handle, HTTP_Method method, HTTP_Strin
|
||||
|
||||
// Append a header to the specified request. You must call
|
||||
// this after http_request_line and may do so multiple times.
|
||||
//
|
||||
// TODO: use HTTP_String instead of char*+int
|
||||
void http_request_header(HTTP_RequestHandle handle, char *header, int len);
|
||||
void http_request_header(HTTP_RequestHandle handle, HTTP_String str);
|
||||
|
||||
// Append some data to the request's body. You must call
|
||||
// this after either http_request_line or http_request_header.
|
||||
//
|
||||
// TODO: use HTTP_String instead of char*+int
|
||||
void http_request_body(HTTP_RequestHandle handle, char *body, int len);
|
||||
void http_request_body(HTTP_RequestHandle handle, HTTP_String str);
|
||||
|
||||
// Mark the initialization of the request as completed and
|
||||
// perform the request.
|
||||
|
||||
+6
-10
@@ -774,16 +774,14 @@ void http_engine_status(HTTP_Engine *eng, int status)
|
||||
eng->state = HTTP_ENGINE_STATE_SERVER_PREP_HEADER;
|
||||
}
|
||||
|
||||
void http_engine_header(HTTP_Engine *eng, const char *src, int len)
|
||||
void http_engine_header(HTTP_Engine *eng, HTTP_String str)
|
||||
{
|
||||
if ((eng->state & HTTP_ENGINE_STATEBIT_PREP_HEADER) == 0)
|
||||
return;
|
||||
|
||||
if (len < 0) len = strlen(src);
|
||||
|
||||
// TODO: Check that the header is valid
|
||||
|
||||
byte_queue_write(&eng->output, src, len);
|
||||
byte_queue_write(&eng->output, str.ptr, str.len);
|
||||
byte_queue_write(&eng->output, "\r\n", 2);
|
||||
}
|
||||
|
||||
@@ -848,16 +846,14 @@ static void complete_message_body(HTTP_Engine *eng)
|
||||
byte_queue_patch(&eng->output, eng->content_length_value_offset, tmp + i, 10 - i);
|
||||
}
|
||||
|
||||
void http_engine_body(HTTP_Engine *eng, void *src, int len)
|
||||
void http_engine_body(HTTP_Engine *eng, HTTP_String str)
|
||||
{
|
||||
if (len < 0) len = strlen(src);
|
||||
|
||||
http_engine_bodycap(eng, len);
|
||||
http_engine_bodycap(eng, str.len);
|
||||
int cap;
|
||||
char *buf = http_engine_bodybuf(eng, &cap);
|
||||
if (buf) {
|
||||
memcpy(buf, src, len);
|
||||
http_engine_bodyack(eng, len);
|
||||
memcpy(buf, str.ptr, str.len);
|
||||
http_engine_bodyack(eng, str.len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -108,8 +108,8 @@ HTTP_Response* http_engine_getres (HTTP_Engine *eng);
|
||||
|
||||
void http_engine_url (HTTP_Engine *eng, HTTP_Method method, HTTP_String url, int minor);
|
||||
void http_engine_status (HTTP_Engine *eng, int status);
|
||||
void http_engine_header (HTTP_Engine *eng, const char *src, int len);
|
||||
void http_engine_body (HTTP_Engine *eng, void *src, int len);
|
||||
void http_engine_header (HTTP_Engine *eng, HTTP_String str);
|
||||
void http_engine_body (HTTP_Engine *eng, HTTP_String str);
|
||||
void http_engine_bodycap (HTTP_Engine *eng, int mincap);
|
||||
char* http_engine_bodybuf (HTTP_Engine *eng, int *cap);
|
||||
void http_engine_bodyack (HTTP_Engine *eng, int num);
|
||||
|
||||
+2
-2
@@ -358,7 +358,7 @@ static int serve_dynamic_route(Route *route, HTTP_Request *req, HTTP_ResponseHan
|
||||
int path_len = sanitize_path(req->url.path, path_mem, (int) sizeof(path_mem));
|
||||
if (path_len < 0) {
|
||||
http_response_status(res, 400);
|
||||
http_response_body(res, "Invalid path", -1);
|
||||
http_response_body(res, HTTP_STR("Invalid path"));
|
||||
http_response_done(res);
|
||||
return 1;
|
||||
}
|
||||
@@ -403,7 +403,7 @@ int http_serve(char *addr, int port, HTTP_Router *router)
|
||||
{
|
||||
int ret;
|
||||
|
||||
HTTP_Server *server = http_server_init((HTTP_String) { addr, strlen(addr) }, port, 0, (HTTP_String) {}, (HTTP_String) {});
|
||||
HTTP_Server *server = http_server_init_ex((HTTP_String) { addr, strlen(addr) }, port, 0, (HTTP_String) {}, (HTTP_String) {});
|
||||
if (server == NULL) {
|
||||
http_router_free(router);
|
||||
return -1;
|
||||
|
||||
+2
-6
@@ -133,7 +133,6 @@ HTTP_Server *http_server_init_ex(HTTP_String addr, uint16_t port,
|
||||
}
|
||||
}
|
||||
|
||||
server->num_websites = 0;
|
||||
server->num_conns = 0;
|
||||
server->ready_head = 0;
|
||||
server->ready_count = 0;
|
||||
@@ -368,16 +367,13 @@ void http_response_header(HTTP_ResponseHandle res, const char *fmt, ...)
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void http_response_body(HTTP_ResponseHandle res, char *src, int len)
|
||||
void http_response_body(HTTP_ResponseHandle res, HTTP_String str)
|
||||
{
|
||||
Connection *conn = handle2conn(res);
|
||||
if (conn == NULL)
|
||||
return;
|
||||
|
||||
if (len < 0)
|
||||
len = strlen(src);
|
||||
|
||||
http_engine_body(&conn->engine, src, len);
|
||||
http_engine_body(&conn->engine, str);
|
||||
}
|
||||
|
||||
void http_response_bodycap(HTTP_ResponseHandle res, int mincap)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ int http_server_wait (HTTP_Server *server, HTTP_Request **req, H
|
||||
int http_server_add_website (HTTP_Server *server, HTTP_String domain, HTTP_String cert_file, HTTP_String key_file);
|
||||
void http_response_status (HTTP_ResponseHandle res, int status);
|
||||
void http_response_header (HTTP_ResponseHandle res, const char *fmt, ...);
|
||||
void http_response_body (HTTP_ResponseHandle res, char *src, int len);
|
||||
void http_response_body (HTTP_ResponseHandle res, HTTP_String str);
|
||||
void http_response_bodycap (HTTP_ResponseHandle res, int mincap);
|
||||
char* http_response_bodybuf (HTTP_ResponseHandle res, int *cap);
|
||||
void http_response_bodyack (HTTP_ResponseHandle res, int num);
|
||||
|
||||
Reference in New Issue
Block a user