libuhttpd: New callback: on_accept

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao committed 2018-07-23 23:42:16 +08:00
1 parent f21e2001e1
commit ddf6e8dd86
4 files changed
+17

No files matched your search

+9
View File
@@ -121,6 +121,11 @@ static inline const char *client_get_peer_addr(struct uh_client *cl)
return inet_ntoa(cl->peer_addr.sin_addr);
}
static inline int client_get_peer_port(struct uh_client *cl)
{
return ntohs(cl->peer_addr.sin_port);
}
static inline const char *client_get_url(struct uh_client *cl)
{
return kvlist_get(&cl->request.url, "url");
@@ -625,6 +630,7 @@ void uh_accept_client(struct uh_server *srv, bool ssl)
cl->get_version = client_get_version;
cl->get_method = client_get_method;
cl->get_peer_addr = client_get_peer_addr;
cl->get_peer_port = client_get_peer_port;
cl->get_url = client_get_url;
cl->get_path = client_get_path;
cl->get_query = client_get_query;
@@ -632,6 +638,9 @@ void uh_accept_client(struct uh_server *srv, bool ssl)
cl->get_header = client_get_header;
cl->get_body = client_get_body;
if (srv->on_accept)
srv->on_accept(cl);
return;
err:
close(sfd);
+1
View File
@@ -120,6 +120,7 @@ struct uh_client {
const char *(*get_method)(struct uh_client *cl);
const char *(*get_version)(struct uh_client *cl);
const char *(*get_peer_addr)(struct uh_client *cl);
int (*get_peer_port)(struct uh_client *cl);
const char *(*get_url)(struct uh_client *cl);
const char *(*get_path)(struct uh_client *cl);
const char *(*get_query)(struct uh_client *cl);
+1
View File
@@ -36,6 +36,7 @@ struct uh_server {
void (*set_index_file)(struct uh_server *srv, const char *index_file);
void (*on_error404)(struct uh_client *cl);
int (*on_request)(struct uh_client *cl);
void (*on_accept)(struct uh_client *cl);
#if (UHTTPD_SSL_SUPPORT)
int (*ssl_init)(struct uh_server *srv, const char *key, const char *crt);