[Libwebsockets] POST client

Karl Vogel karl.vogel at gmail.com
Fri Mar 6 15:52:15 CET 2020


On Fri, Mar 6, 2020 at 3:45 PM Andy Green <andy at warmcat.com> wrote:
> On 3/6/20 1:32 PM, Karl Vogel wrote:
>
> > [2020/03/06 14:27:45:1392] I: Initial logging level 1151
> > [2020/03/06 14:27:45:1393] I: Libwebsockets version: 4.0.0 v4.0.0
>
> ...
>
> > [2020/03/06 14:27:45:1431] D: lws_client_socket_service:
> > buflist-aware-read 0 120
> > [2020/03/06 14:27:45:1431] P: WSI_TOKEN_NAME_PART 'H' 0x48
> > (role=0x10000000) wsi->lextable_pos=0
> > [2020/03/06 14:27:45:1431] P: WSI_TOKEN_NAME_PART 'T' 0x54
> > (role=0x10000000) wsi->lextable_pos=87
> > [2020/03/06 14:27:45:1431] P: WSI_TOKEN_NAME_PART 'T' 0x54
> > (role=0x10000000) wsi->lextable_pos=173
> > [2020/03/06 14:27:45:1431] P: WSI_TOKEN_NAME_PART 'P' 0x50
> > (role=0x10000000) wsi->lextable_pos=174
> > [2020/03/06 14:27:45:1431] P: WSI_TOKEN_NAME_PART '/' 0x2F
> > (role=0x10000000) wsi->lextable_pos=175
> > [2020/03/06 14:27:45:1432] P: WSI_TOKEN_NAME_PART '1' 0x31
> > (role=0x10000000) wsi->lextable_pos=947
> > [2020/03/06 14:27:45:1432] P: WSI_TOKEN_NAME_PART '.' 0x2E
> > (role=0x10000000) wsi->lextable_pos=948
> > [2020/03/06 14:27:45:1432] P: WSI_TOKEN_NAME_PART '1' 0x31
> > (role=0x10000000) wsi->lextable_pos=949
> > [2020/03/06 14:27:45:1432] P: WSI_TOKEN_NAME_PART ' ' 0x20
> > (role=0x10000000) wsi->lextable_pos=-1
>
> Hum, it came off the rails there, the input is fine and it's following
> the parse path for "http/1.1 " fine until the space.
>
> >> Make sure you're using today's current master HEAD, it's
> >> 1289b0a0ef6fde60cb2d765c380a67167ca522f2 at the moment, or v4.0-stable
> >> that's out today.  Under some conditions http headers were broken a few
> >> days ago briefly on master due to changes allowing chopping them down if
> >> h2, ws, or "uncommon headers" are disabled for build in cmake, for very
> >> small footprint case.
> >
> > Pulled in the last few commits, but same issue. The included debug log
> > is versus the
> > 1289b0a0ef6fde60cb2d765c380a67167ca522f2 commit.
>
> Here I can do an h1 POST fine
>
> $ ./bin/lws-minimal-http-client-post --h1
> [2020/03/06 14:35:02:2123] U: LWS minimal http client - POST
> [-d<verbosity>] [-l] [--h1]
> [2020/03/06 14:35:02:2124] N: lws_create_context: using ss proxy bind
> '(null)', port 0, ads '(null)'
> [2020/03/06 14:35:02:2930] U: callback_http: doing POST flow
> [2020/03/06 14:35:02:2931] U: LWS_CALLBACK_CLIENT_HTTP_WRITEABLE
> [2020/03/06 14:35:02:2932] U: LWS_CALLBACK_CLIENT_HTTP_WRITEABLE
> [2020/03/06 14:35:02:2932] U: LWS_CALLBACK_CLIENT_HTTP_WRITEABLE
> [2020/03/06 14:35:02:3264] U: Connected with server response: 200
> [2020/03/06 14:35:02:3264] U: RECEIVE_CLIENT_HTTP_READ: read 538
> [2020/03/06 14:35:02:3265] N:
> [2020/03/06 14:35:02:3265] N: 0000: 3C 21 44 4F 43 54 59 50 45 20 68 74
> 6D 6C 3E 3C    <!DOCTYPE html><
> [2020/03/06 14:35:02:3265] N: 0010: 68 74 6D 6C 20 6C 61 6E 67 3D 22 65
> 6E 22 3E 3C    html lang="en"><
> [2020/03/06 14:35:02:3265] N: 0020: 68 65 61 64 3E 3C 6D 65 74 61 20 63
> 68 61 72 73    head><meta chars
> [2020/03/06 14:35:02:3266] N: 0030: 65 74 3D 75 74 66 2D 38 20 68 74 74
> 70 2D 65 71    et=utf-8 http-eq
> [2020/03/06 14:35:02:3266] N: 0040: 75 69 76 3D 22 43 6F 6E 74 65 6E 74
> 2D 4C 61 6E    uiv="Content-Lan
> [2020/03/06 14:35:02:3266] N: 0050: 67 75 61 67 65 22 20 63 6F 6E 74 65
> 6E 74 3D 22    guage" content="
> [2020/03/06 14:35:02:3266] N: 0060: 65 6E 22 2F 3E 3C 74 69 74 6C 65 3E
> 4C 57 53 20    en"/><title>LWS
> [2020/03/06 14:35:02:3266] N: 0070: 53 65 72 76 65 72 20 53 74 61 74 75
> 73 3C 2F 74    Server Status</t
> [2020/03/06 14:35:02:3266] N: 0080: 69 74 6C 65 3E 3C 2F 68 65 61 64 3E
> 3C 62 6F 64    itle></head><bod
> [2020/03/06 14:35:02:3266] N: 0090: 79 3E 3C 68 31 3E 46 6F 72 6D 20 72
> 65 73 75 6C    y><h1>Form resul
> [2020/03/06 14:35:02:3267] N: 00A0: 74 73 20 28 61 66 74 65 72 20 75 72
> 6C 64 65 63    ts (after urldec
> [2020/03/06 14:35:02:3267] N: 00B0: 6F 64 69 6E 67 29 3C 2F 68 31 3E 3C
> 74 61 62 6C    oding)</h1><tabl
> [2020/03/06 14:35:02:3267] N: 00C0: 65 3E 3C 74 72 3E 3C 74 64 3E 4E 61
> 6D 65 3C 2F    e><tr><td>Name</
> [2020/03/06 14:35:02:3267] N: 00D0: 74 64 3E 3C 74 64 3E 4C 65 6E 67 74
> 68 3C 2F 74    td><td>Length</t
> [2020/03/06 14:35:02:3267] N: 00E0: 64 3E 3C 74 64 3E 56 61 6C 75 65 3C
> 2F 74 64 3E    d><td>Value</td>
> [2020/03/06 14:35:02:3267] N: 00F0: 3C 2F 74 72 3E 3C 74 72 3E 3C 74 64
> 3E 3C 62 3E    </tr><tr><td><b>
> [2020/03/06 14:35:02:3267] N: 0100: 74 65 78 74 3C 2F 62 3E 3C 2F 74 64
> 3E 3C 74 64    text</b></td><td
> [2020/03/06 14:35:02:3268] N: 0110: 3E 31 35 3C 2F 74 64 3E 3C 74 64 3E
> 6D 79 20 74    >15</td><td>my t
> [2020/03/06 14:35:02:3268] N: 0120: 65 78 74 20 66 69 65 6C 64 0D 0A 3C
> 2F 74 64 3E    ext field..</td>
> [2020/03/06 14:35:02:3268] N: 0130: 3C 2F 74 72 3E 3C 74 72 3E 3C 74 64
> 3E 3C 62 3E    </tr><tr><td><b>
> [2020/03/06 14:35:02:3268] N: 0140: 73 65 6E 64 3C 2F 62 3E 3C 2F 74 64
> 3E 3C 74 64    send</b></td><td
> [2020/03/06 14:35:02:3268] N: 0150: 3E 30 3C 2F 74 64 3E 3C 74 64 3E 4E
> 55 4C 4C 3C    >0</td><td>NULL<
> [2020/03/06 14:35:02:3268] N: 0160: 2F 74 64 3E 3C 2F 74 72 3E 3C 74 72
> 3E 3C 74 64    /td></tr><tr><td
> [2020/03/06 14:35:02:3269] N: 0170: 3E 3C 62 3E 66 69 6C 65 3C 2F 62 3E
> 3C 2F 74 64    ><b>file</b></td
> [2020/03/06 14:35:02:3269] N: 0180: 3E 3C 74 64 3E 30 3C 2F 74 64 3E 3C
> 74 64 3E 4E    ><td>0</td><td>N
> [2020/03/06 14:35:02:3269] N: 0190: 55 4C 4C 3C 2F 74 64 3E 3C 2F 74 72
> 3E 3C 74 72    ULL</td></tr><tr
> [2020/03/06 14:35:02:3269] N: 01A0: 3E 3C 74 64 3E 3C 62 3E 75 70 6C 6F
> 61 64 3C 2F    ><td><b>upload</
> [2020/03/06 14:35:02:3269] N: 01B0: 62 3E 3C 2F 74 64 3E 3C 74 64 3E 30
> 3C 2F 74 64    b></td><td>0</td
> [2020/03/06 14:35:02:3269] N: 01C0: 3E 3C 74 64 3E 4E 55 4C 4C 3C 2F 74
> 64 3E 3C 2F    ><td>NULL</td></
> [2020/03/06 14:35:02:3269] N: 01D0: 74 72 3E 3C 2F 74 61 62 6C 65 3E 3C
> 62 72 3E 3C    tr></table><br><
> [2020/03/06 14:35:02:3270] N: 01E0: 62 3E 66 69 6C 65 6E 61 6D 65 3A 3C
> 2F 62 3E 20    b>filename:</b>
> [2020/03/06 14:35:02:3270] N: 01F0: 6D 79 66 69 6C 65 2E 74 78 74 2C 20
> 3C 62 3E 6C    myfile.txt, <b>l
> [2020/03/06 14:35:02:3270] N: 0200: 65 6E 67 74 68 3C 2F 62 3E 20 34 36
> 3C 2F 62 6F    ength</b> 46</bo
> [2020/03/06 14:35:02:3270] N: 0210: 64 79 3E 3C 2F 68 74 6D 6C 3E
>                dy></html>
> [2020/03/06 14:35:02:3270] N:
> [2020/03/06 14:35:02:3270] U: LWS_CALLBACK_COMPLETED_CLIENT_HTTP
> [2020/03/06 14:35:02:3293] U: Completed: OK
> $
>
> The related parser bit is
>
> [2020/03/06 14:35:54:3029] P: WSI_TOKEN_NAME_PART 'H' 0x48
> (role=0x10000000) wsi->lextable_pos=0
> [2020/03/06 14:35:54:3029] P: WSI_TOKEN_NAME_PART 'T' 0x54
> (role=0x10000000) wsi->lextable_pos=87
> [2020/03/06 14:35:54:3029] P: WSI_TOKEN_NAME_PART 'T' 0x54
> (role=0x10000000) wsi->lextable_pos=173
> [2020/03/06 14:35:54:3029] P: WSI_TOKEN_NAME_PART 'P' 0x50
> (role=0x10000000) wsi->lextable_pos=174
> [2020/03/06 14:35:54:3029] P: WSI_TOKEN_NAME_PART '/' 0x2F
> (role=0x10000000) wsi->lextable_pos=175
> [2020/03/06 14:35:54:3029] P: WSI_TOKEN_NAME_PART '1' 0x31
> (role=0x10000000) wsi->lextable_pos=992
> [2020/03/06 14:35:54:3030] P: WSI_TOKEN_NAME_PART '.' 0x2E
> (role=0x10000000) wsi->lextable_pos=993
> [2020/03/06 14:35:54:3030] P: WSI_TOKEN_NAME_PART '1' 0x31
> (role=0x10000000) wsi->lextable_pos=994
> [2020/03/06 14:35:54:3030] P: WSI_TOKEN_NAME_PART ' ' 0x20
> (role=0x10000000) wsi->lextable_pos=1094
> [2020/03/06 14:35:54:3030] P: known hdr 14
>
> I could reproduce your problem after -DLWS_ROLE_WS=0... you should be
> able to work around it by setting -DLWS_ROLE_WS=1 at cmake while I look
> further into it.

Can confirm that with LWS_ROLE_WS enabled, it works fine.

Thanks!


More information about the Libwebsockets mailing list