Test WS frames that are larger than 64k

This commit is contained in:
cpq 2022-08-13 11:16:13 +01:00
parent ef6fbad0cb
commit 6615a821f1
6 changed files with 301 additions and 263 deletions

View File

@ -48,6 +48,232 @@ static const unsigned char v1[] = {
47, 104, 116, 109, 108, 62, 10, 0 // /html>.
};
static const unsigned char v2[] = {
39, 117, 115, 101, 32, 115, 116, 114, 105, 99, 116, 39, // 'use strict'
59, 10, 105, 109, 112, 111, 114, 116, 32, 123, 32, 104, // ;.import { h
44, 32, 104, 116, 109, 108, 44, 32, 114, 101, 110, 100, // , html, rend
101, 114, 32, 125, 32, 102, 114, 111, 109, 32, 39, 46, // er } from '.
47, 112, 114, 101, 97, 99, 116, 46, 109, 105, 110, 46, // /preact.min.
106, 115, 39, 59, 10, 10, 10, 99, 111, 110, 115, 116, // js';...const
32, 88, 32, 61, 32, 102, 117, 110, 99, 116, 105, 111, // X = functio
110, 32, 40, 41, 32, 123, 10, 10, 32, 32, 114, 101, // n () {.. re
116, 117, 114, 110, 32, 104, 116, 109, 108, 96, 10, 32, // turn html`.
32, 60, 100, 105, 118, 32, 99, 108, 97, 115, 115, 61, // <div class=
34, 99, 111, 110, 116, 97, 105, 110, 101, 114, 34, 62, // "container">
10, 32, 32, 32, 32, 60, 104, 50, 32, 99, 108, 97, // . <h2 cla
115, 115, 61, 34, 115, 101, 99, 116, 105, 111, 110, 34, // ss="section"
62, 65, 66, 79, 85, 84, 32, 85, 83, 60, 47, 104, // >ABOUT US</h
50, 62, 10, 32, 32, 32, 32, 60, 100, 105, 118, 32, // 2>. <div
99, 108, 97, 115, 115, 61, 34, 114, 111, 119, 34, 62, // class="row">
10, 32, 32, 32, 32, 32, 32, 60, 100, 105, 118, 32, // . <div
99, 108, 97, 115, 115, 61, 34, 99, 111, 108, 45, 55, // class="col-7
34, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, // ">. <
112, 62, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, // p> .
32, 32, 32, 32, 32, 32, 32, 67, 101, 115, 97, 110, // Cesan
116, 97, 32, 83, 111, 102, 116, 119, 97, 114, 101, 32, // ta Software
76, 116, 100, 46, 32, 105, 115, 32, 104, 101, 97, 100, // Ltd. is head
113, 117, 97, 114, 116, 101, 114, 101, 100, 194, 160, 105, // quartered..i
110, 32, 68, 117, 98, 108, 105, 110, 44, 32, 82, 101, // n Dublin, Re
112, 117, 98, 108, 105, 99, 32, 111, 102, 32, 73, 114, // public of Ir
101, 108, 97, 110, 100, 46, 10, 32, 32, 32, 32, 32, // eland..
32, 32, 32, 60, 47, 112, 62, 10, 32, 32, 32, 32, // </p>.
32, 32, 32, 32, 60, 112, 62, 60, 47, 112, 62, 10, // <p></p>.
32, 32, 32, 32, 32, 32, 32, 32, 79, 117, 114, 32, // Our
115, 116, 111, 114, 121, 32, 114, 111, 111, 116, 115, 32, // story roots
98, 97, 99, 107, 32, 116, 111, 32, 50, 48, 48, 52, // back to 2004
44, 32, 119, 104, 101, 110, 32, 77, 111, 110, 103, 111, // , when Mongo
111, 115, 101, 32, 87, 101, 98, 32, 83, 101, 114, 118, // ose Web Serv
101, 114, 32, 76, 105, 98, 114, 97, 114, 121, 194, 160, // er Library..
100, 101, 118, 101, 108, 111, 112, 109, 101, 110, 116, 32, // development
115, 116, 97, 114, 116, 101, 100, 46, 32, 60, 98, 114, // started. <br
62, 10, 10, 32, 32, 32, 32, 32, 32, 32, 32, 65, // >.. A
115, 32, 77, 111, 110, 103, 111, 111, 115, 101, 32, 87, // s Mongoose W
101, 98, 32, 83, 101, 114, 118, 101, 114, 32, 103, 114, // eb Server gr
101, 119, 32, 105, 110, 32, 112, 111, 112, 117, 108, 97, // ew in popula
114, 105, 116, 121, 32, 97, 110, 100, 32, 109, 97, 116, // rity and mat
117, 114, 101, 100, 32, 111, 118, 101, 114, 32, 116, 104, // ured over th
101, 32, 102, 111, 108, 108, 111, 119, 105, 110, 103, 32, // e following
121, 101, 97, 114, 115, 44, 32, 105, 110, 32, 50, 48, // years, in 20
49, 51, 32, 67, 101, 115, 97, 110, 116, 97, 32, 119, // 13 Cesanta w
97, 115, 32, 101, 115, 116, 97, 98, 108, 105, 115, 104, // as establish
101, 100, 32, 116, 111, 32, 99, 111, 110, 116, 105, 110, // ed to contin
117, 101, 32, 105, 116, 115, 32, 100, 101, 118, 101, 108, // ue its devel
111, 112, 109, 101, 110, 116, 32, 97, 110, 100, 32, 10, // opment and .
32, 32, 32, 32, 32, 32, 32, 32, 112, 114, 111, 118, // prov
105, 100, 101, 32, 115, 117, 112, 112, 111, 114, 116, 32, // ide support
116, 111, 32, 111, 117, 114, 32, 118, 97, 108, 117, 101, // to our value
100, 32, 99, 117, 115, 116, 111, 109, 101, 114, 115, 46, // d customers.
10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 47, 112, // . </p
62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 112, // >. <p
62, 87, 101, 32, 97, 114, 101, 32, 112, 114, 111, 117, // >We are prou
100, 32, 116, 111, 32, 104, 97, 118, 101, 32, 97, 109, // d to have am
111, 110, 103, 32, 111, 117, 114, 32, 99, 117, 115, 116, // ong our cust
111, 109, 101, 114, 115, 32, 109, 97, 110, 121, 32, 60, // omers many <
105, 62, 70, 111, 114, 116, 117, 110, 101, 32, 53, 48, // i>Fortune 50
48, 60, 47, 105, 62, 32, 99, 111, 109, 112, 97, 110, // 0</i> compan
105, 101, 115, 32, 97, 115, 32, 119, 101, 108, 108, 32, // ies as well
97, 115, 32, 109, 101, 100, 105, 117, 109, 32, 97, 110, // as medium an
100, 32, 115, 109, 97, 108, 108, 32, 115, 105, 122, 101, // d small size
32, 98, 117, 115, 105, 110, 101, 115, 115, 101, 115, 46, // businesses.
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 83, // . S
101, 99, 117, 114, 105, 116, 121, 32, 97, 110, 100, 32, // ecurity and
113, 117, 97, 108, 105, 116, 121, 32, 111, 102, 32, 111, // quality of o
117, 114, 32, 115, 111, 108, 117, 116, 105, 111, 110, 115, // ur solutions
32, 105, 115, 32, 97, 32, 112, 97, 114, 97, 109, 111, // is a paramo
117, 110, 116, 32, 102, 111, 114, 32, 117, 115, 32, 97, // unt for us a
110, 100, 32, 116, 104, 101, 32, 102, 97, 99, 116, 32, // nd the fact
116, 104, 97, 116, 32, 77, 111, 110, 103, 111, 111, 115, // that Mongoos
101, 32, 87, 101, 98, 32, 83, 101, 114, 118, 101, 114, // e Web Server
32, 105, 115, 32, 117, 115, 101, 100, 32, 98, 121, 32, // is used by
78, 65, 83, 65, 32, 97, 98, 111, 97, 114, 100, 32, // NASA aboard
116, 104, 101, 32, 73, 110, 116, 101, 114, 110, 97, 116, // the Internat
105, 111, 110, 97, 108, 32, 83, 112, 97, 99, 101, 32, // ional Space
83, 116, 97, 116, 105, 111, 110, 32, 105, 115, 32, 10, // Station is .
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 116, 104, // th
101, 32, 98, 101, 115, 116, 32, 99, 111, 110, 102, 105, // e best confi
114, 109, 97, 116, 105, 111, 110, 32, 116, 111, 32, 105, // rmation to i
116, 46, 60, 47, 112, 62, 10, 32, 32, 32, 32, 32, // t.</p>.
32, 32, 32, 32, 32, 60, 112, 62, 83, 105, 110, 99, // <p>Sinc
101, 32, 50, 48, 49, 51, 44, 32, 67, 101, 115, 97, // e 2013, Cesa
110, 116, 97, 32, 104, 97, 115, 32, 101, 120, 112, 97, // nta has expa
110, 100, 101, 100, 32, 105, 116, 115, 32, 112, 114, 111, // nded its pro
100, 117, 99, 116, 32, 112, 111, 114, 116, 102, 111, 108, // duct portfol
105, 111, 46, 32, 87, 101, 32, 100, 101, 118, 101, 108, // io. We devel
111, 112, 32, 97, 110, 100, 32, 100, 105, 115, 116, 114, // op and distr
105, 98, 117, 116, 101, 32, 101, 109, 98, 101, 100, 100, // ibute embedd
101, 100, 32, 115, 111, 102, 116, 119, 97, 114, 101, 32, // ed software
97, 110, 100, 32, 104, 97, 114, 100, 119, 97, 114, 101, // and hardware
32, 119, 105, 116, 104, 32, 102, 111, 99, 117, 115, 32, // with focus
111, 110, 32, 99, 111, 110, 110, 101, 99, 116, 101, 100, // on connected
32, 112, 114, 111, 100, 117, 99, 116, 115, 32, 97, 110, // products an
100, 32, 116, 104, 101, 32, 73, 110, 116, 101, 114, 110, // d the Intern
101, 116, 32, 111, 102, 32, 84, 104, 105, 110, 103, 115, // et of Things
46, 60, 47, 112, 62, 10, 10, 32, 32, 32, 32, 32, // .</p>..
32, 60, 47, 100, 105, 118, 62, 10, 32, 32, 32, 32, // </div>.
60, 47, 100, 105, 118, 62, 10, 32, 32, 60, 47, 100, // </div>. </d
105, 118, 62, 10, 96, 59, 10, 125, 59, 10, 10, 99, // iv>.`;.};..c
111, 110, 115, 116, 32, 89, 32, 61, 32, 102, 117, 110, // onst Y = fun
99, 116, 105, 111, 110, 32, 40, 41, 32, 123, 10, 10, // ction () {..
32, 32, 114, 101, 116, 117, 114, 110, 32, 104, 116, 109, // return htm
108, 96, 10, 32, 32, 60, 100, 105, 118, 32, 99, 108, // l`. <div cl
97, 115, 115, 61, 34, 99, 111, 110, 116, 97, 105, 110, // ass="contain
101, 114, 34, 62, 10, 32, 32, 32, 32, 60, 104, 51, // er">. <h3
32, 99, 108, 97, 115, 115, 61, 34, 115, 101, 99, 116, // class="sect
105, 111, 110, 34, 62, 65, 109, 111, 110, 103, 32, 111, // ion">Among o
117, 114, 32, 112, 114, 111, 100, 117, 99, 116, 115, 32, // ur products
97, 114, 101, 58, 60, 47, 104, 51, 62, 10, 32, 32, // are:</h3>.
32, 32, 60, 100, 105, 118, 32, 99, 108, 97, 115, 115, // <div class
61, 34, 114, 111, 119, 34, 62, 10, 32, 32, 32, 32, // ="row">.
32, 32, 60, 100, 105, 118, 32, 99, 108, 97, 115, 115, // <div class
61, 34, 99, 111, 108, 45, 55, 34, 62, 10, 32, 32, // ="col-7">.
32, 32, 32, 32, 32, 60, 117, 108, 62, 10, 32, 32, // <ul>.
32, 32, 32, 32, 32, 32, 32, 60, 108, 105, 62, 10, // <li>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, // <
97, 32, 104, 114, 101, 102, 61, 34, 104, 116, 116, 112, // a href="http
115, 58, 47, 47, 109, 111, 110, 103, 111, 111, 115, 101, // s://mongoose
46, 119, 115, 47, 34, 62, 77, 111, 110, 103, 111, 111, // .ws/">Mongoo
115, 101, 32, 87, 101, 98, 32, 83, 101, 114, 118, 101, // se Web Serve
114, 60, 47, 97, 62, 10, 32, 32, 32, 32, 32, 32, // r</a>.
32, 32, 32, 32, 32, 45, 32, 97, 110, 32, 101, 109, // - an em
98, 101, 100, 100, 101, 100, 32, 119, 101, 98, 32, 115, // bedded web s
101, 114, 118, 101, 114, 32, 97, 110, 100, 32, 110, 101, // erver and ne
116, 119, 111, 114, 107, 105, 110, 103, 32, 108, 105, 98, // tworking lib
114, 97, 114, 121, 10, 32, 32, 32, 32, 32, 32, 32, // rary.
32, 32, 60, 47, 108, 105, 62, 10, 32, 32, 32, 32, // </li>.
32, 32, 32, 32, 32, 60, 108, 105, 62, 10, 32, 32, // <li>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 97, 32, // <a
104, 114, 101, 102, 61, 34, 104, 116, 116, 112, 115, 58, // href="https:
47, 47, 118, 99, 111, 110, 46, 105, 111, 47, 34, 62, // //vcon.io/">
86, 67, 79, 78, 46, 105, 111, 60, 47, 97, 62, 10, // VCON.io</a>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 45, // -
32, 65, 114, 100, 117, 105, 110, 111, 45, 99, 111, 109, // Arduino-com
112, 97, 116, 105, 98, 108, 101, 32, 98, 111, 97, 114, // patible boar
100, 115, 32, 119, 105, 116, 104, 32, 98, 117, 105, 108, // ds with buil
116, 45, 105, 110, 32, 102, 105, 114, 109, 119, 97, 114, // t-in firmwar
101, 32, 79, 84, 65, 32, 117, 112, 100, 97, 116, 101, // e OTA update
115, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // s.
32, 97, 110, 100, 32, 109, 97, 110, 97, 103, 101, 109, // and managem
101, 110, 116, 32, 100, 97, 115, 104, 98, 111, 97, 114, // ent dashboar
100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, // d. <
47, 108, 105, 62, 10, 32, 32, 32, 32, 32, 32, 32, // /li>.
32, 32, 60, 108, 105, 62, 10, 32, 32, 32, 32, 32, // <li>.
32, 32, 32, 32, 32, 32, 60, 97, 32, 104, 114, 101, // <a hre
102, 61, 34, 104, 116, 116, 112, 115, 58, 47, 47, 109, // f="https://m
100, 97, 115, 104, 46, 110, 101, 116, 47, 34, 62, 109, // dash.net/">m
68, 97, 115, 104, 46, 110, 101, 116, 60, 47, 97, 62, // Dash.net</a>
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // .
45, 32, 97, 110, 32, 97, 108, 108, 45, 105, 110, 45, // - an all-in-
111, 110, 101, 32, 73, 111, 84, 32, 80, 108, 97, 116, // one IoT Plat
102, 111, 114, 109, 10, 32, 32, 32, 32, 32, 32, 32, // form.
32, 32, 60, 47, 108, 105, 62, 10, 32, 32, 32, 32, // </li>.
32, 32, 32, 32, 32, 60, 108, 105, 62, 10, 32, 32, // <li>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 97, 32, // <a
104, 114, 101, 102, 61, 34, 104, 116, 116, 112, 115, 58, // href="https:
47, 47, 109, 111, 110, 103, 111, 111, 115, 101, 45, 111, // //mongoose-o
115, 46, 99, 111, 109, 34, 62, 77, 111, 110, 103, 111, // s.com">Mongo
111, 115, 101, 32, 79, 83, 60, 47, 97, 62, 10, 32, // ose OS</a>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 45, 32, // -
97, 110, 32, 111, 112, 101, 114, 97, 116, 105, 110, 103, // an operating
32, 115, 121, 115, 116, 101, 109, 32, 102, 111, 114, 32, // system for
108, 111, 119, 45, 112, 111, 119, 101, 114, 32, 109, 105, // low-power mi
99, 114, 111, 99, 111, 110, 116, 114, 111, 108, 108, 101, // crocontrolle
114, 115, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, // rs.
60, 47, 108, 105, 62, 10, 10, 32, 32, 32, 32, 32, // </li>..
32, 32, 32, 32, 60, 108, 105, 62, 10, 32, 32, 32, // <li>.
32, 32, 32, 32, 32, 32, 32, 32, 60, 97, 32, 104, // <a h
114, 101, 102, 61, 34, 104, 116, 116, 112, 115, 58, 47, // ref="https:/
47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, // /github.com/
99, 101, 115, 97, 110, 116, 97, 47, 109, 106, 115, 34, // cesanta/mjs"
62, 109, 74, 83, 60, 47, 97, 62, 10, 32, 32, 32, // >mJS</a>.
32, 32, 32, 32, 32, 32, 32, 32, 45, 32, 97, 110, // - an
32, 101, 109, 98, 101, 100, 100, 101, 100, 32, 74, 97, // embedded Ja
118, 97, 83, 99, 114, 105, 112, 116, 32, 101, 110, 103, // vaScript eng
105, 110, 101, 32, 102, 111, 114, 32, 67, 47, 67, 43, // ine for C/C+
43, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, // +. <
47, 108, 105, 62, 10, 32, 32, 32, 32, 32, 32, 32, // /li>.
60, 47, 117, 108, 62, 10, 32, 32, 32, 32, 32, 32, // </ul>.
60, 47, 100, 105, 118, 62, 10, 32, 32, 32, 32, 32, // </div>.
32, 60, 100, 105, 118, 32, 99, 108, 97, 115, 115, 61, // <div class=
34, 99, 111, 108, 45, 54, 34, 62, 10, 32, 32, 32, // "col-6">.
32, 32, 32, 32, 32, 60, 112, 62, 60, 98, 62, 79, // <p><b>O
117, 114, 32, 115, 111, 108, 117, 116, 105, 111, 110, 115, // ur solutions
32, 97, 114, 101, 58, 60, 47, 98, 62, 60, 47, 112, // are:</b></p
62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 117, // >. <u
108, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, // l>.
32, 60, 108, 105, 62, 105, 110, 116, 101, 103, 114, 97, // <li>integra
116, 101, 100, 32, 105, 110, 116, 111, 32, 116, 104, 111, // ted into tho
117, 115, 97, 110, 100, 115, 32, 111, 102, 32, 99, 111, // usands of co
109, 109, 101, 114, 99, 105, 97, 108, 32, 112, 114, 111, // mmercial pro
100, 117, 99, 116, 115, 60, 47, 108, 105, 62, 10, 32, // ducts</li>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 108, 105, // <li
62, 100, 101, 112, 108, 111, 121, 101, 100, 32, 116, 111, // >deployed to
32, 104, 117, 110, 100, 114, 101, 100, 115, 32, 111, 102, // hundreds of
32, 109, 105, 108, 108, 105, 111, 110, 115, 32, 100, 101, // millions de
118, 105, 99, 101, 115, 32, 105, 110, 32, 112, 114, 111, // vices in pro
100, 117, 99, 116, 105, 111, 110, 32, 101, 110, 118, 105, // duction envi
114, 111, 110, 109, 101, 110, 116, 115, 60, 47, 108, 105, // ronments</li
62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 47, // >. </
117, 108, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, // ul>. </
100, 105, 118, 62, 10, 32, 32, 32, 32, 60, 47, 100, // div>. </d
105, 118, 62, 10, 32, 32, 60, 47, 100, 105, 118, 62, // iv>. </div>
10, 96, 59, 10, 125, 59, 10, 10, 99, 111, 110, 115, // .`;.};..cons
116, 32, 65, 112, 112, 32, 61, 32, 102, 117, 110, 99, // t App = func
116, 105, 111, 110, 32, 40, 112, 114, 111, 112, 115, 41, // tion (props)
32, 123, 10, 10, 32, 32, 114, 101, 116, 117, 114, 110, // {.. return
32, 104, 116, 109, 108, 96, 10, 60, 104, 49, 62, 66, // html`.<h1>B
97, 115, 105, 99, 32, 69, 109, 98, 101, 100, 100, 101, // asic Embedde
100, 32, 70, 105, 108, 101, 115, 121, 115, 116, 101, 109, // d Filesystem
32, 100, 101, 109, 111, 60, 47, 104, 49, 62, 10, 60, // demo</h1>.<
100, 105, 118, 62, 10, 32, 32, 36, 123, 104, 40, 88, // div>. ${h(X
41, 125, 10, 60, 47, 100, 105, 118, 62, 10, 60, 100, // )}.</div>.<d
105, 118, 62, 10, 32, 32, 36, 123, 104, 40, 89, 41, // iv>. ${h(Y)
125, 10, 60, 47, 100, 105, 118, 62, 96, 59, 10, 125, // }.</div>`;.}
59, 10, 10, 119, 105, 110, 100, 111, 119, 46, 111, 110, // ;..window.on
108, 111, 97, 100, 32, 61, 32, 40, 41, 32, 61, 62, // load = () =>
32, 114, 101, 110, 100, 101, 114, 40, 104, 40, 65, 112, // render(h(Ap
112, 41, 44, 32, 100, 111, 99, 117, 109, 101, 110, 116, // p), document
46, 98, 111, 100, 121, 41, 59, 10, 0 // .body);.
};
static const unsigned char v3[] = {
118, 97, 114, 32, 101, 44, 110, 44, 95, 44, 116, 44, // var e,n,_,t,
111, 44, 114, 44, 117, 44, 108, 61, 123, 125, 44, 105, // o,r,u,l={},i
61, 91, 93, 44, 99, 61, 47, 97, 99, 105, 116, 124, // =[],c=/acit|
@ -1149,7 +1375,7 @@ static const unsigned char v2[] = {
115, 101, 69, 114, 114, 111, 114, 66, 111, 117, 110, 100, // seErrorBound
97, 114, 121, 125, 59, 10, 0 // ary};.
};
static const unsigned char v3[] = {
static const unsigned char v4[] = {
42, 32, 123, 32, 98, 111, 120, 45, 115, 105, 122, 105, // * { box-sizi
110, 103, 58, 32, 98, 111, 114, 100, 101, 114, 45, 98, // ng: border-b
111, 120, 59, 32, 125, 10, 104, 116, 109, 108, 44, 32, // ox; }.html,
@ -1304,232 +1530,6 @@ static const unsigned char v3[] = {
123, 32, 119, 105, 100, 116, 104, 58, 32, 49, 48, 48, // { width: 100
37, 59, 32, 125, 32, 125, 10, 0 // %; } }.
};
static const unsigned char v4[] = {
39, 117, 115, 101, 32, 115, 116, 114, 105, 99, 116, 39, // 'use strict'
59, 10, 105, 109, 112, 111, 114, 116, 32, 123, 32, 104, // ;.import { h
44, 32, 104, 116, 109, 108, 44, 32, 114, 101, 110, 100, // , html, rend
101, 114, 32, 125, 32, 102, 114, 111, 109, 32, 39, 46, // er } from '.
47, 112, 114, 101, 97, 99, 116, 46, 109, 105, 110, 46, // /preact.min.
106, 115, 39, 59, 10, 10, 10, 99, 111, 110, 115, 116, // js';...const
32, 88, 32, 61, 32, 102, 117, 110, 99, 116, 105, 111, // X = functio
110, 32, 40, 41, 32, 123, 10, 10, 32, 32, 114, 101, // n () {.. re
116, 117, 114, 110, 32, 104, 116, 109, 108, 96, 10, 32, // turn html`.
32, 60, 100, 105, 118, 32, 99, 108, 97, 115, 115, 61, // <div class=
34, 99, 111, 110, 116, 97, 105, 110, 101, 114, 34, 62, // "container">
10, 32, 32, 32, 32, 60, 104, 50, 32, 99, 108, 97, // . <h2 cla
115, 115, 61, 34, 115, 101, 99, 116, 105, 111, 110, 34, // ss="section"
62, 65, 66, 79, 85, 84, 32, 85, 83, 60, 47, 104, // >ABOUT US</h
50, 62, 10, 32, 32, 32, 32, 60, 100, 105, 118, 32, // 2>. <div
99, 108, 97, 115, 115, 61, 34, 114, 111, 119, 34, 62, // class="row">
10, 32, 32, 32, 32, 32, 32, 60, 100, 105, 118, 32, // . <div
99, 108, 97, 115, 115, 61, 34, 99, 111, 108, 45, 55, // class="col-7
34, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, // ">. <
112, 62, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, // p> .
32, 32, 32, 32, 32, 32, 32, 67, 101, 115, 97, 110, // Cesan
116, 97, 32, 83, 111, 102, 116, 119, 97, 114, 101, 32, // ta Software
76, 116, 100, 46, 32, 105, 115, 32, 104, 101, 97, 100, // Ltd. is head
113, 117, 97, 114, 116, 101, 114, 101, 100, 194, 160, 105, // quartered..i
110, 32, 68, 117, 98, 108, 105, 110, 44, 32, 82, 101, // n Dublin, Re
112, 117, 98, 108, 105, 99, 32, 111, 102, 32, 73, 114, // public of Ir
101, 108, 97, 110, 100, 46, 10, 32, 32, 32, 32, 32, // eland..
32, 32, 32, 60, 47, 112, 62, 10, 32, 32, 32, 32, // </p>.
32, 32, 32, 32, 60, 112, 62, 60, 47, 112, 62, 10, // <p></p>.
32, 32, 32, 32, 32, 32, 32, 32, 79, 117, 114, 32, // Our
115, 116, 111, 114, 121, 32, 114, 111, 111, 116, 115, 32, // story roots
98, 97, 99, 107, 32, 116, 111, 32, 50, 48, 48, 52, // back to 2004
44, 32, 119, 104, 101, 110, 32, 77, 111, 110, 103, 111, // , when Mongo
111, 115, 101, 32, 87, 101, 98, 32, 83, 101, 114, 118, // ose Web Serv
101, 114, 32, 76, 105, 98, 114, 97, 114, 121, 194, 160, // er Library..
100, 101, 118, 101, 108, 111, 112, 109, 101, 110, 116, 32, // development
115, 116, 97, 114, 116, 101, 100, 46, 32, 60, 98, 114, // started. <br
62, 10, 10, 32, 32, 32, 32, 32, 32, 32, 32, 65, // >.. A
115, 32, 77, 111, 110, 103, 111, 111, 115, 101, 32, 87, // s Mongoose W
101, 98, 32, 83, 101, 114, 118, 101, 114, 32, 103, 114, // eb Server gr
101, 119, 32, 105, 110, 32, 112, 111, 112, 117, 108, 97, // ew in popula
114, 105, 116, 121, 32, 97, 110, 100, 32, 109, 97, 116, // rity and mat
117, 114, 101, 100, 32, 111, 118, 101, 114, 32, 116, 104, // ured over th
101, 32, 102, 111, 108, 108, 111, 119, 105, 110, 103, 32, // e following
121, 101, 97, 114, 115, 44, 32, 105, 110, 32, 50, 48, // years, in 20
49, 51, 32, 67, 101, 115, 97, 110, 116, 97, 32, 119, // 13 Cesanta w
97, 115, 32, 101, 115, 116, 97, 98, 108, 105, 115, 104, // as establish
101, 100, 32, 116, 111, 32, 99, 111, 110, 116, 105, 110, // ed to contin
117, 101, 32, 105, 116, 115, 32, 100, 101, 118, 101, 108, // ue its devel
111, 112, 109, 101, 110, 116, 32, 97, 110, 100, 32, 10, // opment and .
32, 32, 32, 32, 32, 32, 32, 32, 112, 114, 111, 118, // prov
105, 100, 101, 32, 115, 117, 112, 112, 111, 114, 116, 32, // ide support
116, 111, 32, 111, 117, 114, 32, 118, 97, 108, 117, 101, // to our value
100, 32, 99, 117, 115, 116, 111, 109, 101, 114, 115, 46, // d customers.
10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 47, 112, // . </p
62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 112, // >. <p
62, 87, 101, 32, 97, 114, 101, 32, 112, 114, 111, 117, // >We are prou
100, 32, 116, 111, 32, 104, 97, 118, 101, 32, 97, 109, // d to have am
111, 110, 103, 32, 111, 117, 114, 32, 99, 117, 115, 116, // ong our cust
111, 109, 101, 114, 115, 32, 109, 97, 110, 121, 32, 60, // omers many <
105, 62, 70, 111, 114, 116, 117, 110, 101, 32, 53, 48, // i>Fortune 50
48, 60, 47, 105, 62, 32, 99, 111, 109, 112, 97, 110, // 0</i> compan
105, 101, 115, 32, 97, 115, 32, 119, 101, 108, 108, 32, // ies as well
97, 115, 32, 109, 101, 100, 105, 117, 109, 32, 97, 110, // as medium an
100, 32, 115, 109, 97, 108, 108, 32, 115, 105, 122, 101, // d small size
32, 98, 117, 115, 105, 110, 101, 115, 115, 101, 115, 46, // businesses.
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 83, // . S
101, 99, 117, 114, 105, 116, 121, 32, 97, 110, 100, 32, // ecurity and
113, 117, 97, 108, 105, 116, 121, 32, 111, 102, 32, 111, // quality of o
117, 114, 32, 115, 111, 108, 117, 116, 105, 111, 110, 115, // ur solutions
32, 105, 115, 32, 97, 32, 112, 97, 114, 97, 109, 111, // is a paramo
117, 110, 116, 32, 102, 111, 114, 32, 117, 115, 32, 97, // unt for us a
110, 100, 32, 116, 104, 101, 32, 102, 97, 99, 116, 32, // nd the fact
116, 104, 97, 116, 32, 77, 111, 110, 103, 111, 111, 115, // that Mongoos
101, 32, 87, 101, 98, 32, 83, 101, 114, 118, 101, 114, // e Web Server
32, 105, 115, 32, 117, 115, 101, 100, 32, 98, 121, 32, // is used by
78, 65, 83, 65, 32, 97, 98, 111, 97, 114, 100, 32, // NASA aboard
116, 104, 101, 32, 73, 110, 116, 101, 114, 110, 97, 116, // the Internat
105, 111, 110, 97, 108, 32, 83, 112, 97, 99, 101, 32, // ional Space
83, 116, 97, 116, 105, 111, 110, 32, 105, 115, 32, 10, // Station is .
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 116, 104, // th
101, 32, 98, 101, 115, 116, 32, 99, 111, 110, 102, 105, // e best confi
114, 109, 97, 116, 105, 111, 110, 32, 116, 111, 32, 105, // rmation to i
116, 46, 60, 47, 112, 62, 10, 32, 32, 32, 32, 32, // t.</p>.
32, 32, 32, 32, 32, 60, 112, 62, 83, 105, 110, 99, // <p>Sinc
101, 32, 50, 48, 49, 51, 44, 32, 67, 101, 115, 97, // e 2013, Cesa
110, 116, 97, 32, 104, 97, 115, 32, 101, 120, 112, 97, // nta has expa
110, 100, 101, 100, 32, 105, 116, 115, 32, 112, 114, 111, // nded its pro
100, 117, 99, 116, 32, 112, 111, 114, 116, 102, 111, 108, // duct portfol
105, 111, 46, 32, 87, 101, 32, 100, 101, 118, 101, 108, // io. We devel
111, 112, 32, 97, 110, 100, 32, 100, 105, 115, 116, 114, // op and distr
105, 98, 117, 116, 101, 32, 101, 109, 98, 101, 100, 100, // ibute embedd
101, 100, 32, 115, 111, 102, 116, 119, 97, 114, 101, 32, // ed software
97, 110, 100, 32, 104, 97, 114, 100, 119, 97, 114, 101, // and hardware
32, 119, 105, 116, 104, 32, 102, 111, 99, 117, 115, 32, // with focus
111, 110, 32, 99, 111, 110, 110, 101, 99, 116, 101, 100, // on connected
32, 112, 114, 111, 100, 117, 99, 116, 115, 32, 97, 110, // products an
100, 32, 116, 104, 101, 32, 73, 110, 116, 101, 114, 110, // d the Intern
101, 116, 32, 111, 102, 32, 84, 104, 105, 110, 103, 115, // et of Things
46, 60, 47, 112, 62, 10, 10, 32, 32, 32, 32, 32, // .</p>..
32, 60, 47, 100, 105, 118, 62, 10, 32, 32, 32, 32, // </div>.
60, 47, 100, 105, 118, 62, 10, 32, 32, 60, 47, 100, // </div>. </d
105, 118, 62, 10, 96, 59, 10, 125, 59, 10, 10, 99, // iv>.`;.};..c
111, 110, 115, 116, 32, 89, 32, 61, 32, 102, 117, 110, // onst Y = fun
99, 116, 105, 111, 110, 32, 40, 41, 32, 123, 10, 10, // ction () {..
32, 32, 114, 101, 116, 117, 114, 110, 32, 104, 116, 109, // return htm
108, 96, 10, 32, 32, 60, 100, 105, 118, 32, 99, 108, // l`. <div cl
97, 115, 115, 61, 34, 99, 111, 110, 116, 97, 105, 110, // ass="contain
101, 114, 34, 62, 10, 32, 32, 32, 32, 60, 104, 51, // er">. <h3
32, 99, 108, 97, 115, 115, 61, 34, 115, 101, 99, 116, // class="sect
105, 111, 110, 34, 62, 65, 109, 111, 110, 103, 32, 111, // ion">Among o
117, 114, 32, 112, 114, 111, 100, 117, 99, 116, 115, 32, // ur products
97, 114, 101, 58, 60, 47, 104, 51, 62, 10, 32, 32, // are:</h3>.
32, 32, 60, 100, 105, 118, 32, 99, 108, 97, 115, 115, // <div class
61, 34, 114, 111, 119, 34, 62, 10, 32, 32, 32, 32, // ="row">.
32, 32, 60, 100, 105, 118, 32, 99, 108, 97, 115, 115, // <div class
61, 34, 99, 111, 108, 45, 55, 34, 62, 10, 32, 32, // ="col-7">.
32, 32, 32, 32, 32, 60, 117, 108, 62, 10, 32, 32, // <ul>.
32, 32, 32, 32, 32, 32, 32, 60, 108, 105, 62, 10, // <li>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, // <
97, 32, 104, 114, 101, 102, 61, 34, 104, 116, 116, 112, // a href="http
115, 58, 47, 47, 109, 111, 110, 103, 111, 111, 115, 101, // s://mongoose
46, 119, 115, 47, 34, 62, 77, 111, 110, 103, 111, 111, // .ws/">Mongoo
115, 101, 32, 87, 101, 98, 32, 83, 101, 114, 118, 101, // se Web Serve
114, 60, 47, 97, 62, 10, 32, 32, 32, 32, 32, 32, // r</a>.
32, 32, 32, 32, 32, 45, 32, 97, 110, 32, 101, 109, // - an em
98, 101, 100, 100, 101, 100, 32, 119, 101, 98, 32, 115, // bedded web s
101, 114, 118, 101, 114, 32, 97, 110, 100, 32, 110, 101, // erver and ne
116, 119, 111, 114, 107, 105, 110, 103, 32, 108, 105, 98, // tworking lib
114, 97, 114, 121, 10, 32, 32, 32, 32, 32, 32, 32, // rary.
32, 32, 60, 47, 108, 105, 62, 10, 32, 32, 32, 32, // </li>.
32, 32, 32, 32, 32, 60, 108, 105, 62, 10, 32, 32, // <li>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 97, 32, // <a
104, 114, 101, 102, 61, 34, 104, 116, 116, 112, 115, 58, // href="https:
47, 47, 118, 99, 111, 110, 46, 105, 111, 47, 34, 62, // //vcon.io/">
86, 67, 79, 78, 46, 105, 111, 60, 47, 97, 62, 10, // VCON.io</a>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 45, // -
32, 65, 114, 100, 117, 105, 110, 111, 45, 99, 111, 109, // Arduino-com
112, 97, 116, 105, 98, 108, 101, 32, 98, 111, 97, 114, // patible boar
100, 115, 32, 119, 105, 116, 104, 32, 98, 117, 105, 108, // ds with buil
116, 45, 105, 110, 32, 102, 105, 114, 109, 119, 97, 114, // t-in firmwar
101, 32, 79, 84, 65, 32, 117, 112, 100, 97, 116, 101, // e OTA update
115, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // s.
32, 97, 110, 100, 32, 109, 97, 110, 97, 103, 101, 109, // and managem
101, 110, 116, 32, 100, 97, 115, 104, 98, 111, 97, 114, // ent dashboar
100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, // d. <
47, 108, 105, 62, 10, 32, 32, 32, 32, 32, 32, 32, // /li>.
32, 32, 60, 108, 105, 62, 10, 32, 32, 32, 32, 32, // <li>.
32, 32, 32, 32, 32, 32, 60, 97, 32, 104, 114, 101, // <a hre
102, 61, 34, 104, 116, 116, 112, 115, 58, 47, 47, 109, // f="https://m
100, 97, 115, 104, 46, 110, 101, 116, 47, 34, 62, 109, // dash.net/">m
68, 97, 115, 104, 46, 110, 101, 116, 60, 47, 97, 62, // Dash.net</a>
10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // .
45, 32, 97, 110, 32, 97, 108, 108, 45, 105, 110, 45, // - an all-in-
111, 110, 101, 32, 73, 111, 84, 32, 80, 108, 97, 116, // one IoT Plat
102, 111, 114, 109, 10, 32, 32, 32, 32, 32, 32, 32, // form.
32, 32, 60, 47, 108, 105, 62, 10, 32, 32, 32, 32, // </li>.
32, 32, 32, 32, 32, 60, 108, 105, 62, 10, 32, 32, // <li>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 97, 32, // <a
104, 114, 101, 102, 61, 34, 104, 116, 116, 112, 115, 58, // href="https:
47, 47, 109, 111, 110, 103, 111, 111, 115, 101, 45, 111, // //mongoose-o
115, 46, 99, 111, 109, 34, 62, 77, 111, 110, 103, 111, // s.com">Mongo
111, 115, 101, 32, 79, 83, 60, 47, 97, 62, 10, 32, // ose OS</a>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 45, 32, // -
97, 110, 32, 111, 112, 101, 114, 97, 116, 105, 110, 103, // an operating
32, 115, 121, 115, 116, 101, 109, 32, 102, 111, 114, 32, // system for
108, 111, 119, 45, 112, 111, 119, 101, 114, 32, 109, 105, // low-power mi
99, 114, 111, 99, 111, 110, 116, 114, 111, 108, 108, 101, // crocontrolle
114, 115, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, // rs.
60, 47, 108, 105, 62, 10, 10, 32, 32, 32, 32, 32, // </li>..
32, 32, 32, 32, 60, 108, 105, 62, 10, 32, 32, 32, // <li>.
32, 32, 32, 32, 32, 32, 32, 32, 60, 97, 32, 104, // <a h
114, 101, 102, 61, 34, 104, 116, 116, 112, 115, 58, 47, // ref="https:/
47, 103, 105, 116, 104, 117, 98, 46, 99, 111, 109, 47, // /github.com/
99, 101, 115, 97, 110, 116, 97, 47, 109, 106, 115, 34, // cesanta/mjs"
62, 109, 74, 83, 60, 47, 97, 62, 10, 32, 32, 32, // >mJS</a>.
32, 32, 32, 32, 32, 32, 32, 32, 45, 32, 97, 110, // - an
32, 101, 109, 98, 101, 100, 100, 101, 100, 32, 74, 97, // embedded Ja
118, 97, 83, 99, 114, 105, 112, 116, 32, 101, 110, 103, // vaScript eng
105, 110, 101, 32, 102, 111, 114, 32, 67, 47, 67, 43, // ine for C/C+
43, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 60, // +. <
47, 108, 105, 62, 10, 32, 32, 32, 32, 32, 32, 32, // /li>.
60, 47, 117, 108, 62, 10, 32, 32, 32, 32, 32, 32, // </ul>.
60, 47, 100, 105, 118, 62, 10, 32, 32, 32, 32, 32, // </div>.
32, 60, 100, 105, 118, 32, 99, 108, 97, 115, 115, 61, // <div class=
34, 99, 111, 108, 45, 54, 34, 62, 10, 32, 32, 32, // "col-6">.
32, 32, 32, 32, 32, 60, 112, 62, 60, 98, 62, 79, // <p><b>O
117, 114, 32, 115, 111, 108, 117, 116, 105, 111, 110, 115, // ur solutions
32, 97, 114, 101, 58, 60, 47, 98, 62, 60, 47, 112, // are:</b></p
62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 117, // >. <u
108, 62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, // l>.
32, 60, 108, 105, 62, 105, 110, 116, 101, 103, 114, 97, // <li>integra
116, 101, 100, 32, 105, 110, 116, 111, 32, 116, 104, 111, // ted into tho
117, 115, 97, 110, 100, 115, 32, 111, 102, 32, 99, 111, // usands of co
109, 109, 101, 114, 99, 105, 97, 108, 32, 112, 114, 111, // mmercial pro
100, 117, 99, 116, 115, 60, 47, 108, 105, 62, 10, 32, // ducts</li>.
32, 32, 32, 32, 32, 32, 32, 32, 32, 60, 108, 105, // <li
62, 100, 101, 112, 108, 111, 121, 101, 100, 32, 116, 111, // >deployed to
32, 104, 117, 110, 100, 114, 101, 100, 115, 32, 111, 102, // hundreds of
32, 109, 105, 108, 108, 105, 111, 110, 115, 32, 100, 101, // millions de
118, 105, 99, 101, 115, 32, 105, 110, 32, 112, 114, 111, // vices in pro
100, 117, 99, 116, 105, 111, 110, 32, 101, 110, 118, 105, // duction envi
114, 111, 110, 109, 101, 110, 116, 115, 60, 47, 108, 105, // ronments</li
62, 10, 32, 32, 32, 32, 32, 32, 32, 32, 60, 47, // >. </
117, 108, 62, 10, 32, 32, 32, 32, 32, 32, 60, 47, // ul>. </
100, 105, 118, 62, 10, 32, 32, 32, 32, 60, 47, 100, // div>. </d
105, 118, 62, 10, 32, 32, 60, 47, 100, 105, 118, 62, // iv>. </div>
10, 96, 59, 10, 125, 59, 10, 10, 99, 111, 110, 115, // .`;.};..cons
116, 32, 65, 112, 112, 32, 61, 32, 102, 117, 110, 99, // t App = func
116, 105, 111, 110, 32, 40, 112, 114, 111, 112, 115, 41, // tion (props)
32, 123, 10, 10, 32, 32, 114, 101, 116, 117, 114, 110, // {.. return
32, 104, 116, 109, 108, 96, 10, 60, 104, 49, 62, 66, // html`.<h1>B
97, 115, 105, 99, 32, 69, 109, 98, 101, 100, 100, 101, // asic Embedde
100, 32, 70, 105, 108, 101, 115, 121, 115, 116, 101, 109, // d Filesystem
32, 100, 101, 109, 111, 60, 47, 104, 49, 62, 10, 60, // demo</h1>.<
100, 105, 118, 62, 10, 32, 32, 36, 123, 104, 40, 88, // div>. ${h(X
41, 125, 10, 60, 47, 100, 105, 118, 62, 10, 60, 100, // )}.</div>.<d
105, 118, 62, 10, 32, 32, 36, 123, 104, 40, 89, 41, // iv>. ${h(Y)
125, 10, 60, 47, 100, 105, 118, 62, 96, 59, 10, 125, // }.</div>`;.}
59, 10, 10, 119, 105, 110, 100, 111, 119, 46, 111, 110, // ;..window.on
108, 111, 97, 100, 32, 61, 32, 40, 41, 32, 61, 62, // load = () =>
32, 114, 101, 110, 100, 101, 114, 40, 104, 40, 65, 112, // render(h(Ap
112, 41, 44, 32, 100, 111, 99, 117, 109, 101, 110, 116, // p), document
46, 98, 111, 100, 121, 41, 59, 10, 0 // .body);.
};
static const struct packed_file {
const char *name;
@ -1537,10 +1537,10 @@ static const struct packed_file {
size_t size;
time_t mtime;
} packed_files[] = {
{"/web_root/index.html", v1, sizeof(v1), 1660140294},
{"/web_root/preact.min.js", v2, sizeof(v2), 1660138387},
{"/web_root/style.css", v3, sizeof(v3), 1660138387},
{"/web_root/main.js", v4, sizeof(v4), 1660142672},
{"/web_root/index.html", v1, sizeof(v1), 1660216320},
{"/web_root/main.js", v2, sizeof(v2), 1660216320},
{"/web_root/preact.min.js", v3, sizeof(v3), 1660216320},
{"/web_root/style.css", v4, sizeof(v4), 1660216320},
{NULL, NULL, 0, 0}
};

View File

@ -2092,9 +2092,9 @@ static int uri_to_path2(struct mg_connection *c, struct mg_http_message *hm,
(tmp = fs->st(path, NULL, NULL)) != 0))) {
flags = tmp;
} else if ((mg_snprintf(path + n, path_size - n, "/" MG_HTTP_INDEX ".gz") > 0 &&
(tmp = fs->st(path, NULL, NULL)) != 0)) {
(tmp = fs->st(path, NULL, NULL)) != 0)) { // check for gzipped index
flags = tmp;
path[n + 1 + strlen(MG_HTTP_INDEX)] = '\0'; // Remove appended .gz
path[n + 1 + strlen(MG_HTTP_INDEX)] = '\0'; // Remove appended .gz in index file name
} else {
path[n] = '\0'; // Remove appended index file name
}
@ -5705,19 +5705,18 @@ struct ws_msg {
};
size_t mg_ws_vprintf(struct mg_connection *c, int op, const char *fmt,
va_list ap) {
char mem[256], *buf = mem;
size_t len = mg_vasprintf(&buf, sizeof(mem), fmt, ap);
len = mg_ws_send(c, buf, len, op);
if (buf != mem) free(buf);
return len;
va_list *ap) {
size_t len = c->send.len;
size_t n = mg_vrprintf(mg_pfn_iobuf, &c->send, fmt, ap);
mg_ws_wrap(c, c->send.len - len, op);
return n;
}
size_t mg_ws_printf(struct mg_connection *c, int op, const char *fmt, ...) {
size_t len = 0;
va_list ap;
va_start(ap, fmt);
len = mg_ws_vprintf(c, op, fmt, ap);
len = mg_ws_vprintf(c, op, fmt, &ap);
va_end(ap);
return len;
}
@ -5752,6 +5751,11 @@ static void ws_handshake(struct mg_connection *c, const struct mg_str *wskey,
mg_send(c, "\r\n", 2);
}
static uint32_t be32(const uint8_t *p) {
return (((uint32_t) p[3]) << 0) | (((uint32_t) p[2]) << 8) |
(((uint32_t) p[1]) << 16) | (((uint32_t) p[0]) << 24);
}
static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
size_t i, n = 0, mask_len = 0;
memset(msg, 0, sizeof(*msg));
@ -5764,12 +5768,11 @@ static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
msg->header_len = 2 + mask_len;
} else if (n == 126 && len >= 4 + mask_len) {
msg->header_len = 4 + mask_len;
msg->data_len = mg_ntohs(*(uint16_t *) &buf[2]);
msg->data_len = (((size_t) buf[2]) << 8) | buf[3];
} else if (len >= 10 + mask_len) {
msg->header_len = 10 + mask_len;
msg->data_len =
(size_t) (((uint64_t) mg_ntohl(*(uint32_t *) &buf[2])) << 32) +
mg_ntohl(*(uint32_t *) &buf[6]);
(size_t) (((uint64_t) be32(buf + 2) << 32) + be32(buf + 6));
}
}
// Sanity check, and integer overflow protection for the boundary check below
@ -5797,9 +5800,9 @@ static size_t mkhdr(size_t len, int op, bool is_client, uint8_t *buf) {
} else {
uint32_t tmp;
buf[1] = 127;
tmp = mg_htonl((uint32_t) ((uint64_t) len >> 32));
tmp = mg_htonl((uint32_t) (len >> 32));
memcpy(&buf[2], &tmp, sizeof(tmp));
tmp = mg_htonl((uint32_t) (len & 0xffffffff));
tmp = mg_htonl((uint32_t) (len & 0xffffffffU));
memcpy(&buf[6], &tmp, sizeof(tmp));
n = 10;
}

