diff --git a/lib/roles/http/client/client.c b/lib/roles/http/client/client.c index bb721ec75..5645fa2b7 100644 --- a/lib/roles/http/client/client.c +++ b/lib/roles/http/client/client.c @@ -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; diff --git a/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c b/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c index 19940ffeb..e3d58aa40 100644 --- a/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c +++ b/minimal-examples/http-client/minimal-http-client-multi/minimal-http-client-multi.c @@ -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",