[Libwebsockets] Connection failed with code 304
pbrett_11 at yahoo.co.uk
Fri Oct 21 14:32:14 CEST 2016
Don't worry, I'm not about to ask what a 304 error is.
I am deliberately causing this by injecting a "If-Modified-Since" header in my callback under reason LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER. My question is about what happens next. I see the log line lwsl_notice("Connection failed with code %d", n); from lib/client.c (needs a '\n' in my opinion, but that's not important) after which I see a LOCK_POLL, CHANGE_MODE_POLL_FD, UNLOCK_POLL sequence and then just a bunch of GET_THREAD_ID's, which were much faster than my lws_service interval.
I've been ignoring LOCK_POLL, CHANGE_MODE_POLL_FD, UNLOCK_POLL sequences, since I understand they are only used where an external thread is involved.
I would have expected to see a CLIENT_CONNECTION_ERROR (perhaps that's for tcp connection errors?) or some other indication via my callback. How should I be detecting the 304 error - actually it looks like all HTTP error responses are treated the same looking at the code in client.c.
Also, I may be in a minority of 1 here, but it would be useful to me to be able to see the full HTTP response even in the case where the response code is not 200. Basically, I want to be able to poll a server, with 2 aims: to retrieve the latest version of a file when it changes and to synchronise to server time based on the Date header (my application is to run in a device with no RTC). I am seeing a callback with reason LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH as expected when I do not inject the If-Modified-Since code.
My code is based on test-client.c with few changes other than logging every reason in the callback, injecting the extra header as described above and in my main, I only ever call lws_client_connect_via_info once and then use a for loop to call lws_service.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libwebsockets