mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
client: use effective wsi for some callbacks
This commit is contained in:
parent
9a1462d221
commit
d9e6263323
2 changed files with 23 additions and 10 deletions
|
@ -633,12 +633,20 @@ lws_http_transaction_completed_client(struct lws *wsi)
|
|||
}
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN unsigned int
|
||||
lws_http_client_http_response(struct lws *wsi)
|
||||
lws_http_client_http_response(struct lws *_wsi)
|
||||
{
|
||||
if (!wsi->http.ah)
|
||||
return 0;
|
||||
struct lws *wsi;
|
||||
unsigned int resp;
|
||||
|
||||
return wsi->http.ah->http_response;
|
||||
if (_wsi->http.ah && _wsi->http.ah->http_response)
|
||||
return _wsi->http.ah->http_response;
|
||||
|
||||
lws_vhost_lock(_wsi->vhost);
|
||||
wsi = _lws_client_wsi_master(_wsi);
|
||||
resp = wsi->http.ah->http_response;
|
||||
lws_vhost_unlock(_wsi->vhost);
|
||||
|
||||
return resp;
|
||||
}
|
||||
#endif
|
||||
#if defined(LWS_PLAT_OPTEE)
|
||||
|
@ -914,9 +922,9 @@ lws_client_interpret_server_handshake(struct lws *wsi)
|
|||
* we seem to be good to go, give client last chance to check
|
||||
* headers and OK it
|
||||
*/
|
||||
if (wsi->protocol->callback(wsi,
|
||||
if (w->protocol->callback(w,
|
||||
LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH,
|
||||
wsi->user_space, NULL, 0)) {
|
||||
w->user_space, NULL, 0)) {
|
||||
|
||||
cce = "HS: disallowed by client filter";
|
||||
goto bail2;
|
||||
|
@ -928,9 +936,9 @@ lws_client_interpret_server_handshake(struct lws *wsi)
|
|||
wsi->rxflow_change_to = LWS_RXFLOW_ALLOW;
|
||||
|
||||
/* call him back to inform him he is up */
|
||||
if (wsi->protocol->callback(wsi,
|
||||
if (w->protocol->callback(w,
|
||||
LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP,
|
||||
wsi->user_space, NULL, 0)) {
|
||||
w->user_space, NULL, 0)) {
|
||||
cce = "HS: disallowed at ESTABLISHED";
|
||||
goto bail3;
|
||||
}
|
||||
|
@ -968,9 +976,9 @@ bail2:
|
|||
n = 0;
|
||||
if (cce)
|
||||
n = (int)strlen(cce);
|
||||
wsi->protocol->callback(wsi,
|
||||
w->protocol->callback(w,
|
||||
LWS_CALLBACK_CLIENT_CONNECTION_ERROR,
|
||||
wsi->user_space, (void *)cce,
|
||||
w->user_space, (void *)cce,
|
||||
(unsigned int)n);
|
||||
}
|
||||
wsi->already_did_cce = 1;
|
||||
|
|
|
@ -52,6 +52,11 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason,
|
|||
|
||||
switch (reason) {
|
||||
|
||||
case LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP:
|
||||
lwsl_user("LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP: resp %u\n",
|
||||
lws_http_client_http_response(wsi));
|
||||
break;
|
||||
|
||||
/* because we are protocols[0] ... */
|
||||
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
|
||||
lwsl_err("CLIENT_CONNECTION_ERROR: %s\n",
|
||||
|
|
Loading…
Add table
Reference in a new issue