parent
9570dda5cf
commit
96ef9bcda0
|
@ -36,10 +36,10 @@ static const char *index_page = "index.html";
|
||||||
static void on_request(struct uh_connection *conn)
|
static void on_request(struct uh_connection *conn)
|
||||||
{
|
{
|
||||||
if (!serve_file) {
|
if (!serve_file) {
|
||||||
const struct uh_str path = conn->get_path(conn);
|
struct uh_str path = conn->get_path(conn);
|
||||||
const struct uh_str query = conn->get_query(conn);
|
struct uh_str query = conn->get_query(conn);
|
||||||
const struct uh_str ua = conn->get_header(conn, "User-Agent");
|
struct uh_str ua = conn->get_header(conn, "User-Agent");
|
||||||
const struct uh_str body = conn->get_body(conn);
|
struct uh_str body = conn->get_body(conn);
|
||||||
|
|
||||||
conn->send_head(conn, HTTP_STATUS_OK, -1, NULL);
|
conn->send_head(conn, HTTP_STATUS_OK, -1, NULL);
|
||||||
conn->chunk_printf(conn, "I'm Libuhttpd: %s\n", UHTTPD_VERSION_STRING);
|
conn->chunk_printf(conn, "I'm Libuhttpd: %s\n", UHTTPD_VERSION_STRING);
|
||||||
|
|
|
@ -173,7 +173,7 @@ static const char *conn_get_method_str(struct uh_connection *conn)
|
||||||
return http_method_str(conn->parser.method);
|
return http_method_str(conn->parser.method);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct uh_str conn_get_path(struct uh_connection *conn)
|
static struct uh_str conn_get_path(struct uh_connection *conn)
|
||||||
{
|
{
|
||||||
struct http_parser_url *u = &conn->url_parser;
|
struct http_parser_url *u = &conn->url_parser;
|
||||||
struct uh_request *req = &conn->req;
|
struct uh_request *req = &conn->req;
|
||||||
|
@ -185,7 +185,7 @@ static const struct uh_str conn_get_path(struct uh_connection *conn)
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct uh_str conn_get_query(struct uh_connection *conn)
|
static struct uh_str conn_get_query(struct uh_connection *conn)
|
||||||
{
|
{
|
||||||
struct http_parser_url *u = &conn->url_parser;
|
struct http_parser_url *u = &conn->url_parser;
|
||||||
struct uh_request *req = &conn->req;
|
struct uh_request *req = &conn->req;
|
||||||
|
@ -200,7 +200,7 @@ static const struct uh_str conn_get_query(struct uh_connection *conn)
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct uh_str conn_get_header(struct uh_connection *conn, const char *name)
|
static struct uh_str conn_get_header(struct uh_connection *conn, const char *name)
|
||||||
{
|
{
|
||||||
struct uh_request *req = &conn->req;
|
struct uh_request *req = &conn->req;
|
||||||
int name_len = strlen(name);
|
int name_len = strlen(name);
|
||||||
|
@ -222,7 +222,7 @@ static const struct uh_str conn_get_header(struct uh_connection *conn, const cha
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct uh_str conn_get_body(struct uh_connection *conn)
|
static struct uh_str conn_get_body(struct uh_connection *conn)
|
||||||
{
|
{
|
||||||
return conn->req.body;
|
return conn->req.body;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,10 +98,10 @@ struct uh_connection {
|
||||||
void (*chunk_end)(struct uh_connection *conn);
|
void (*chunk_end)(struct uh_connection *conn);
|
||||||
enum http_method (*get_method)(struct uh_connection *conn);
|
enum http_method (*get_method)(struct uh_connection *conn);
|
||||||
const char *(*get_method_str)(struct uh_connection *conn);
|
const char *(*get_method_str)(struct uh_connection *conn);
|
||||||
const struct uh_str (*get_path)(struct uh_connection *conn);
|
struct uh_str (*get_path)(struct uh_connection *conn);
|
||||||
const struct uh_str (*get_query)(struct uh_connection *conn);
|
struct uh_str (*get_query)(struct uh_connection *conn);
|
||||||
const struct uh_str (*get_header)(struct uh_connection *conn, const char *name);
|
struct uh_str (*get_header)(struct uh_connection *conn, const char *name);
|
||||||
const struct uh_str (*get_body)(struct uh_connection *conn);
|
struct uh_str (*get_body)(struct uh_connection *conn);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct uh_connection *uh_new_connection(struct uh_server *srv, int sock, struct sockaddr_in *addr);
|
struct uh_connection *uh_new_connection(struct uh_server *srv, int sock, struct sockaddr_in *addr);
|
||||||
|
|
Loading…
Reference in New Issue