map wsorigin on to origin at an early point and stop dupe header mem leaks
authorAndy Green <andy@warmcat.com>
Tue, 3 Apr 2012 15:02:20 +0000 (17:02 +0200)
committerAndy Green <andy.green@linaro.org>
Wed, 4 Apr 2012 00:29:08 +0000 (08:29 +0800)
commitfd963309209cc22d212f2f33b43147a3a449897b
treeaa9e41e07b6efda689cc0f4e71e1cb93a9380217
parent5519d9f0544264fe71e0badd3d858d8ffbef2431
map wsorigin on to origin at an early point and stop dupe header mem leaks

Carlo wrote

''I'm interested to use the libwebsockets server (C based) with a Java
websocket client. I was able to implement a Java websocket client based
on JWebSocket library that works fine with the libwebsockets server, but
I was obliged to patch the libwebsockets server in order to reach my
goal. In particular I patched the handshake_00() function because
JWebSocket library uses hixie 76 version. The problem was that the
JWebSocket library sends only WSI_TOKEN_SWORIGIN token instead
WSI_TOKEN_ORIGIN token. For this reason the handshake_00 failed because
the token length of WSI_TOKEN_ORIGIN was 0. I have written a patch in
order to control if at least one of the two tokens (WSI_TOKEN_SWORIGIN
and WSI_TOKEN_ORIGIN) is defined. I have attached into the e-mail the
patch. Probably it can be written better, but in any case I think that
this problem should be fixed for client/server compatibility.''

I found a simpler approach which is convert WSORIGIN processing to
go into ORIGIN token at the earliest point, then everything else can
stay the same.

I also noticed we would leak on duplicated headers and fixed that.

Reported-by: Carlo PARATA <carlo.parata@st.com>
Signed-off-by: Andy Green <andy@warmcat.com>
lib/parsers.c