View File

@ -1262,7 +1262,8 @@ void mg_ws_upgrade(struct mg_connection *, struct mg_http_message *,
size_t mg_ws_send(struct mg_connection *, const void *buf, size_t len, int op);
size_t mg_ws_wrap(struct mg_connection *, size_t len, int op);
size_t mg_ws_printf(struct mg_connection *c, int op, const char *fmt, ...);
size_t mg_ws_vprintf(struct mg_connection *c, int op, const char *fmt, va_list);
size_t mg_ws_vprintf(struct mg_connection *c, int op, const char *fmt,
va_list *);

View File

@ -15,19 +15,18 @@ struct ws_msg {
};
size_t mg_ws_vprintf(struct mg_connection *c, int op, const char *fmt,
va_list ap) {
char mem[256], *buf = mem;
size_t len = mg_vasprintf(&buf, sizeof(mem), fmt, ap);
len = mg_ws_send(c, buf, len, op);
if (buf != mem) free(buf);
return len;
va_list *ap) {
size_t len = c->send.len;
size_t n = mg_vrprintf(mg_pfn_iobuf, &c->send, fmt, ap);
mg_ws_wrap(c, c->send.len - len, op);
return n;
}
size_t mg_ws_printf(struct mg_connection *c, int op, const char *fmt, ...) {
size_t len = 0;
va_list ap;
va_start(ap, fmt);
len = mg_ws_vprintf(c, op, fmt, ap);
len = mg_ws_vprintf(c, op, fmt, &ap);
va_end(ap);
return len;
}
@ -62,6 +61,11 @@ static void ws_handshake(struct mg_connection *c, const struct mg_str *wskey,
mg_send(c, "\r\n", 2);
}
static uint32_t be32(const uint8_t *p) {
return (((uint32_t) p[3]) << 0) | (((uint32_t) p[2]) << 8) |
(((uint32_t) p[1]) << 16) | (((uint32_t) p[0]) << 24);
}
static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
size_t i, n = 0, mask_len = 0;
memset(msg, 0, sizeof(*msg));
@ -74,12 +78,11 @@ static size_t ws_process(uint8_t *buf, size_t len, struct ws_msg *msg) {
msg->header_len = 2 + mask_len;
} else if (n == 126 && len >= 4 + mask_len) {
msg->header_len = 4 + mask_len;
msg->data_len = mg_ntohs(*(uint16_t *) &buf[2]);
msg->data_len = (((size_t) buf[2]) << 8) | buf[3];
} else if (len >= 10 + mask_len) {
msg->header_len = 10 + mask_len;
msg->data_len =
(size_t) (((uint64_t) mg_ntohl(*(uint32_t *) &buf[2])) << 32) +
mg_ntohl(*(uint32_t *) &buf[6]);
(size_t) (((uint64_t) be32(buf + 2) << 32) + be32(buf + 6));
}
}
// Sanity check, and integer overflow protection for the boundary check below
@ -107,9 +110,9 @@ static size_t mkhdr(size_t len, int op, bool is_client, uint8_t *buf) {
} else {
uint32_t tmp;
buf[1] = 127;
tmp = mg_htonl((uint32_t) ((uint64_t) len >> 32));
tmp = mg_htonl((uint32_t) (len >> 32));
memcpy(&buf[2], &tmp, sizeof(tmp));
tmp = mg_htonl((uint32_t) (len & 0xffffffff));
tmp = mg_htonl((uint32_t) (len & 0xffffffffU));
memcpy(&buf[6], &tmp, sizeof(tmp));
n = 10;
}

