introduce LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER
This adds a callback to protocols[0] which happens when the
Client HTTP handshake packet is being composed. After all the
headers for the websocket handshake to the server have been
added, the callback is called with a pointer to a char *
that allows extra headers to be added. See the comments in
libwebsocket.h or the api documentation for example code.
Signed-off-by: Andy Green <andy@warmcat.com>
diff --git a/libwebsockets-api-doc.html b/libwebsockets-api-doc.html
index 966df7d..8cc72c4 100644
--- a/libwebsockets-api-doc.html
+++ b/libwebsockets-api-doc.html
@@ -621,6 +621,32 @@
This also means that if you don't handle this callback then
the default callback action of returning 0 allows the client
certificates.
+</blockquote>
+<h3>LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER</h3>
+<blockquote>
+this callback happens
+when a client handshake is being compiled. <tt><b>user</b></tt> is NULL,
+<tt><b>in</b></tt> is a char **, it's pointing to a char * which holds the
+next location in the header buffer where you can add
+headers, and <tt><b>len</b></tt> is the remaining space in the header buffer,
+which is typically some hundreds of bytes. So, to add a canned
+cookie, your handler code might look similar to:
+<p>
+char **p = (char **)in;
+<p>
+if (len < 100)
+return 1;
+<p>
+*p += sprintf(*p, "Cookie: a=b\x0d\x0a");
+<p>
+return 0;
+<p>
+Notice if you add anything, you just have to take care about
+the CRLF on the line you added. Obviously this callback is
+optional, if you don't handle it everything is fine.
+<p>
+Notice the callback is coming to protocols[0] all the time,
+because there is no specific protocol handshook yet.
<p>
The next four reasons are optional and only need taking care of if you
will be integrating libwebsockets sockets into an external polling