aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2013-11-09 11:59:56 +0800
committerAndy Green <andy.green@linaro.org>2013-11-09 11:59:56 +0800
commit19895bcfd4e89f96100ab2dca041e965973f8e2b (patch)
tree6ae163d9ccd1545777acb751b82387087e96185b /lib
parent6cd8880f23354ceeba75d641379c8f07407b0570 (diff)
downloadlibwebsockets-19895bcfd4e89f96100ab2dca041e965973f8e2b.tar.gz
introduce LWS_CALLBACK_FILTER_HTTP_CONNECTION
Signed-off-by: Andy Green <andy.green@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/handshake.c5
-rw-r--r--lib/libwebsockets.h13
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/handshake.c b/lib/handshake.c
index 3e1941cf..f1e7dadb 100644
--- a/lib/handshake.c
+++ b/lib/handshake.c
@@ -146,6 +146,11 @@ libwebsocket_read(struct libwebsocket_context *context,
n = 0;
if (wsi->protocol->callback)
n = wsi->protocol->callback(context, wsi,
+ LWS_CALLBACK_FILTER_HTTP_CONNECTION,
+ wsi->user_space, uri_ptr, uri_len);
+
+ if (!n && wsi->protocol->callback)
+ n = wsi->protocol->callback(context, wsi,
LWS_CALLBACK_HTTP,
wsi->user_space, uri_ptr, uri_len);
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index 5cade285..54d485ab 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -148,6 +148,7 @@ enum libwebsocket_callback_reasons {
LWS_CALLBACK_HTTP_FILE_COMPLETION,
LWS_CALLBACK_HTTP_WRITEABLE,
LWS_CALLBACK_FILTER_NETWORK_CONNECTION,
+ LWS_CALLBACK_FILTER_HTTP_CONNECTION,
LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS,
LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS,
@@ -492,6 +493,18 @@ struct libwebsocket_extension;
* Because this happens immediately after the network connection
* from the client, there's no websocket protocol selected yet so
* this callback is issued only to protocol 0.
+ *
+ * LWS_CALLBACK_FILTER_HTTP_CONNECTION: called when the request has
+ * been received and parsed from the client, but the response is
+ * not sent yet. Return non-zero to disallow the connection.
+ * @user is a pointer to the connection user space allocation,
+ * @in is the URI, eg, "/"
+ * In your handler you can use the public APIs
+ * lws_hdr_total_length() / lws_hdr_copy() to access all of the
+ * headers using the header enums lws_token_indexes from
+ * libwebsockets.h to check for and read the supported header
+ * presence and content before deciding to allow the http
+ * connection to proceed or to kill the connection.
*
* LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION: called when the handshake has
* been received and parsed from the client, but the response is