View File

@ -22,4 +22,5 @@ void mg_ws_upgrade(struct mg_connection *, struct mg_http_message *,
size_t mg_ws_send(struct mg_connection *, const void *buf, size_t len, int op);
size_t mg_ws_wrap(struct mg_connection *, size_t len, int op);
size_t mg_ws_printf(struct mg_connection *c, int op, const char *fmt, ...);
size_t mg_ws_vprintf(struct mg_connection *c, int op, const char *fmt, va_list);
size_t mg_ws_vprintf(struct mg_connection *c, int op, const char *fmt,
va_list *);

View File

@ -573,8 +573,8 @@ static void wcb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
struct mg_str *wsproto = mg_http_get_header(hm, "Sec-WebSocket-Protocol");
ASSERT(wsproto != NULL);
mg_ws_send(c, "boo", 3, WEBSOCKET_OP_BINARY);
mg_ws_send(c, "foobar", 6, WEBSOCKET_OP_BINARY);
mg_ws_printf(c, WEBSOCKET_OP_BINARY, "%.3s", "boo!!!!");
mg_ws_printf(c, WEBSOCKET_OP_BINARY, "%s", "foobar");
mg_ws_send(c, "", 0, WEBSOCKET_OP_PING);
p[0] += 100;
} else if (ev == MG_EV_WS_MSG) {
@ -588,6 +588,27 @@ static void wcb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
}
}
static void ew2(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
if (ev == MG_EV_WS_OPEN) {
char *msg = mg_file_read(&mg_fs_posix, "mongoose.c", NULL);
mg_ws_printf(c, WEBSOCKET_OP_TEXT, "%s", msg);
free(msg);
c->recv.align = 16 * 1024;
} else if (ev == MG_EV_WS_MSG) {
struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
if (wm->data.len == 6) {
// Ignore the "opened" message from server
} else {
char *msg = mg_file_read(&mg_fs_posix, "mongoose.c", NULL);
// MG_INFO(("%lu %lu", wm->data.len, strlen(msg)));
ASSERT(mg_vcmp(&wm->data, msg) == 0);
ASSERT(wm->data.len > 70000); // Message must be > 64k
free(msg);
*(int *) fn_data = 1;
}
}
}
static void test_ws(void) {
char buf[FETCH_BUF_SIZE];
const char *url = "ws://LOCALHOST:12343/ws";
@ -604,6 +625,12 @@ static void test_ws(void) {
// Test that non-WS requests fail
ASSERT(fetch(&mgr, buf, url, "GET /ws HTTP/1.0\r\n\n") == 426);
// Test large WS frames, over 64k
done = 0;
mg_ws_connect(&mgr, url, ew2, &done, NULL);
for (i = 0; i < 1000 && done == 0; i++) mg_mgr_poll(&mgr, 1);
ASSERT(done == 1);
mg_mgr_free(&mgr);
ASSERT(mgr.conns == NULL);
}
@ -2232,8 +2259,8 @@ static void w3(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
memset(buf, 'A', sizeof(buf));
mg_ws_send(c, "hi there!", 9, WEBSOCKET_OP_TEXT);
mg_printf(c, "%s", "boo");
mg_ws_wrap(c, 3, WEBSOCKET_OP_TEXT),
mg_ws_send(c, buf, sizeof(buf), WEBSOCKET_OP_TEXT);
mg_ws_wrap(c, 3, WEBSOCKET_OP_TEXT);
mg_ws_send(c, buf, sizeof(buf), WEBSOCKET_OP_TEXT);
} else if (ev == MG_EV_WS_MSG) {
struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
ASSERT(mg_strcmp(wm->data, mg_str("lebowski")) == 0);
@ -2266,11 +2293,14 @@ static void w2(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
}
} else if (ev == MG_EV_WS_MSG) {
struct mg_ws_message *wm = (struct mg_ws_message *) ev_data;
MG_INFO(("Got WS, %lu", wm->data.len));
mg_hexdump(wm->data.ptr, wm->data.len);
if (wm->data.len == 9) {
ASSERT(mg_strcmp(wm->data, mg_str("hi there!")) == 0);
} else if (wm->data.len == 3) {
ASSERT(mg_strcmp(wm->data, mg_str("boo")) == 0);
} else {
MG_INFO(("%lu", wm->data.len));
ASSERT(wm->data.len == 8192);
}
}