1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00
libwebsockets/minimal-examples/http-client/minimal-http-client-custom-headers
Andy Green b3131fdfdd cmakelist: Augean Stables refactor
Establish a new distributed CMake architecture with CMake code related to
a source directory moving to be in the subdir in its own CMakeLists.txt.
In particular, there's now one in ./lib which calls through to ones
further down the directory tree like ./lib/plat/xxx, ./lib/roles/xxx etc.

This cuts the main CMakelists.txt from 98KB -> 33KB, about a 66% reduction,
and it's much easier to maintain sub-CMakeLists.txt that are in the same
directory as the sources they manage, and conceal all the details that that
level.

Child CMakelists.txt become responsible for:

 - include_directories() definition (this is not supported by CMake
   directly, it passes it back up via PARENT_SCOPE vars in helper
   macros)

 - Addition child CMakeLists.txt inclusion, for example toplevel ->
   role -> role subdir

 - Source file addition to the build

 - Dependent library path resolution... this is now a private thing
   in the child CMakeLists.txt, it just passes back any adaptations
   to include_directories() and the LIB_LIST without filling the
   parent namespace with the details
2020-05-27 08:40:12 +01:00
..
CMakeLists.txt cmakelist: Augean Stables refactor 2020-05-27 08:40:12 +01:00
minimal-http-client-custom-headers.c sul: all timed objects use a single pt sul list 2019-08-09 10:12:09 +01:00
README.md minimal-http-client-custom-headers 2019-03-12 11:57:43 +08:00
warmcat.com.cer tls certs: update warmcat.com and libwebsockets.org public certs 2019-09-22 03:08:36 -07:00

lws minimal http client custom headers

This http client application shows how to send and receive custom headers.

This currently only works on http 1, so the app forces that even if h2 enables.

build

 $ cmake . && make

usage

Commandline option Meaning
-d Debug verbosity in decimal, eg, -d15
-l Connect to https://localhost:7681 and accept selfsigned cert
-n no TLS

The app looks for a custom header "test-custom-header" sent by warmcat.com.

 $ ./lws-minimal-http-client-custom-headers
[2019/03/11 05:46:45:7582] USER: LWS minimal http client Custom Headers [-d<verbosity>] [-l] [--h1]
[2019/03/11 05:46:45:7671] NOTICE: created client ssl context for default
[2019/03/11 05:46:46:7812] USER: Connected with server response: 200
[2019/03/11 05:46:46:7812] NOTICE: callback_http: custom header: 'hello'
[2019/03/11 05:46:46:7814] USER: RECEIVE_CLIENT_HTTP_READ: read 1024
...

You can use the -n and -l to make this test app connect to localhost:7681 over http, and confirm the "dnt:1" header was sent either by tcpdump or by running the test server on :7681 with -d1151

[2019/03/11 05:48:53:6806] PARSER: WSI_TOKEN_NAME_PART 'd' 0x64 (role=0x20000000) wsi->lextable_pos=0
[2019/03/11 05:48:53:6807] PARSER: WSI_TOKEN_NAME_PART 'n' 0x6E (role=0x20000000) wsi->lextable_pos=567
[2019/03/11 05:48:53:6807] PARSER: WSI_TOKEN_NAME_PART 't' 0x74 (role=0x20000000) wsi->lextable_pos=-1
[2019/03/11 05:48:53:6807] PARSER: WSI_TOKEN_NAME_PART ' ' 0x20 (role=0x20000000) wsi->lextable_pos=-1
[2019/03/11 05:48:53:6807] PARSER: WSI_TOKEN_NAME_PART '1' 0x31 (role=0x20000000) wsi->lextable_pos=-1
' 0x0D (role=0x20000000) wsi->lextable_pos=-1NAME_PART '
[2019/03/11 05:48:53:6807] PARSER: WSI_TOKEN_NAME_PART '