[Libwebsockets] Logging WS HS

Andy Green andy at warmcat.com
Mon Mar 9 07:42:45 CET 2020

On 3/8/20 2:24 PM, o_O凌雲 wrote:
> the current master added the callback 
> reason:LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP, the last opportunity to get 

The general idea of the patch is that a denied ws upgrade should better 
understand that it logically stays as http on both sides.  It's 
specifically aimed at failed ws upgrade case only.

The patch is making a failed ws upgrade negotiation response act just 
like a http client getting an http response from the server.

So IIUI what you're asking is "how do I read http client bodies".

> server reply. But how to Get the content of reply? can you show an 
> example? thanks.

The minimal-http-client example does what you want.  For example

$ ./bin/lws-minimal-http-client --path /git/noexist

goes to https://libwebsockets.org/git/noexist which blows a 403 
Forbidden (libwebsockets.org itself is configured to return a valid page 
for 404s with styles, /git is actually a reverse proxy to an instance of 
gitohashi which will return a 403 for that suitable for this test).

If you enable this in the example


you will see the client example is dumping

[2020/03/09 06:37:37:7771] U: Connected to, http 
response: 403
<html><head><meta charset=utf-8 http-equiv="Content-Language" 
content="en"/><link rel="stylesheet" type="text/css" 
href="/error.css"/></head><body><h1>403</h1>403 Forbidden</body></html>


More information about the Libwebsockets mailing list