aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndy Green <andy.green@linaro.org>2013-11-09 11:40:32 +0800
committerAndy Green <andy.green@linaro.org>2013-11-09 11:40:32 +0800
commit84fd949e05d011410dba2abe93dfd2fd7dff1589 (patch)
tree49ffbd9ea11bf797fe547bfebc4316962818d27b /lib
parentcc13c6f187f47fd31a377d05477f90c0fd7f7452 (diff)
downloadlibwebsockets-84fd949e05d011410dba2abe93dfd2fd7dff1589.tar.gz
make ah available in http callback properly
Signed-off-by: Andy Green <andy.green@linaro.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/handshake.c7
-rw-r--r--lib/private-libwebsockets.h13
2 files changed, 13 insertions, 7 deletions
diff --git a/lib/handshake.c b/lib/handshake.c
index 3007426b..3e1941cf 100644
--- a/lib/handshake.c
+++ b/lib/handshake.c
@@ -137,9 +137,12 @@ libwebsocket_read(struct libwebsocket_context *context,
/* union transition */
memset(&wsi->u, 0, sizeof(wsi->u));
-
wsi->mode = LWS_CONNMODE_HTTP_SERVING_ACCEPTED;
wsi->state = WSI_STATE_HTTP;
+
+ /* expose it at the same offset as u.hdr */
+ wsi->u.http.ah = ah;
+
n = 0;
if (wsi->protocol->callback)
n = wsi->protocol->callback(context, wsi,
@@ -149,6 +152,8 @@ libwebsocket_read(struct libwebsocket_context *context,
/* now drop the header info we kept a pointer to */
if (ah)
free(ah);
+ /* not possible to continue to use past here */
+ wsi->u.http.ah = NULL;
if (n) {
lwsl_info("LWS_CALLBACK_HTTP closing\n");
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index 5963db58..7cf88995 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -306,12 +306,6 @@ struct libwebsocket_context {
* other APIs to get information out of it.
*/
-struct _lws_http_mode_related {
- int fd;
- unsigned long filepos;
- unsigned long filelen;
-};
-
struct lws_fragments {
unsigned short offset;
unsigned short len;
@@ -330,6 +324,13 @@ struct allocated_headers {
#endif
};
+struct _lws_http_mode_related {
+ struct allocated_headers *ah; /* mirroring _lws_header_related */
+ int fd;
+ unsigned long filepos;
+ unsigned long filelen;
+};
+
struct _lws_header_related {
struct allocated_headers *ah;
short lextable_pos;