mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-25 12:04:47 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a8f839281 | ||
|
|
ab48174bac | ||
|
|
4439251f17 | ||
|
|
f9a6403b11 | ||
|
|
786f46c655 | ||
|
|
5ebd9fe7a5 | ||
|
|
2302ae5e88 | ||
|
|
8b12263dbc | ||
|
|
376d2666a5 | ||
|
|
d90622630f | ||
|
|
da447b1067 | ||
|
|
460d95afc5 | ||
|
|
8f522048d8 | ||
|
|
147c095105 | ||
|
|
fecb11f2fa | ||
|
|
56e50c2dbe | ||
|
|
c1b5e9b260 | ||
|
|
286fa90ee9 | ||
|
|
d63fb70c69 | ||
|
|
4d76a3be4c | ||
|
|
d9c612ef2b | ||
|
|
3b3ca1c1b3 | ||
|
|
2e748fdbf1 | ||
|
|
6c99691d1c | ||
|
|
fd067c8077 | ||
|
|
04012760d1 | ||
|
|
0ec1a141f1 | ||
|
|
7414a4fb06 | ||
|
|
abbd44e276 | ||
|
|
13e80e6bd5 | ||
|
|
ffa981d172 | ||
|
|
806f07db67 | ||
|
|
6746933a3d | ||
|
|
8cb2833fa7 | ||
|
|
1730f3c0c9 | ||
|
|
d6dda04f4f | ||
|
|
1b0825ef4b | ||
|
|
7249b2bd5f | ||
|
|
238bf1a29e | ||
|
|
4cbf81da59 | ||
|
|
d9b7ec18e7 | ||
|
|
ffed9c4d8c | ||
|
|
0dc0c5a0e0 | ||
|
|
57f826ece1 | ||
|
|
729bdebc50 | ||
|
|
2a541175b5 | ||
|
|
5f93f7162f | ||
|
|
3640554503 | ||
|
|
12437fd7fe | ||
|
|
4120f953c7 | ||
|
|
844c7787f9 | ||
|
|
0fe9ec1499 | ||
|
|
b3fb21dacc | ||
|
|
2deaf084e4 | ||
|
|
1b324510cc | ||
|
|
fd839f1827 | ||
|
|
f149f4aab1 | ||
|
|
af6fc64ab9 | ||
|
|
ff159bf30a | ||
|
|
8cdd19bcae | ||
|
|
2efc859829 | ||
|
|
d4a8351464 | ||
|
|
5fa544fc78 | ||
|
|
1070dd2d87 | ||
|
|
af98854ce4 | ||
|
|
7cace648c0 | ||
|
|
447bf4adb0 | ||
|
|
6572c1c692 | ||
|
|
7b48859f8d | ||
|
|
a6230bafe7 | ||
|
|
cc8f1466c7 | ||
|
|
69f810febc | ||
|
|
e5da7440d7 | ||
|
|
849ec1684a | ||
|
|
4f210cd8eb | ||
|
|
285f75764c | ||
|
|
3586203753 | ||
|
|
e406de7e00 | ||
|
|
53ed8502c9 | ||
|
|
ac8c756879 | ||
|
|
07faacdaf9 | ||
|
|
8464844518 | ||
|
|
fe2d1ff027 | ||
|
|
8d129e359e | ||
|
|
39aa56457b | ||
|
|
8491d5da8b | ||
|
|
681196e2c8 | ||
|
|
836ad5ebab | ||
|
|
a3ea1eddfb | ||
|
|
a2c06ac6ba | ||
|
|
a5c697fa2d | ||
|
|
be199b4fe9 | ||
|
|
cc15320cfe | ||
|
|
70bae59ec6 | ||
|
|
d4f3361805 | ||
|
|
332c855d40 | ||
|
|
01e3fa4d13 | ||
|
|
15a0f7a00a | ||
|
|
a751adba2a | ||
|
|
10eed010df | ||
|
|
033ca26216 | ||
|
|
40793cbdce | ||
|
|
48a1b2ec75 | ||
|
|
1a55556c66 | ||
|
|
3edd3ccbe6 | ||
|
|
194933e037 | ||
|
|
38deaedaef | ||
|
|
fc3dd5900c | ||
|
|
b1213425d0 | ||
|
|
40f0b450a8 | ||
|
|
0bab3977a8 | ||
|
|
2c46760b77 | ||
|
|
878c9ae5ae | ||
|
|
c8553de09e | ||
|
|
6738858e11 | ||
|
|
61cd6ab86e | ||
|
|
77704b669a | ||
|
|
770be613d7 | ||
|
|
9790366449 | ||
|
|
89f0a8c530 | ||
|
|
f72a06e25a | ||
|
|
8b975533e5 | ||
|
|
b32f7a9b57 | ||
|
|
e1e0083897 | ||
|
|
ca08ac0e3c | ||
|
|
a5b85b4462 | ||
|
|
3feab3a16d | ||
|
|
5d76e57b81 | ||
|
|
9101cd0339 | ||
|
|
4b2d3f5f5b | ||
|
|
482a471abb | ||
|
|
4d90bb0d02 | ||
|
|
202dfc18be | ||
|
|
13f4742699 | ||
|
|
33e769bd75 | ||
|
|
992f3000ef | ||
|
|
7ea4adae5e | ||
|
|
5ed9991135 | ||
|
|
dc2527c11f | ||
|
|
bee95654f3 | ||
|
|
48296bb1cf | ||
|
|
1ee9735354 | ||
|
|
f8da303ca1 | ||
|
|
6ae6ee9fd2 | ||
|
|
a11eafc5b3 | ||
|
|
efe53b57e4 | ||
|
|
e2330944d4 | ||
|
|
1c18906db7 | ||
|
|
873ceb48bd | ||
|
|
a48b955d89 | ||
|
|
b92fae2bfb | ||
|
|
156be17191 | ||
|
|
92290cfe81 | ||
|
|
29725c97f1 | ||
|
|
56b9cd14cb | ||
|
|
3550cc8f48 | ||
|
|
6a3d01ee6b | ||
|
|
27986213aa | ||
|
|
a2d07ef983 | ||
|
|
3cf4e32d9f | ||
|
|
a54584b716 | ||
|
|
51907e2642 | ||
|
|
5dd9d37ef2 | ||
|
|
f900854e0d | ||
|
|
d20e94f763 | ||
|
|
58de2ad2d7 | ||
|
|
f30c7b75d0 | ||
|
|
c5b8e55e12 | ||
|
|
559874fce7 | ||
|
|
1875653b34 | ||
|
|
6df770e72d | ||
|
|
51d415c8dd | ||
|
|
63bf428c34 | ||
|
|
a5d2772082 | ||
|
|
43c317ef4c | ||
|
|
01ffdb69d0 | ||
|
|
a78f346ac6 | ||
|
|
4ae88c859e | ||
|
|
e8a97f12d7 | ||
|
|
06aabdefbe | ||
|
|
15643f8e67 | ||
|
|
b987df1974 | ||
|
|
cbe63d43df | ||
|
|
e91a7c9599 | ||
|
|
3054952a5e | ||
|
|
3244df9cd1 | ||
|
|
1f75081f6e | ||
|
|
2c83a50a8a | ||
|
|
1c80fc28ee | ||
|
|
810eab9a58 | ||
|
|
256aa0296d | ||
|
|
2eb506c5e0 | ||
|
|
9f78a2902b | ||
|
|
613ae4ee34 | ||
|
|
ab208b71c4 | ||
|
|
68dd8d277d | ||
|
|
36a1927915 | ||
|
|
68437de416 | ||
|
|
459cd1b095 | ||
|
|
6f7f774080 | ||
|
|
fc0bf1953a | ||
|
|
c907e6c5fb | ||
|
|
29b3950ee7 | ||
|
|
0e0c6b8357 | ||
|
|
6f17f3e2c2 | ||
|
|
df107a272e | ||
|
|
b7a0748312 | ||
|
|
421b420a0c | ||
|
|
a478dc5935 | ||
|
|
4d65cb1c0f | ||
|
|
ced823cd95 | ||
|
|
79325bd219 | ||
|
|
5a19135c35 | ||
|
|
290e5f83d4 | ||
|
|
b535cb319a | ||
|
|
e3a9c6afb4 | ||
|
|
3f1a33e4b4 | ||
|
|
441eaa7f6c | ||
|
|
632153a1b4 | ||
|
|
f9d0ad9dc3 | ||
|
|
a67323fc12 | ||
|
|
1daa5e69b1 | ||
|
|
1718490982 | ||
|
|
1d4f97bb4c | ||
|
|
183fc7ced9 | ||
|
|
dcf1cedec9 | ||
|
|
845e608280 | ||
|
|
d6ecfe7f24 | ||
|
|
06b6bf6185 | ||
|
|
04a38b446f | ||
|
|
dfde5785a6 | ||
|
|
1a61455eef | ||
|
|
9f2ecb0144 | ||
|
|
3265060dc8 | ||
|
|
58b8acd68a | ||
|
|
3ec09ceedf | ||
|
|
1ce4aa81ee | ||
|
|
177e829f4b | ||
|
|
b5b672ec89 | ||
|
|
d41419c8d3 | ||
|
|
5e4d9dc17a | ||
|
|
4ac688e560 | ||
|
|
5d0a5cfe72 | ||
|
|
d4b81bb911 | ||
|
|
23122b327c | ||
|
|
f443c64341 | ||
|
|
c84af7d1e2 | ||
|
|
19a28b3c81 | ||
|
|
69944c1d3a | ||
|
|
81bf4921d4 | ||
|
|
91f6eedb24 | ||
|
|
dae150a3a5 | ||
|
|
8a81dce0c1 | ||
|
|
203d4a79e2 | ||
|
|
b04d47c3a9 | ||
|
|
8fcd1906a2 | ||
|
|
9939212379 | ||
|
|
38752f1327 | ||
|
|
6b51ec3371 | ||
|
|
5714056f9f | ||
|
|
21665e367c | ||
|
|
dff844b40a | ||
|
|
54403dfcbc | ||
|
|
61672c7805 | ||
|
|
69bb96113b | ||
|
|
51328efb22 | ||
|
|
f159666ae3 | ||
|
|
7fdb50807c | ||
|
|
890c7b42dc | ||
|
|
55398684cc | ||
|
|
c85edc38aa | ||
|
|
fa368b56ba | ||
|
|
41d7520585 | ||
|
|
0f23618324 | ||
|
|
bf9a2b45ef | ||
|
|
063c017bb7 | ||
|
|
7519a3765b | ||
|
|
56c687b39b | ||
|
|
083d398631 | ||
|
|
466183113f | ||
|
|
923c432977 | ||
|
|
e433ba8d7b | ||
|
|
848c884fff | ||
|
|
0769bbb7ff | ||
|
|
7054b09584 | ||
|
|
2633628ad1 | ||
|
|
e5ae1c2ea3 | ||
|
|
d2844580a1 | ||
|
|
42f5a3e2f7 | ||
|
|
8a62005a2d | ||
|
|
616f54c4a2 | ||
|
|
2140e5992a | ||
|
|
cd38c62430 | ||
|
|
67ac6ae191 | ||
|
|
7addae0fdd | ||
|
|
a3e8ba5506 | ||
|
|
6a302c38ab | ||
|
|
129bb6b1c3 | ||
|
|
c8b09c2238 | ||
|
|
76364af243 | ||
|
|
0efa8f9d3f | ||
|
|
f36b452f00 | ||
|
|
0be132f3b5 | ||
|
|
d31d8a764b | ||
|
|
68b29b683d | ||
|
|
eee293518c | ||
|
|
c4adc86f5e | ||
|
|
3ebda76def | ||
|
|
7564623d46 | ||
|
|
dc6b44571f | ||
|
|
ccd0167e40 | ||
|
|
7dd1004b93 | ||
|
|
19dd02acfd | ||
|
|
5e31914dc1 | ||
|
|
8296e0f485 | ||
|
|
afa5e3f469 | ||
|
|
f57fcbcb50 | ||
|
|
ce53e9dd2b | ||
|
|
55c2634416 | ||
|
|
fe0d340c03 | ||
|
|
5a02c9dbed | ||
|
|
2c4ffcf70d | ||
|
|
53c3e1338f | ||
|
|
79454a9072 | ||
|
|
21c2c5650b | ||
|
|
81ee559905 | ||
|
|
4a637a6e9a | ||
|
|
aaf4802d80 | ||
|
|
96310d761b | ||
|
|
96150bf568 | ||
|
|
f49df51544 | ||
|
|
673796fb3a | ||
|
|
482ab33c03 | ||
|
|
fb53cd37e7 | ||
|
|
c9fc7a1320 | ||
|
|
5f59b7e747 | ||
|
|
024b24932c | ||
|
|
604c0b189f | ||
|
|
356f1f5119 | ||
|
|
06659844b6 | ||
|
|
57cf363be9 | ||
|
|
2fc1ff68cf | ||
|
|
6c4fecc4f7 | ||
|
|
0991ad7cc8 | ||
|
|
d03b96b699 | ||
|
|
a690c1442f | ||
|
|
d742b67878 | ||
|
|
41971a95b2 | ||
|
|
b6d700077a | ||
|
|
c091e6910b | ||
|
|
35f633b533 | ||
|
|
85e4ed7c25 | ||
|
|
3b345a81c4 | ||
|
|
a55c48a4ce | ||
|
|
6f4c21c218 | ||
|
|
5060640408 | ||
|
|
f1cc8379e7 | ||
|
|
4f9627c612 | ||
|
|
012f241005 | ||
|
|
ccf67dbf05 | ||
|
|
a43709b4a8 | ||
|
|
e95c074965 | ||
|
|
4ca73566b6 | ||
|
|
d0b347517c | ||
|
|
7bed7ff482 | ||
|
|
d38b0dbf5b | ||
|
|
29d6c4ac04 | ||
|
|
8148b6d037 | ||
|
|
3327e0e871 | ||
|
|
0456f0f59b | ||
|
|
72cf78de2c | ||
|
|
1d0a89879c | ||
|
|
d1cc952859 | ||
|
|
f56c5b201d | ||
|
|
077b9eb7a4 | ||
|
|
15c333feb0 | ||
|
|
31c20ab32c | ||
|
|
69215cf9eb | ||
|
|
f89b51eace | ||
|
|
c581b5e532 | ||
|
|
df311203dc | ||
|
|
4927195ee4 | ||
|
|
63be1ebd38 | ||
|
|
796dc18cfb | ||
|
|
14e116553f | ||
|
|
c82ccd6cf7 | ||
|
|
0adb080319 | ||
|
|
dbb38fffae | ||
|
|
672a68219a | ||
|
|
22cb0efd00 | ||
|
|
a68d3d63b2 | ||
|
|
cf48c7280a | ||
|
|
1295973028 | ||
|
|
d5b9eda0f2 | ||
|
|
41c078d25c | ||
|
|
5614224e7d | ||
|
|
9ba44cb0d5 | ||
|
|
c18828af7b | ||
|
|
8a5f8439b4 | ||
|
|
8f0374569e | ||
|
|
09dde636d2 | ||
|
|
d347247bf3 | ||
|
|
a6c66fb669 | ||
|
|
b4dbc825b1 | ||
|
|
4a0cc8223e | ||
|
|
7db10857b3 | ||
|
|
7e927b43ad | ||
|
|
9eea072f2a | ||
|
|
aa2ff674db | ||
|
|
de24bfdf2f | ||
|
|
2a084c3d98 | ||
|
|
db8df41396 | ||
|
|
bda05d9372 | ||
|
|
59bc2af4d6 | ||
|
|
00a23ee330 | ||
|
|
51ad50a641 | ||
|
|
148e1926e8 | ||
|
|
96c023df41 | ||
|
|
44f37f49a1 | ||
|
|
a8a30f6d3f | ||
|
|
ba80b1cd55 | ||
|
|
b56e985ccc | ||
|
|
67521fd9f6 | ||
|
|
8c394f44b8 | ||
|
|
77b4fff268 | ||
|
|
f56a0c6075 | ||
|
|
9ce8486059 | ||
|
|
04a321150a | ||
|
|
d333c3c09e | ||
|
|
81d977c720 | ||
|
|
f477898c7c | ||
|
|
566193a1eb | ||
|
|
5d6eeb5d1d | ||
|
|
d9b9d71b2d | ||
|
|
643ee1df14 | ||
|
|
6c4d37ee68 | ||
|
|
97b79cd04a | ||
|
|
56c6229dd6 | ||
|
|
0fe2dd9b48 | ||
|
|
910aee7f7b | ||
|
|
97063937ff | ||
|
|
7e68b097d1 | ||
|
|
4d41dff4fd | ||
|
|
05082cec88 | ||
|
|
f05733da69 | ||
|
|
3c53909e82 | ||
|
|
1e53ec47a9 | ||
|
|
17802735d7 | ||
|
|
d2eb67a1ae | ||
|
|
3f254dd3fc | ||
|
|
e139bde6ae | ||
|
|
5f62951143 | ||
|
|
2207e87c8f | ||
|
|
5bd59c7b70 | ||
|
|
02f6867a2f | ||
|
|
b93fa3144a | ||
|
|
a68e0d9a3f | ||
|
|
cfe80ba9b7 | ||
|
|
35abfd44dd | ||
|
|
e98b5a691e | ||
|
|
ed24afd172 | ||
|
|
714556de65 | ||
|
|
547ec85b58 | ||
|
|
845d751e87 | ||
|
|
518a7f8a71 | ||
|
|
31323b01bc | ||
|
|
3a138ecc83 | ||
|
|
7294674a8b | ||
|
|
423b978395 | ||
|
|
ecf20ec7b8 | ||
|
|
c948a509fb | ||
|
|
f5ad19d76b | ||
|
|
d665d9e90e | ||
|
|
a5e10450dd | ||
|
|
e9d79b130d | ||
|
|
7951dac9d5 | ||
|
|
6c77351c58 | ||
|
|
7c4cda622f | ||
|
|
d8f8c1cb99 | ||
|
|
d2b9ad570f | ||
|
|
5b36f32996 | ||
|
|
3298030b8e | ||
|
|
6cfc696439 | ||
|
|
a93b3a06dd | ||
|
|
79e8d77ea0 | ||
|
|
d68fab9ee5 | ||
|
|
bda470245e | ||
|
|
0c95290f93 | ||
|
|
8989739d32 | ||
|
|
1112981e6e | ||
|
|
0cf82744ce | ||
|
|
5cdf838325 | ||
|
|
6418cad39f | ||
|
|
46529fd51e | ||
|
|
c09ba40a48 | ||
|
|
47d52896a1 | ||
|
|
d60c99b01c | ||
|
|
b8aeba06a2 | ||
|
|
8a0bc2d614 | ||
|
|
e34747d1ad | ||
|
|
1a6bc7c514 | ||
|
|
ffa0ddfdbf | ||
|
|
ca55bff1cf | ||
|
|
cfee5c4fdb | ||
|
|
e46185068b | ||
|
|
6ef2fea45e | ||
|
|
e244dd84a9 | ||
|
|
5034937a15 | ||
|
|
060045be65 | ||
|
|
9adfe8d484 | ||
|
|
799cc369e0 | ||
|
|
b97d3fea4b | ||
|
|
2a4ca9d5c3 | ||
|
|
747e40e74e | ||
|
|
cf279e7885 | ||
|
|
cbf968735a | ||
|
|
57b35e6007 | ||
|
|
1eaabdd8e5 | ||
|
|
dcd4e660a3 | ||
|
|
96409e74e5 | ||
|
|
e28ee097a1 | ||
|
|
2b4e544867 | ||
|
|
ee042a3481 | ||
|
|
63075f6846 | ||
|
|
7f2e42a06d | ||
|
|
3fbfa33b9a | ||
|
|
179aa75047 | ||
|
|
4658194d08 | ||
|
|
b35657814c | ||
|
|
a2322c77c6 | ||
|
|
b50c183c19 | ||
|
|
a941687db0 | ||
|
|
c2eef52b65 | ||
|
|
3e6cbbde04 | ||
|
|
6400536282 | ||
|
|
776103068f | ||
|
|
93beff3b65 | ||
|
|
22f8d86b05 | ||
|
|
3a9a9c7ad0 | ||
|
|
13238b1ad2 | ||
|
|
56f661e9c6 | ||
|
|
5351f46efb | ||
|
|
0cd3335b78 | ||
|
|
0611627448 | ||
|
|
f014918435 | ||
|
|
51e016089e | ||
|
|
8a66ff5278 | ||
|
|
e1dd3f06fe | ||
|
|
32ab35f61f | ||
|
|
8ab96ec74b | ||
|
|
0730590e35 | ||
|
|
f7e0b1331c | ||
|
|
17aa2a7092 | ||
|
|
7d38d05ca7 | ||
|
|
33bad047f0 | ||
|
|
5234b73c29 | ||
|
|
c566e2eba5 | ||
|
|
e565977481 | ||
|
|
8927c9d22b | ||
|
|
28eb251ccd | ||
|
|
b99dc95b1d | ||
|
|
75aadb3e79 | ||
|
|
b6ecd5fb4c | ||
|
|
1e7f55ed84 | ||
|
|
eeadc5ecff | ||
|
|
568ca42988 | ||
|
|
7b758bfc9d | ||
|
|
8ef454b75f | ||
|
|
0a2f2fda5c | ||
|
|
6b440918ec | ||
|
|
a73fce945c | ||
|
|
d349bb3cc7 | ||
|
|
7c4119a287 | ||
|
|
8a71ad99e6 | ||
|
|
41b405d7bf | ||
|
|
30b80dc5ee | ||
|
|
524aa2e586 | ||
|
|
990a1b9ae0 | ||
|
|
4cb0c6864e | ||
|
|
5183693951 | ||
|
|
e47506f957 | ||
|
|
824e4dc0e4 | ||
|
|
d033497714 | ||
|
|
d8028df29d | ||
|
|
564683d25a | ||
|
|
30c0a3f201 | ||
|
|
08fe9ac518 | ||
|
|
14d6f71f82 | ||
|
|
29454e2296 | ||
|
|
d6cbf9f77d | ||
|
|
b9fead4d6e | ||
|
|
c6a04e1719 | ||
|
|
c839a61fea | ||
|
|
c06abbc5f7 | ||
|
|
c8e88e1710 | ||
|
|
bf7a115bf2 | ||
|
|
b8dfb69cf5 | ||
|
|
1cd9715095 | ||
|
|
5c7aeac148 | ||
|
|
09a80628e6 | ||
|
|
2ff2c369f7 | ||
|
|
eef70aaf74 | ||
|
|
89ac97caba | ||
|
|
c00b236c8d | ||
|
|
eacd3f35e0 | ||
|
|
8a2aa72571 | ||
|
|
7da8f273d2 | ||
|
|
a90a5a2b6a | ||
|
|
b5b819b4a3 | ||
|
|
821e2b3a75 | ||
|
|
773efb0745 | ||
|
|
ed1904a75d | ||
|
|
a66663f0f6 | ||
|
|
1104688b02 | ||
|
|
36d95e230e | ||
|
|
8a27a95a2a | ||
|
|
2e63b5a5e5 | ||
|
|
4cbd113d01 | ||
|
|
ba5ae74144 | ||
|
|
f2b40e5fae | ||
|
|
8ed682930b | ||
|
|
86ad7922b0 | ||
|
|
f7476f53c7 | ||
|
|
5d6f7ac8ef | ||
|
|
f16fa5ed55 | ||
|
|
c0ba32f7a6 | ||
|
|
7cf28a5623 | ||
|
|
6668c456ac | ||
|
|
98f2476751 |
No files matched your search
@@ -0,0 +1,8 @@
|
|||||||
|
People who have agreed to the
|
||||||
|
[Cesanta CLA](https://docs.cesanta.com/contributors_la.shtml)
|
||||||
|
can make contributions. Note that the CLA isn't a copyright
|
||||||
|
_assigment_ but rather a copyright _license_.
|
||||||
|
You retain the copyright on your contributions.
|
||||||
|
|
||||||
|
We follow the Google C/C++ style guide: https://google.github.io/styleguide/cppguide.html
|
||||||
|
We'd appreciate if your contribution follows the same style guide.
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
Copyright (c) 2004-2013 Sergey Lyubka <valenok@gmail.com>
|
Copyright (c) 2004-2013 Sergey Lyubka <valenok@gmail.com>
|
||||||
Copyright (c) 2013-2015 Cesanta Software Limited
|
Copyright (c) 2013-2016 Cesanta Software Limited
|
||||||
All rights reserved
|
All rights reserved
|
||||||
|
|
||||||
This code is dual-licensed: you can redistribute it and/or modify
|
This software is dual-licensed: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License version 2 as
|
it under the terms of the GNU General Public License version 2 as
|
||||||
published by the Free Software Foundation. For the terms of this
|
published by the Free Software Foundation. For the terms of this
|
||||||
license, see <http://www.gnu.org/licenses>.
|
license, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
You are free to use this code under the terms of the GNU General
|
You are free to use this software under the terms of the GNU General
|
||||||
Public License, but WITHOUT ANY WARRANTY; without even the implied
|
Public License, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
See the GNU General Public License for more details.
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
Alternatively, you can license this code under a commercial
|
Alternatively, you can license this software under a commercial
|
||||||
license, as set out in <http://cesanta.com/>.
|
license, as set out in <https://www.cesanta.com/license>.
|
||||||
@@ -1,76 +1,80 @@
|
|||||||
# <img src="http://cesanta.com/images/mongoose_logo.png" width="64" height="64"> Mongoose Web Server
|
# Mongoose - Embedded Web Server / Embedded Networking Library
|
||||||
|
|
||||||
Mongoose is the most easy to use web server on the planet. A web server of choice for Web developers (PHP, Ruby, Python, etc) and Web designers.
|

|
||||||
|
|
||||||
Mongoose is built on top of Libmongoose embedded library, which can turn
|
Mongoose is ideal for embedded environments. It has been designed
|
||||||
anything into a web server in 5 minutes worth of effort and few lines of code.
|
for connecting devices and bringing them online. On the market since 2004,
|
||||||
Libmongoose is used to serve Web GUI on embedded devices, implement RESTful
|
used by vast number of open source and
|
||||||
services, RPC frameworks (e.g. JSON-RPC), handle telemetry data exchange, and
|
commercial products - it even runs on space stations!
|
||||||
perform many other tasks in various different industries including aerospace,
|
Mongoose makes embedded network programming fast, robust, and easy.
|
||||||
manufacturing, finance, research, automotive, gaming, IT.
|
|
||||||
|
|
||||||
|
If you're looking for a pre-compiled Windows or Mac binary,
|
||||||
|
- [Download pre-compiled Mongoose web server binary](https://www.cesanta.com/products/binary)
|
||||||
|
|
||||||
* [Mailing list](http://groups.google.com/group/mongoose-users)
|
Alternatively,
|
||||||
* [Downloads](http://cesanta.com/products.shtml)
|
|
||||||
* [Documentation](http://cesanta.com/docs.shtml)
|
|
||||||
|
|
||||||
Check out Fossa - our [embedded multi-protocol library](https://github.com/cesanta/fossa) with TCP,UDP,HTTP,Websocket,MQTT,DNS support, designed for Internet Of Things!
|
- [Download Mongoose Source Code here](http://hubs.ly/H01bWvx0)
|
||||||
|
- [Check our latest releases] (https://github.com/cesanta/mongoose/releases)
|
||||||
|
- [Read User Guide and API reference](https://docs.cesanta.com/mongoose/dev)
|
||||||
|
- [Study mongoose example code](https://github.com/cesanta/mongoose/tree/master/examples)
|
||||||
|
|
||||||
|
If you are looking for a complete solution with firmware and cloud components, check out [Mongoose IoT Platform](https://github.com/cesanta/mongoose-iot).
|
||||||
|
|
||||||
|
# Support
|
||||||
|
- [Support Forum - Ask your technical questions here] (http://forum.cesanta.com/index.php?p=/categories/mongoose)
|
||||||
|
- [Chat - Visit www.cesanta.com for our live chat] (http://www.cesanta.com)
|
||||||
|
- [Commercial one-to-one support - Available to all commercial license holders] (https://www.cesanta.com/services-support)
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
||||||
- Works on Windows, Mac, UNIX/Linux, iPhone, Android eCos, QNX
|
* Cross-platform: works on Linux/UNIX, MacOS, QNX, eCos, Windows, Android,
|
||||||
and many other platforms
|
iPhone, FreeRTOS (TI CC3200, ESP8266), etc
|
||||||
- CGI, SSI, SSL, Digest auth, Websocket, WEbDAV, Resumed download,
|
* Single-threaded, asynchronous, non-blocking core with simple event-based API
|
||||||
URL rewrite, file blacklist
|
* Native support for [PicoTCP embedded TCP/IP stack](http://www.picotcp.com),
|
||||||
- Custom error pages, Virtual hosts, IP-based ACL, Windows service,
|
[LWIP embedded TCP/IP stack](https://en.wikipedia.org/wiki/LwIP)
|
||||||
HTTP/HTTPS client
|
* Builtin protocols:
|
||||||
- Simple and clean
|
- plain TCP, plain UDP, SSL/TLS (over TCP, one-way or two-way)
|
||||||
[embedding API](https://github.com/cesanta/mongoose/blob/master/mongoose.h).
|
- HTTP client, HTTP server
|
||||||
The source is in single
|
- WebSocket client, WebSocket server
|
||||||
[mongoose.c](https://github.com/cesanta/mongoose/blob/master/mongoose.c) file
|
- MQTT client, MQTT broker
|
||||||
to make embedding easy
|
- CoAP client, CoAP server
|
||||||
- Extremely lightweight, has a core of under 40kB and tiny runtime footprint
|
- DNS client, DNS server, async DNS resolver
|
||||||
- Asynchronous, non-blocking core supporting single- or multi-threaded usage
|
* Tiny static and run-time footprint
|
||||||
- On the market since 2004 with over 1 million cumulative downloads
|
* Source code is both ISO C and ISO C++ compliant
|
||||||
- Stable, mature and tested, has several man-years invested
|
* Very easy to integrate: just copy
|
||||||
in continuous improvement and refinement
|
[mongoose.c](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.c) and
|
||||||
|
[mongoose.h](https://raw.githubusercontent.com/cesanta/mongoose/master/mongoose.h)
|
||||||
# Screenshots
|
files to your build tree
|
||||||
|
|
||||||
Download, double-click to start, run browser -- that's all!
|
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
# Contributions
|
|
||||||
|
|
||||||
People who have agreed to the
|
|
||||||
[Cesanta CLA](http://cesanta.com/contributors_la.html)
|
|
||||||
can make contributions. Note that the CLA isn't a copyright
|
|
||||||
_assigment_ but rather a copyright _license_.
|
|
||||||
You retain the copyright on your contributions.
|
|
||||||
|
|
||||||
# Licensing
|
# Licensing
|
||||||
|
|
||||||
Mongoose is released under commercial and
|
Mongoose is released under commercial and [GNU GPL v.2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) open source licenses.
|
||||||
[GNU GPL v.2](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) open
|
|
||||||
source licenses. The GPLv2 open source License does not generally permit
|
|
||||||
incorporating this software into non-open source programs.
|
|
||||||
For those customers who do not wish to comply with the GPLv2 open
|
|
||||||
source license requirements,
|
|
||||||
[Cesanta](http://cesanta.com) offers a full,
|
|
||||||
royalty-free commercial license and professional support
|
|
||||||
without any of the GPL restrictions.
|
|
||||||
|
|
||||||
# Other products by Cesanta
|
Commercial Projects:
|
||||||
|
Once your project becomes commercialised GPLv2 licensing dictates that you need to either open your source fully or purchase a commercial license. Cesanta offer full, royalty-free commercial licenses without any GPL restrictions. If your needs require a custom license, we’d be happy to work on a solution with you. [Contact us for pricing.] (https://www.cesanta.com/contact)
|
||||||
|
|
||||||
- [Fossa](http://github.com/cesanta/fossa) - Multi-protocol networking library
|
Prototyping:
|
||||||
- [SSL Wrapper](https://github.com/cesanta/ssl_wrapper) - application to
|
While your project is still in prototyping stage and not for sale, you can use Mongoose’s open source code without license restrictions.
|
||||||
secure network communications
|
|
||||||
- [Frozen](https://github.com/cesanta/frozen) - JSON parser and generator
|
# Dashboard Example
|
||||||
- [SLRE](https://github.com/cesanta/slre) - Super Light Regular Expression
|
|
||||||
library
|
Mongoose is often used to implement device dashboards and real-time
|
||||||
- [V7](https://github.com/cesanta/v7) - Embedded JavaScript engine
|
data exchange over Websocket. Here is a dashboard example that illustrates
|
||||||
|
the functionality:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
[Developing a new product? Contact us today to discuss how Mongoose can help
|
||||||
|
](https://www.cesanta.com/contact)
|
||||||
|
|
||||||
|
# Contributions
|
||||||
|
|
||||||
|
To submit contributions, sign
|
||||||
|
[Cesanta CLA](https://docs.cesanta.com/contributors_la.shtml)
|
||||||
|
and send GitHub pull request. You retain the copyright on your contributions.
|
||||||
|
|
||||||
|
## Working with the Source Code
|
||||||
|
|
||||||
|
See [tools](https://github.com/cesanta/mongoose/tree/master/tools) directory.
|
||||||
|
|
||||||
|
[](https://github.com/cesanta/mongoose)
|
||||||
-249
@@ -1,249 +0,0 @@
|
|||||||
# Mongoose API Reference
|
|
||||||
|
|
||||||
struct mg_server *mg_create_server(void *server_param, mg_handler_t handler);
|
|
||||||
|
|
||||||
Creates web server instance. Returns opaque instance pointer, or NULL if
|
|
||||||
there is not enough memory. `server_param`: Could be any pointer, or NULL.
|
|
||||||
This pointer will be passed
|
|
||||||
to the callback functions as `struct mg_connection::server_param` field.
|
|
||||||
A common use case is to pass `this` pointer of the C++ wrapper class
|
|
||||||
as `user_param`, to let the callback get the pointer to the C++ object.
|
|
||||||
|
|
||||||
Note that this function doesn't make the
|
|
||||||
server instance to serve. Serving is done by `mg_poll_server()` function.
|
|
||||||
Mongoose has single-threaded, event-driven, asynchronous, non-blocking core.
|
|
||||||
When server instance is created, it contains an information about
|
|
||||||
the configuration and the state of each connection.
|
|
||||||
Server instance is capable on listening on only one port. After creation,
|
|
||||||
`struct mg_server` has a list
|
|
||||||
of active connections and configuration parameters.
|
|
||||||
|
|
||||||
Side-effect: on UNIX, `mg_create_server()` ignores SIGPIPE signals. If custom
|
|
||||||
processing is required SIGPIPE, signal handler must be set up after
|
|
||||||
calling `mg_create_server()`.
|
|
||||||
|
|
||||||
Important: Mongoose does not install `SIGCHLD` handler. If CGI is used,
|
|
||||||
`SIGCHLD` handler must be set up to reap CGI zombie processes.
|
|
||||||
|
|
||||||
|
|
||||||
void mg_destroy_server(struct mg_server **server);
|
|
||||||
|
|
||||||
Deallocates web server instance, closes all pending connections, and makes
|
|
||||||
server pointer a NULL pointer.
|
|
||||||
|
|
||||||
const char mg_set_option(struct mg_server *server, const char *name,
|
|
||||||
const char *value);
|
|
||||||
|
|
||||||
Sets a particular server option. Note that at least one option,
|
|
||||||
`listening_port`, must be specified. To serve static files, `document_root`
|
|
||||||
must be specified too. If `document_root` option is left unset, Mongoose
|
|
||||||
will not access filesystem at all. `mg_set_option()` returns NULL if option was
|
|
||||||
set successfully, otherwise it returns human-readable error string. It is
|
|
||||||
allowed to call `mg_set_option()` by the same thread that does
|
|
||||||
`mg_poll_server()` (Mongoose thread) and change server configuration while it
|
|
||||||
is serving, in between `mg_poll_server()` calls.
|
|
||||||
|
|
||||||
int mg_poll_server(struct mg_server *server, int milliseconds);
|
|
||||||
|
|
||||||
Performs one iteration of IO loop by iterating over all
|
|
||||||
active connections, performing `select()` syscall on all sockets with a timeout
|
|
||||||
of `milliseconds`. When `select()` returns, Mongoose
|
|
||||||
does an IO for each socket that has data to be sent or received. Application
|
|
||||||
code must call `mg_poll_server()` in a loop. It is an error to have more then
|
|
||||||
one thread calling `mg_poll_server()`, `mg_set_option()` or any other function
|
|
||||||
that take `struct mg_server *` parameter. Mongoose does not
|
|
||||||
mutex-protect `struct mg_server *`, therefore only single thread
|
|
||||||
(Mongoose thread) should make Mongoose calls.
|
|
||||||
|
|
||||||
`mg_poll_server()` calls user-specified event handler when certain events
|
|
||||||
occur. Sequence of events for the accepted connection is this:
|
|
||||||
|
|
||||||
* `MG_AUTH` - Mongoose asks whether this connection is authorized. If event
|
|
||||||
handler returns `MG_FALSE`, then Mongoose does not serve the request but
|
|
||||||
sends authorization request to the client. If `MG_TRUE` is returned,
|
|
||||||
then Mongoose continues on with the request.
|
|
||||||
* `MG_REQUEST` - Mongoose asks event handler to serve the request. If
|
|
||||||
event handler serves the request by sending a reply,
|
|
||||||
it should return `MG_TRUE`. Otherwise,
|
|
||||||
it should return `MG_FALSE` which tells Mongoose that request is not
|
|
||||||
served and Mongoose should serve it. For example, event handler might
|
|
||||||
choose to serve only RESTful API requests with URIs that start with
|
|
||||||
certain prefix, and let Mongoose serve all static files.
|
|
||||||
If event handler decides to serve the request, but doesn't have
|
|
||||||
all the data at the moment, it should return `MG_MORE`. That tells
|
|
||||||
Mongoose to keep the connection open after callback returns.
|
|
||||||
|
|
||||||
`mg_connection::connection_param` pointer is a placeholder to keep
|
|
||||||
user-specific data. For example, handler could decide to open a DB
|
|
||||||
connection and store DB connection handle in `connection_param`.
|
|
||||||
* `MG_POLL` is sent to every connection on every iteration of
|
|
||||||
`mg_poll_server()`. Event handler should return `MG_FALSE` to ignore
|
|
||||||
this event. If event handler returns `MG_TRUE`, then Mongoose assumes
|
|
||||||
that event handler has finished sending data, and Mongoose will
|
|
||||||
close the connection.
|
|
||||||
* `MG_HTTP_ERROR` sent when Mongoose is about to send HTTP error back
|
|
||||||
to the client. Event handler can choose to send a reply itself, in which
|
|
||||||
case event handler must return `MG_TRUE`. Otherwise, event handler must
|
|
||||||
return `MG_FALSE`.
|
|
||||||
* `MG_CLOSE` is sent when the connection is closed. This event is used
|
|
||||||
to cleanup per-connection state stored in `connection_param`
|
|
||||||
if it was allocated. Event handler return value is ignored.
|
|
||||||
|
|
||||||
Sequence of events for the client connection is this:
|
|
||||||
|
|
||||||
* `MG_CONNECT` sent when Mongoose has connected to the remote host.
|
|
||||||
This event is sent to the connection initiated by `mg_connect()` call.
|
|
||||||
Connection status is held in `mg_connection::status_code`: if zero,
|
|
||||||
then connection was successful, otherwise connection was not established.
|
|
||||||
User should send a request upon successful connection.
|
|
||||||
Event handler should return `MG_TRUE` if connection was successful and
|
|
||||||
HTTP request has been sent. Otherwise, it should send `MG_FALSE`.
|
|
||||||
* `MG_REPLY` is sent when response has been received from the remote host.
|
|
||||||
If event handler sends another request, then it should return `MG_TRUE`.
|
|
||||||
Otherwise it should return `MG_FALSE` and Mongoose will close the connection.
|
|
||||||
* `MG_CLOSE` same as for the accepted connection.
|
|
||||||
|
|
||||||
|
|
||||||
When mongoose buffers in HTTP request and successfully parses it, it sends
|
|
||||||
`MG_REQUEST` event for GET requests immediately. For POST requests,
|
|
||||||
Mongoose delays the call until the whole POST request is buffered in memory.
|
|
||||||
POST data is available to the callback as `struct mg_connection::content`,
|
|
||||||
and POST data length is in `struct mg_connection::content_len`.
|
|
||||||
|
|
||||||
Note that websocket connections are treated the same way. Mongoose buffers
|
|
||||||
websocket frame in memory, and calls event handler when frame is fully
|
|
||||||
buffered. Frame data is available `struct mg_connection::content`, and
|
|
||||||
data length is in `struct mg_connection::content_len`, i.e. very similar to
|
|
||||||
the POST request. `struct mg_connection::is_websocket` flag indicates
|
|
||||||
whether the request is websocket or not. Also, for websocket requests,
|
|
||||||
there is `struct mg_connection::wsbits` field which contains first byte
|
|
||||||
of the websocket frame which URI handler can examine. Note that to
|
|
||||||
reply to the websocket client, `mg_websocket_write()` should be used.
|
|
||||||
To reply to the plain HTTP client, `mg_write_data()` should be used.
|
|
||||||
|
|
||||||
Return value: number of active connections.
|
|
||||||
|
|
||||||
|
|
||||||
const char **mg_get_valid_option_names(void);
|
|
||||||
|
|
||||||
Returns a NULL-terminated array of option names and their default values.
|
|
||||||
There are two entries per option in an array: an option name followed by a
|
|
||||||
default value. A default value could be NULL. A NULL name indicates an end
|
|
||||||
of the array.
|
|
||||||
|
|
||||||
const char *mg_get_option(const struct mg_server *server, const char *name);
|
|
||||||
|
|
||||||
Returns the value of particular configuration parameter. If
|
|
||||||
given parameter name is not valid, NULL is returned. For valid names, return
|
|
||||||
value is guaranteed to be non-NULL. If parameter is not set, zero-length string
|
|
||||||
is returned.
|
|
||||||
|
|
||||||
void mg_wakeup_server_ex(struct mg_server *, mg_handler_t func,
|
|
||||||
const char *fmt, ...);
|
|
||||||
|
|
||||||
Sends string message to a server. Function `func` is called for every active
|
|
||||||
connection. String message is passed in `struct mg_connection::callback_param`.
|
|
||||||
This function is designed to push data to the connected clients, and
|
|
||||||
can be called from any thread. There is a limitation on the length of
|
|
||||||
the message, currently at 8 kilobytes.
|
|
||||||
|
|
||||||
void mg_send_status(struct mg_connection *, int status_code);
|
|
||||||
void mg_send_header(struct mg_connection *, const char *name,
|
|
||||||
const char *value);
|
|
||||||
void mg_send_data(struct mg_connection *, const void *data, int data_len);
|
|
||||||
void mg_printf_data(struct mg_connection *, const char *format, ...);
|
|
||||||
|
|
||||||
These functions are used to construct a response to the client. HTTP response
|
|
||||||
consists of three parts: a status line, zero or more HTTP headers,
|
|
||||||
a response body. Mongoose provides functions for all three parts:
|
|
||||||
* `mg_send_status()` is used to create status line. This function can be
|
|
||||||
called zero or once. If `mg_send_status()` is not called, then Mongoose
|
|
||||||
will send status 200 (success) implicitly.
|
|
||||||
* `mg_send_header()` adds HTTP header to the response. This function could
|
|
||||||
be called zero or more times.
|
|
||||||
* `mg_send_data()` and `mg_printf_data()` are used to send data to the
|
|
||||||
client. Note that Mongoose adds `Transfer-Encoding: chunked` header
|
|
||||||
implicitly, and sends data in chunks. Therefore, it is not necessary to
|
|
||||||
set `Content-Length` header. Note that `mg_send_data()` and
|
|
||||||
`mg_printf_data()` do not send data immediately. Instead, they spool
|
|
||||||
data in memory, and Mongoose sends that data later after URI handler
|
|
||||||
returns. If data to be sent is huge, an URI handler might
|
|
||||||
send data in pieces by saving state in
|
|
||||||
`struct mg_connection::connection_param` variable and returning `0`. Then
|
|
||||||
Mongoose will call a handler repeatedly after each socket write.
|
|
||||||
|
|
||||||
<!-- -->
|
|
||||||
|
|
||||||
void mg_send_file(struct mg_connection *, const char *path);
|
|
||||||
|
|
||||||
Tells Mongoose to serve given file. Mongoose handles file according to
|
|
||||||
it's extensions, i.e. Mongoose will invoke CGI script if `path` has CGI
|
|
||||||
extension, it'll render SSI file if `path` has SSI extension, etc. If `path`
|
|
||||||
points to a directory, Mongoose will show directory listing. If this function
|
|
||||||
is used, no calls to `mg_send*` or `mg_printf*` functions must be made, and
|
|
||||||
event handler must return `MG_MORE`.
|
|
||||||
|
|
||||||
size_t mg_websocket_write(struct mg_connection* conn, int opcode,
|
|
||||||
const char *data, size_t data_len);
|
|
||||||
size_t mg_websocket_printf(struct mg_connection* conn, int opcode,
|
|
||||||
const char *fmt, ...);
|
|
||||||
|
|
||||||
|
|
||||||
Similar to `mg_write()` and `mg_printf()`, but wraps the data into a
|
|
||||||
websocket frame with a given websocket `opcode`.
|
|
||||||
|
|
||||||
const char *mg_get_header(const struct mg_connection *, const char *name);
|
|
||||||
|
|
||||||
Get the value of particular HTTP header. This is a helper function.
|
|
||||||
It traverses http_headers array, and if the header is present in the array,
|
|
||||||
returns its value. If it is not present, NULL is returned.
|
|
||||||
|
|
||||||
|
|
||||||
int mg_get_var(const struct mg_connection *conn, const char *var_name,
|
|
||||||
char *buf, size_t buf_len);
|
|
||||||
|
|
||||||
Gets HTTP form variable. Both POST buffer and query string are inspected.
|
|
||||||
Form variable is url-decoded and written to the buffer. On success, this
|
|
||||||
function returns the length of decoded variable. On error, -1 is returned if
|
|
||||||
variable not found, and -2 is returned if destination buffer is too small
|
|
||||||
to hold the variable. Destination buffer is guaranteed to be
|
|
||||||
'\0' - terminated if it is not NULL or zero length.
|
|
||||||
|
|
||||||
int mg_parse_header(const char *hdr, const char *var_name, char *buf,
|
|
||||||
size_t buf_size);
|
|
||||||
|
|
||||||
This function parses HTTP header and fetches given variable's value in a buffer.
|
|
||||||
A header should be like `x=123, y=345, z="other value"`. This function is
|
|
||||||
designed to parse Cookie headers, Authorization headers, and similar. Returns
|
|
||||||
the length of the fetched value, or 0 if variable not found.
|
|
||||||
|
|
||||||
int mg_modify_passwords_file(const char *passwords_file_name,
|
|
||||||
const char *domain,
|
|
||||||
const char *user,
|
|
||||||
const char *password);
|
|
||||||
|
|
||||||
Add, edit or delete the entry in the passwords file.
|
|
||||||
This function allows an application to manipulate .htpasswd files on the
|
|
||||||
fly by adding, deleting and changing user records. This is one of the
|
|
||||||
several ways of implementing authentication on the server side.
|
|
||||||
If password is not NULL, entry is added (or modified if already exists).
|
|
||||||
If password is NULL, entry is deleted.
|
|
||||||
Return: 1 on success, 0 on error.
|
|
||||||
|
|
||||||
|
|
||||||
int mg_parse_multipart(const char *buf, int buf_len,
|
|
||||||
char *var_name, int var_name_len,
|
|
||||||
char *file_name, int file_name_len,
|
|
||||||
const char **data, int *data_len);
|
|
||||||
|
|
||||||
Parses a buffer that contains multipart form data. Stores chunk name
|
|
||||||
in a `var_name` buffer. If chunk is an uploaded file, then `file_name`
|
|
||||||
will have a file name. `data` and `data_len` will point to the chunk data.
|
|
||||||
Returns number of bytes to skip to the next chunk.
|
|
||||||
|
|
||||||
struct mg_connection *mg_connect(struct mg_server *server,
|
|
||||||
const char *host, int port, int use_ssl);
|
|
||||||
|
|
||||||
Create connection to the remote host. Returns `NULL` on error, non-null
|
|
||||||
if the connection has been scheduled for connection. Upon a connection,
|
|
||||||
Mongoose will send `MG_CONNECT` event to the event handler.
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
# Mongoose Build on Android
|
|
||||||
|
|
||||||
This is a small guide to help you run mongoose on Android. Currently it is
|
|
||||||
tested on the HTC Wildfire. If you have managed to run it on other devices
|
|
||||||
as well, please comment or drop an email in the mailing list.
|
|
||||||
Note : You dont need root access to run mongoose on Android.
|
|
||||||
|
|
||||||
- Clone Mongoose Git repo
|
|
||||||
- Download the Android NDK from [http://developer.android.com/tools/sdk/ndk/index.html](http://developer.android.com/tools/sdk/ndk/index.html)
|
|
||||||
- Run `/path-to-ndk/ndk-build -C /path/to/mongoose`
|
|
||||||
That should generate mongoose/lib/armeabi/mongoose
|
|
||||||
- Using the adb tool (you need to have Android SDK installed for that),
|
|
||||||
push the generated mongoose binary to `/data/local` folder on device.
|
|
||||||
- From adb shell, navigate to `/data/local` and execute `./mongoose`.
|
|
||||||
- To test if the server is running fine, visit your web-browser and
|
|
||||||
navigate to `http://127.0.0.1:8080` You should see the `Index of /` page.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
Notes:
|
|
||||||
|
|
||||||
- `jni` stands for Java Native Interface. Read up on Android NDK if you want
|
|
||||||
to know how to interact with the native C functions of mongoose in Android
|
|
||||||
Java applications.
|
|
||||||
- TODO: A Java application that interacts with the native binary or a
|
|
||||||
shared library.
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
How To Create Basic Website With Mongoose
|
|
||||||
===========================================
|
|
||||||
|
|
||||||
## 1. Create a directory which will contain your website files. For example, on drive `C:\`, create a directory called `my_website`:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 2. Inside `my_website` directory, create a new file called "index". This will be the default web page shown when the website is visited.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 3. Open index file with your favorite editor (for example, Notepad) and enter some HTML code:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 4. Save this file as `index.html`:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## 5. Download Mongoose executable from http://cesanta.com/mongoose.shtml and copy the executable inside `my_website` directory:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 6. Double-click mongoose executable. An icon will appear on a system tray in the bottom right corner of the desktop:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 7. Click on the mongoose icon and choose "Go to my address" menu:
|
|
||||||

|
|
||||||
|
|
||||||
## 8. A browser will popup displaying `index.html` file. Now, you can expand your website by adding more content.
|
|
||||||
|
|
||||||

|
|
||||||
-173
@@ -1,173 +0,0 @@
|
|||||||
# Mongoose Embedding Guide
|
|
||||||
|
|
||||||
Embedding Mongoose is done in two steps:
|
|
||||||
|
|
||||||
1. Copy
|
|
||||||
[mongoose.c](https://raw.github.com/cesanta/mongoose/master/mongoose.c) and
|
|
||||||
[mongoose.h](https://raw.github.com/cesanta/mongoose/master/mongoose.h)
|
|
||||||
to your application's source tree and include them in the build.
|
|
||||||
2. Somewhere in the application code, call `mg_create_server()` to create
|
|
||||||
a server, configure it with `mg_set_option()` and loop with
|
|
||||||
`mg_poll_server()` until done. Call `mg_destroy_server()` to cleanup.
|
|
||||||
|
|
||||||
Here's a minimal application `app.c` that embeds mongoose:
|
|
||||||
|
|
||||||
#include "mongoose.h"
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
struct mg_server *server = mg_create_server(NULL, NULL);
|
|
||||||
mg_set_option(server, "document_root", "."); // Serve current directory
|
|
||||||
mg_set_option(server, "listening_port", "8080"); // Open port 8080
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
mg_poll_server(server, 1000); // Infinite loop, Ctrl-C to stop
|
|
||||||
}
|
|
||||||
mg_destroy_server(&server);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
To compile it, put `mongoose.c`, `mongoose.h` and `app.c` into one
|
|
||||||
folder, start terminal on UNIX or Visual Studio command line prompt on Windows,
|
|
||||||
and run the following command:
|
|
||||||
|
|
||||||
cc app.c mongoose.c -pthread -o app # on Unix
|
|
||||||
cl.exe app.c mongoose.c /TC /MD # on Windows
|
|
||||||
|
|
||||||
When run, this simple application opens port 8080 and serves static files,
|
|
||||||
CGI files and lists directory content in the current working directory.
|
|
||||||
|
|
||||||
It is possible to generate HTML page content. Mongoose can call user-defined
|
|
||||||
function when certain events occur.
|
|
||||||
That function is called _an event handler_, and it is the second parameter
|
|
||||||
to `mg_create_server()` function. Here is the example event handler function:
|
|
||||||
|
|
||||||
int event_handler(struct mg_connection *conn, enum mg_event ev) {
|
|
||||||
switch (ev) {
|
|
||||||
case MG_AUTH: return MG_TRUE;
|
|
||||||
default: return MG_FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Event handler is called by Mongoose with `struct mg_connection *`
|
|
||||||
pointer and an event number. `struct mg_connection *conn`
|
|
||||||
has all information about the request: HTTP headers, POST or websocket
|
|
||||||
data buffer, etcetera. `enum mg_event ev` tells which exactly event is sent.
|
|
||||||
For each event, an event handler returns a value which tells Mongoose how
|
|
||||||
to behave.
|
|
||||||
|
|
||||||
The sequence of events for every connection is this:
|
|
||||||
|
|
||||||
* `MG_AUTH` - Mongoose asks whether this connection is authorized. If event
|
|
||||||
handler returns `MG_FALSE`, then Mongoose does not serve the request but
|
|
||||||
sends authorization request to the client. If `MG_TRUE` is returned,
|
|
||||||
then Mongoose continues on with the request.
|
|
||||||
* `MG_REQUEST` - Mongoose asks event handler to serve the request. If
|
|
||||||
event handler serves the request by sending a reply,
|
|
||||||
it should return `MG_TRUE`. Otherwise,
|
|
||||||
it should return `MG_FALSE` which tells Mongoose that request is not
|
|
||||||
served and Mongoose should serve it. For example, event handler might
|
|
||||||
choose to serve only RESTful API requests with URIs that start with
|
|
||||||
certain prefix, and let Mongoose serve all static files.
|
|
||||||
If event handler decides to serve the request, but doesn't have
|
|
||||||
all the data at the moment, it should return `MG_MORE`. That tells
|
|
||||||
Mongoose to keep the connection open after callback returns.
|
|
||||||
|
|
||||||
`mg_connection::connection_param` pointer is a placeholder to keep
|
|
||||||
user-specific data. For example, handler could decide to open a DB
|
|
||||||
connection and store DB connection handle in `connection_param`.
|
|
||||||
* `MG_POLL` is sent to every connection on every iteration of
|
|
||||||
`mg_poll_server()`. Event handler should return `MG_FALSE` to ignore
|
|
||||||
this event. If event handler returns `MG_TRUE`, then Mongoose assumes
|
|
||||||
that event handler has finished sending data, and Mongoose will
|
|
||||||
close the connection.
|
|
||||||
* `MG_HTTP_ERROR` sent when Mongoose is about to send HTTP error back
|
|
||||||
to the client. Event handler can choose to send a reply itself, in which
|
|
||||||
case event handler must return `MG_TRUE`. Otherwise, event handler must
|
|
||||||
return `MG_FALSE`
|
|
||||||
* `MG_CLOSE` is sent when the connection is closed. This event is used
|
|
||||||
to cleanup per-connection state stored in `connection_param`
|
|
||||||
if it was allocated.
|
|
||||||
|
|
||||||
Let's extend our minimal application example and
|
|
||||||
create an URI that will be served by user's C code. The app will handle
|
|
||||||
`/hello` URI by showing a hello message. So, when app is run,
|
|
||||||
http://127.0.0.1:8080/hello will say hello, and here's the code:
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include "mongoose.h"
|
|
||||||
|
|
||||||
static int event_handler(struct mg_connection *conn, enum mg_event ev) {
|
|
||||||
if (ev == MG_AUTH) {
|
|
||||||
return MG_TRUE; // Authorize all requests
|
|
||||||
} else if (ev == MG_REQUEST && !strcmp(conn->uri, "/hello")) {
|
|
||||||
mg_printf_data(conn, "%s", "Hello world");
|
|
||||||
return MG_TRUE; // Mark as processed
|
|
||||||
} else {
|
|
||||||
return MG_FALSE; // Rest of the events are not processed
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void) {
|
|
||||||
struct mg_server *server = mg_create_server(NULL, event_handler);
|
|
||||||
mg_set_option(server, "document_root", ".");
|
|
||||||
mg_set_option(server, "listening_port", "8080");
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
mg_poll_server(server, 1000); // Infinite loop, Ctrl-C to stop
|
|
||||||
}
|
|
||||||
mg_destroy_server(&server);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
## Example code
|
|
||||||
|
|
||||||
Mongoose source code contains number of examples, located in the
|
|
||||||
[examples](https://github.com/cesanta/mongoose/blob/master/examples/) directory.
|
|
||||||
To build any example, go to the respective directory and run `make`.
|
|
||||||
|
|
||||||
## Compilation flags
|
|
||||||
|
|
||||||
Below is the list of compilation flags that enable or disable certain
|
|
||||||
features. By default, some features are enabled, and could be disabled
|
|
||||||
by setting appropriate `NO_*` flag. Features that are disabled by default
|
|
||||||
could be enabled by setting appropriate `USE_*` flag. Bare bones Mongoose
|
|
||||||
is quite small, about 30 kilobytes of compiled x86 code. Each feature adds
|
|
||||||
a couple of kilobytes to the executable size, and also has some runtime penalty.
|
|
||||||
|
|
||||||
Note that some flags start with `NS_` prefix. This is because Mongoose uses
|
|
||||||
[Net Skeleton](http://github.com/cesanta/net_skeleton) as a low-level
|
|
||||||
networking engine. If user code has `#include <net_skeleton.h>`, then
|
|
||||||
all Net Skeleton functions will be available too.
|
|
||||||
|
|
||||||
|
|
||||||
-DMONGOOSE_NO_AUTH Disable MD5 authorization support
|
|
||||||
-DMONGOOSE_NO_CGI Disable CGI support
|
|
||||||
-DMONGOOSE_NO_DAV Disable WebDAV support
|
|
||||||
(PUT, DELETE, MKCOL, PROPFIND methods)
|
|
||||||
-DMONGOOSE_NO_DIRECTORY_LISTING Disable directory listing
|
|
||||||
-DMONGOOSE_NO_FILESYSTEM Disables all file IO, serving from memory only
|
|
||||||
-DMONGOOSE_NO_LOGGING Disable access/error logging
|
|
||||||
-DMONGOOSE_ENABLE_THREADS Enable mg_start_thread() function
|
|
||||||
-DMONGOOSE_NO_WEBSOCKET Disable WebSocket support
|
|
||||||
-DMONGOOSE_NO_USER No concept of a user on used platform.
|
|
||||||
(Platform does not provide getpwnam, setgid or setuid)
|
|
||||||
|
|
||||||
-DMONGOOSE_USE_IDLE_TIMEOUT_SECONDS=X Idle connection timeout, default is 30
|
|
||||||
-DMONGOOSE_USE_LUA Enable Lua scripting
|
|
||||||
-DMONGOOSE_USE_LUA_SQLITE3 Enable sqlite3 binding for Lua
|
|
||||||
-DMONGOOSE_USE_POST_SIZE_LIMIT=X POST requests larger than X will be
|
|
||||||
rejected, not set by default
|
|
||||||
-DMONGOOSE_USE_EXTRA_HTTP_HEADERS=X Append X to the HTTP headers
|
|
||||||
for static files, empty by default
|
|
||||||
|
|
||||||
-DNS_ENABLE_DEBUG Enables debug messages on stdout, very noisy
|
|
||||||
-DNS_ENABLE_SSL Enable SSL
|
|
||||||
-DNS_ENABLE_IPV6 Enable IPv6 support
|
|
||||||
-DNS_ENABLE_HEXDUMP Enables hexdump of sent and received traffic
|
|
||||||
-DNS_STACK_SIZE=X Sets stack size to X for ns_start_thread()
|
|
||||||
-DNS_DISABLE_THREADS Disable threads support
|
|
||||||
-DNS_DISABLE_SOCKETPAIR For systems without loopback interface
|
|
||||||
-DMONGOOSE_SEND_NS_EVENTS Send Net Skeleton events to the event handler
|
|
||||||
in addition to the Mongoose events
|
|
||||||
-45
@@ -1,45 +0,0 @@
|
|||||||
# Mongoose FAQ
|
|
||||||
|
|
||||||
## My Antivirus Software reports Mongoose as a security threat
|
|
||||||
|
|
||||||
Mongoose doesn't contain any malicious logic. Antivirus reports a
|
|
||||||
[false positive](http://en.wikipedia.org/wiki/Type_I_and_type_II_errors#False_positive_error).
|
|
||||||
This is when certain byte sequence in Mongoose accidentally matches
|
|
||||||
virus signature in the Antivirus database.
|
|
||||||
|
|
||||||
## Download page doesn't work
|
|
||||||
|
|
||||||
Please make sure Javascript is enabled in your browser, and that the
|
|
||||||
antivirus software is not blocking the download.
|
|
||||||
|
|
||||||
|
|
||||||
## MacOS message: "Mongoose.app is damaged and can’t be opened. You should move it to the Trash"
|
|
||||||
|
|
||||||
This happens on newer MacOS systems. The reason for the message
|
|
||||||
is the fact Mongoose.app is not digitally signed.
|
|
||||||
Mongoose download procedure changes the app on the fly by injecting
|
|
||||||
user information in the binary, making any prior digital signature void.
|
|
||||||
Open "System Preferences" -> "Security" and set "Allow apps downloaded from"
|
|
||||||
to "Anywhere". Revert the settings once Mongoose is installed.
|
|
||||||
|
|
||||||
## PHP doesn't work: getting empty page, or 'File not found' error
|
|
||||||
|
|
||||||
The reason for that is wrong paths to the interpreter. Remember that with PHP,
|
|
||||||
correct interpreter is `php-cgi.exe` (`php-cgi` on UNIX). Solution: specify
|
|
||||||
full path to the PHP interpreter, e.g.:
|
|
||||||
|
|
||||||
mongoose -cgi_interpreter /full/path/to/php-cgi
|
|
||||||
|
|
||||||
## Mongoose fails to start
|
|
||||||
|
|
||||||
If Mongoose exits immediately when run, this
|
|
||||||
usually indicates a syntax error in the configuration file
|
|
||||||
(named `mongoose.conf` by default) or the command-line arguments.
|
|
||||||
Syntax checking is omitted from Mongoose to keep its size low. However,
|
|
||||||
the Manual should be of help. Note: the syntax changes from time to time,
|
|
||||||
so updating the config file might be necessary after executable update.
|
|
||||||
|
|
||||||
### Embedding with OpenSSL on Windows might fail because of calling convention
|
|
||||||
|
|
||||||
To force Mongoose to use `__stdcall` convention, add `/Gz` compilation
|
|
||||||
flag to the Visual Studio project settings.
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
How To Share Files With Mongoose
|
|
||||||
===========================================
|
|
||||||
|
|
||||||
## 1. Download Mongoose executable from http://cesanta.com/mongoose.shtml and copy the executable inside the directory you want to share:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 2. Double-click mongoose executable. A browser will start automatically, an icon will appear on a system tray in the bottom right corner of the desktop:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 3. Click on the mongoose icon
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## 4. Click on "Go to my address" to launch a browser locally. Or, to access a folder from another machine, launch a browser and type in the URL:
|
|
||||||
|
|
||||||

|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
# Mongoose Internals
|
|
||||||
|
|
||||||
Mongoose has single-threaded, event-driven, asynchronous, non-blocking core.
|
|
||||||
`mg_create_server()` creates a web server instance. An instance is a container
|
|
||||||
for the config options and list of active connections. To do the actual
|
|
||||||
serving, user must call `mg_poll_server()`, which iterates over all
|
|
||||||
active connections, performing `select()` syscall on all sockets with a
|
|
||||||
timeout of specified number of milliseconds. When `select()` returns, Mongoose
|
|
||||||
does an IO for each socket that has data to be sent or received. Application
|
|
||||||
code must call `mg_poll_server()` in a loop.
|
|
||||||
|
|
||||||
Mongoose server instance is designed to be used by a single thread.
|
|
||||||
It is an error to have more then
|
|
||||||
one thread calling `mg_poll_server()`, `mg_set_option()` or any other function
|
|
||||||
that take `struct mg_server *` parameter. Mongoose does not
|
|
||||||
mutex-protect `struct mg_server *`, therefore the best practice is
|
|
||||||
to call server management functions from the same thread (an IO thread).
|
|
||||||
On a multi-core systems, many server instances can be created, sharing the
|
|
||||||
same listening socket and managed by separate threads (see [multi_threaded.c](https://github.com/cesanta/mongoose/blob/master/examples/multi_threaded.c))
|
|
||||||
example.
|
|
||||||
|
|
||||||
It is an error to pass and store `struct mg_connection *` pointers for
|
|
||||||
later use to send data. The reason is that they can be invalidated by the
|
|
||||||
next `mg_poll_server()` call. For such a task,
|
|
||||||
there is `mg_iterate_over_connections()` API
|
|
||||||
exists, which sends a callback function to the IO thread, then IO thread
|
|
||||||
calls specified function for all active connection.
|
|
||||||
|
|
||||||
When mongoose buffers in HTTP request and successfully parses it, it calls
|
|
||||||
appropriate URI handler immediately for GET requests. For POST requests,
|
|
||||||
Mongoose delays the call until the whole POST request is buffered in memory.
|
|
||||||
POST data is available to the callback as `struct mg_connection::content`,
|
|
||||||
and POST data length is in `struct mg_connection::content_len`.
|
|
||||||
|
|
||||||
Note that websocket connections are treated the same way. Mongoose buffers
|
|
||||||
websocket frame in memory, and calls URI handler when frame is fully
|
|
||||||
buffered. Frame data is available `struct mg_connection::content`, and
|
|
||||||
data length is in `struct mg_connection::content_len`, i.e. very similar to
|
|
||||||
the POST request. `struct mg_connection::is_websocket` flag indicates
|
|
||||||
whether the request is websocket or not. Also, for websocket requests,
|
|
||||||
there is `struct mg_connection::wsbits` field which contains first byte
|
|
||||||
of the websocket frame which URI handler can examine. Note that to
|
|
||||||
reply to the websocket client, `mg_websocket_write()` should be used.
|
|
||||||
To reply to the plain HTTP client, `mg_write()` should be used.
|
|
||||||
-154
@@ -1,154 +0,0 @@
|
|||||||
# Mongoose Configuration Options
|
|
||||||
|
|
||||||
### access\_control\_list
|
|
||||||
An Access Control List (ACL) allows restrictions to be put on the list of IP
|
|
||||||
addresses which have access to the web server. In the case of the Mongoose
|
|
||||||
web server, the ACL is a comma separated list of IP subnets, where each
|
|
||||||
subnet is prepended by either a `-` or a `+` sign. A plus sign means allow,
|
|
||||||
where a minus sign means deny. If a subnet mask is omitted, such as `-1.2.3.4`,
|
|
||||||
this means to deny only that single IP address.
|
|
||||||
|
|
||||||
Subnet masks may vary from 0 to 32, inclusive. The default setting is to allow
|
|
||||||
all accesses. On each request the full list is traversed, and
|
|
||||||
the last match wins. Example: `$ mongoose -access_control_list -0.0.0.0/0,+192.168/16` to deny all acccesses except those from `192.168/16` subnet. Note that if the option is set, then all accesses are forbidden
|
|
||||||
by default. Thus in a previous example, `-0.0.0.0` part is not necessary.
|
|
||||||
For example, `$mongoose access_control_list +10.0.0.0/8`
|
|
||||||
means disallow all, allow subnet 10/8 only.
|
|
||||||
|
|
||||||
To learn more about subnet masks, see the
|
|
||||||
[Wikipedia page on Subnetwork](http://en.wikipedia.org/wiki/Subnetwork)
|
|
||||||
|
|
||||||
Default: not set, all accesses are allowed.
|
|
||||||
|
|
||||||
### access\_log\_file
|
|
||||||
Path to a file for access logs. Either full path, or relative to the
|
|
||||||
mongoose executable. Default: not set, no query logging is done.
|
|
||||||
|
|
||||||
### auth_domain
|
|
||||||
Authorization realm used in `.htpasswd` authorization. Default: `mydomain.com`
|
|
||||||
|
|
||||||
### cgi_interpreter
|
|
||||||
Path to an executable to be used use as an interpreter for __all__ CGI scripts
|
|
||||||
regardless script extension. Default: not set, Mongoose looks at
|
|
||||||
[shebang line](http://en.wikipedia.org/wiki/Shebang_(Unix\).
|
|
||||||
|
|
||||||
For example, if both PHP and perl CGIs are used, then
|
|
||||||
`#!/path/to/php-cgi.exe` and `#!/path/to/perl.exe` must be first lines of the
|
|
||||||
respective CGI scripts. Note that paths should be either full file paths,
|
|
||||||
or file paths relative to the directory where mongoose executable is located.
|
|
||||||
|
|
||||||
If all CGIs use the same interpreter, for example they are all PHP, then
|
|
||||||
`cgi_interpreter` option can be set to the path to `php-cgi.exe` executable and
|
|
||||||
shebang line in the CGI scripts can be omitted.
|
|
||||||
**Note**: PHP scripts must use `php-cgi.exe`, not `php.exe`.
|
|
||||||
|
|
||||||
### cgi_pattern
|
|
||||||
All files that match `cgi_pattern` are treated as CGI files. Default pattern
|
|
||||||
allows CGI files be anywhere. To restrict CGIs to a certain directory,
|
|
||||||
use `/path/to/cgi-bin/**.cgi` as a pattern. Note that **full file path** is
|
|
||||||
matched against the pattern, not the URI.
|
|
||||||
|
|
||||||
When Mongoose starts CGI program, it creates new environment for it (in
|
|
||||||
contrast, usually child program inherits the environment from parent). Several
|
|
||||||
environment variables however are inherited from Mongoose's environment,
|
|
||||||
they are: `PATH`, `TMP`, `TEMP`, `TMPDIR`, `PERLLIB`, `MONGOOSE_CGI`. On UNIX
|
|
||||||
it is also `LD_LIBRARY_PATH`. On Windows it is also `COMSPEC`, `SYSTEMROOT`,
|
|
||||||
`SystemDrive`, `ProgramFiles`, `ProgramFiles(x86)`, `CommonProgramFiles(x86)`.
|
|
||||||
|
|
||||||
Default: `**.cgi$|**.pl$|**.php$`
|
|
||||||
|
|
||||||
### dav\_auth\_file
|
|
||||||
Authentication file for WebDAV mutation requests: `PUT`, `DELETE`, `MKCOL`.
|
|
||||||
The format of that file is the same as for the `.htpasswd` file
|
|
||||||
used for digest authentication. It can be created and managed by
|
|
||||||
`mongoose -A` command. Default: not set, WebDAV mutations are disallowed.
|
|
||||||
|
|
||||||
### document_root
|
|
||||||
A directory to serve. Default: current working directory.
|
|
||||||
|
|
||||||
### enable\_directory\_listing
|
|
||||||
Enable directory listing, either `yes` or `no`. Default: `yes`.
|
|
||||||
|
|
||||||
### enable\_proxy
|
|
||||||
Enable proxy functionality, either `yes` or `no`. If set to `yes`, then
|
|
||||||
browsers can be configured to use Mongoose as a proxy. Default: `no`.
|
|
||||||
|
|
||||||
|
|
||||||
### extra\_mime\_types
|
|
||||||
Extra mime types to recognize, in form `extension1=type1,extension2=type2,...`.
|
|
||||||
Extension must include dot. Example:
|
|
||||||
`mongoose -extra_mime_types .cpp=plain/text,.java=plain/text`. Default: not set.
|
|
||||||
|
|
||||||
|
|
||||||
### global\_auth\_file
|
|
||||||
Path to a global passwords file, either full path or relative to the mongoose
|
|
||||||
executable. If set, per-directory `.htpasswd` files are ignored,
|
|
||||||
and all requests are authorised against that file. Use `mongoose -A` to
|
|
||||||
manage passwords, or third party utilities like
|
|
||||||
[htpasswd-generator](http://www.askapache.com/online-tools/htpasswd-generator).
|
|
||||||
Default: not set, per-directory `.htpasswd` files are respected.
|
|
||||||
|
|
||||||
### hide\_files\_patterns
|
|
||||||
A pattern for the files to hide. Files that match the pattern will not
|
|
||||||
show up in directory listing and return `404 Not Found` if requested. Pattern
|
|
||||||
must be for a file name only, not including directory name, e.g.
|
|
||||||
`mongoose -hide_files_patterns secret.txt|even_more_secret.txt`. Default:
|
|
||||||
not set.
|
|
||||||
|
|
||||||
### index_files
|
|
||||||
Comma-separated list of files to be treated as directory index
|
|
||||||
files. Default: `index.html,index.htm,index.cgi,index.shtml,index.php`
|
|
||||||
|
|
||||||
### listening_port
|
|
||||||
Port to listen on. Port could be prepended by the specific IP address to bind
|
|
||||||
to, e.g. `mongoose -listening_port 127.0.0.1:8080`. Otherwise Mongoose
|
|
||||||
will bind to all addresses. To enable SSL, build Mongoose with
|
|
||||||
`-DNS_ENABLE_SSL` compilation option, and specify `listening_port` as
|
|
||||||
`ssl://PORT:SSL_CERTIFICATE.PEM`. Example SSL listener:
|
|
||||||
`mongoose -listening_port ssl://8043:ssl_cert.pem`. Note that PEM file should
|
|
||||||
be in PEM format, and must have both certificate and private key in it,
|
|
||||||
concatenated together. More than one listening port can be specified,
|
|
||||||
separated by comma,
|
|
||||||
for example `mongoose -listening_port 8080,8000`. Default: 8080.
|
|
||||||
|
|
||||||
### run\_as\_user
|
|
||||||
Switch to given user credentials after startup. UNIX-only. This option is
|
|
||||||
required when mongoose needs to bind on privileged port on UNIX, e.g.
|
|
||||||
|
|
||||||
$ sudo mongoose -listening_port 80 -run_as_user nobody
|
|
||||||
|
|
||||||
Default: not set.
|
|
||||||
|
|
||||||
### url\_rewrites
|
|
||||||
Comma-separated list of URL rewrites in the form of
|
|
||||||
`uri_pattern=file_or_directory_path`. When Mongoose receives the request,
|
|
||||||
it constructs the file name to show by combining `document_root` and the URI.
|
|
||||||
However, if the rewrite option is used and `uri_pattern` matches the
|
|
||||||
requested URI, then `document_root` is ignored. Instead,
|
|
||||||
`file_or_directory_path` is used, which should be a full path name or
|
|
||||||
a path relative to the web server's current working directory. Note that
|
|
||||||
`uri_pattern`, as all mongoose patterns, is a prefix pattern. If `uri_pattern`
|
|
||||||
is a number, then it is treated as HTTP error code, and `file_or_directory_path`
|
|
||||||
should be an URI to redirect to. Mongoose will issue `302` temporary redirect
|
|
||||||
to the specified URI with following parameters:
|
|
||||||
`?code=HTTP_ERROR_CODE&orig_uri=ORIGINAL_URI&query_string=QUERY_STRING`.
|
|
||||||
|
|
||||||
If `uri_pattern` starts with `@` symbol, then Mongoose compares
|
|
||||||
it with the `HOST` header of the request. If they are equal, Mongoose sets
|
|
||||||
document root to `file_or_directory_path`, implementing virtual hosts support.
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
# Redirect all accesses to `.doc` files to a special script
|
|
||||||
mongoose -url_rewrites **.doc$=/path/to/cgi-bin/handle_doc.cgi
|
|
||||||
|
|
||||||
# Implement user home directories support
|
|
||||||
mongoose -url_rewrites /~joe/=/home/joe/,/~bill=/home/bill/
|
|
||||||
|
|
||||||
# Redirect 404 errors to a specific error page
|
|
||||||
mongoose -url_rewrites 404=/cgi-bin/error.cgi
|
|
||||||
|
|
||||||
# Virtual hosts example: serve foo.com domain from different directory
|
|
||||||
mongoose -url_rewrites @foo.com=/var/www/foo.com
|
|
||||||
|
|
||||||
Default: not set.
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
How To Create A PHP Website With Mongoose
|
|
||||||
===========================================
|
|
||||||
|
|
||||||
## 1. Create a directory which will contain your website files. For example, on drive `C:\`, create a directory called `my_website`:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 2. Inside `my_website` directory, create a new file called "index". This will be the default web page shown when the website is visited.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 3. Open index file with your favorite editor (for example, Notepad) and enter some HTML / PHP code:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 4. Save this file as `index.php`:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## 5. Download Mongoose executable from http://cesanta.com/mongoose.shtml and copy the executable inside `my_website` directory:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 6. Double-click mongoose executable. An icon will appear on a system tray in the bottom right corner of the desktop:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 7. Download PHP 5.3 zip (do NOT download PHP 5.5 cause you might have missing DLLs problem) from http://windows.php.net/download and extract it to `C:\php5` directory:
|
|
||||||

|
|
||||||
|
|
||||||
## 8. Click on the mongoose icon and choose "Edit Settings" menu.:
|
|
||||||

|
|
||||||
|
|
||||||
## 9. A settings dialog will appear. Click on `cgi_interpreter` button:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 10. Choose `C:\php5\php-cgi.exe` and click "Save Settings":
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
## 11. Click on the mongoose icon and choose "Go to my address" menu:
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
## 12. A browser will popup displaying `index.php`.
|
|
||||||
|
|
||||||

|
|
||||||
@@ -1,218 +0,0 @@
|
|||||||
# Mongoose Release Notes
|
|
||||||
|
|
||||||
## Release 5.6, 2015-03-17
|
|
||||||
|
|
||||||
Changes in Libmongoose library:
|
|
||||||
|
|
||||||
- Added `-dav_root` configuration option that gives an ability to mount
|
|
||||||
a different root directory (not document_root)
|
|
||||||
- Fixes for build under Win23 and MinGW
|
|
||||||
- Bugfix: Double dots removal
|
|
||||||
- Bugfix: final chunked response double-send
|
|
||||||
- Fixed compilation in 64-bit environments
|
|
||||||
- Added OS/2 compatibility
|
|
||||||
- Added `getaddrinfo()` call and `NS_ENABLE_GETADDRINFO`
|
|
||||||
- Various SSL-related fixes
|
|
||||||
- Added integer overflow protection in `iobuf_append()` and `deliver_websocket_frame()`
|
|
||||||
- Fixed NetBSD build
|
|
||||||
- Enabled `NS_ENABLE_IPV6` build for Visual Studio 2008+
|
|
||||||
- Enhanced comma detection in `parse_header()`
|
|
||||||
- Fixed unchanged memory accesses on ARM
|
|
||||||
- Added ability to use custom memory allocator through NS_MALLOC, NS_FREE, NS_REALLOC
|
|
||||||
|
|
||||||
Changes in Mongoose binary:
|
|
||||||
|
|
||||||
- Added `-start_browser` option to disable automatic browser launch
|
|
||||||
- Added experimental SSL support. To listen on HTTPS port, use `ssl://PORT:SSL_CERT` format. For example, to listen on HTTP port 8080 and HTTPS port 8043, use `-listening_port 8080,ssl://8043:ssl_cert.pem`
|
|
||||||
|
|
||||||
## Release 5.5, October 28 2014
|
|
||||||
|
|
||||||
Changes in Libmongoose library:
|
|
||||||
|
|
||||||
- Added new API function: `mg_forward()` for proxying functionality
|
|
||||||
- Added new API function: `mg_send_file_data()` for sending file data
|
|
||||||
- Added new utility API functions: `mg_mmap() and mg_munmap()`
|
|
||||||
- Changed the way SSL settings are handled: removed `ssl_certificate` and
|
|
||||||
`ssl_ca_certificate` options, and instead made `listening_port` accept
|
|
||||||
`ssl://PORT:SSL_CERT:CA_CERT` notation
|
|
||||||
- Added ability to listen on multiple ports, see `listening_port` documentation
|
|
||||||
- Added `enable_proxy` option
|
|
||||||
- Added [cookie_authentication](https://github.com/cesanta/mongoose/tree/master/examples/cookie_authentication) example
|
|
||||||
- Added [websocket\_ssl\_proxy](https://github.com/cesanta/mongoose/tree/master/examples/websocket_ssl_proxy) example
|
|
||||||
- Added [http_client](https://github.com/cesanta/mongoose/tree/master/examples/http_client) example
|
|
||||||
- Increased default 'idle connection' timeout from 30 to 300 seconds
|
|
||||||
- Fixed MinGW build
|
|
||||||
- Refactored all examples, put each in it's own directory with dedicated build
|
|
||||||
- Many smaller bugfixed, including SSL, CGI, API, proxy, etc
|
|
||||||
|
|
||||||
Changes in pre-compiled binaries:
|
|
||||||
|
|
||||||
- Support for multiple listening ports
|
|
||||||
- Fixed CGI handling for scripts that specify interpreter in the hashbang line
|
|
||||||
|
|
||||||
## Release 5.4, July 28 2014
|
|
||||||
|
|
||||||
Changes in Libmongoose library:
|
|
||||||
|
|
||||||
- Added `hexdump_file` option for low-level request/reply debugging
|
|
||||||
- Added `mg_template()` API function for generating HTML pages from
|
|
||||||
templates with expansions
|
|
||||||
- Fixed `struct mg_connection::local_ip` handling, `mg_set_option()`
|
|
||||||
behavior with NULL values
|
|
||||||
- Added `mg_send_file()` call to send arbitrary file to the client
|
|
||||||
- Added `mg_terminate_ssl()` for SSL termination functionality
|
|
||||||
- Added HTTP proxy support, `enable_proxy` config option
|
|
||||||
- Added `mg_next()` for iterating over existing active connections
|
|
||||||
- Added client-side SSL auth, `ssl_ca_certificate` option
|
|
||||||
- Added `mg_wakeup_server_ex()` for pushing messages to existing connections
|
|
||||||
- Added `MG_WS_HANDSHAKE` and `MG_WS_CONNECT` events that are sent on
|
|
||||||
Websocket handshake is connection establishment, respectively
|
|
||||||
- Removed server-side Lua support
|
|
||||||
- Filesystem access, reading from socket/SSL performance improvements
|
|
||||||
- DAV PROPFIND memory leak fixed
|
|
||||||
- Added `big_upload.c` and enhanced `upload.c` example
|
|
||||||
- Added `proxy.c` example that demonstrates proxy functionality and SSE pushes
|
|
||||||
- Added `websocket2.c` example that shows simple web chat implementation
|
|
||||||
over websockets
|
|
||||||
- Various minor fixes
|
|
||||||
|
|
||||||
|
|
||||||
Changes in pre-compiled binaries:
|
|
||||||
|
|
||||||
- Created HTML administration console
|
|
||||||
- When server is started, browser is started automatically
|
|
||||||
- Fixed directory listing bug when directory contains `#` character
|
|
||||||
- Removed built-in Lua Server Pages in the binary, and instead
|
|
||||||
added Mongoose + Lua developer bundle which has Lua Server Pages support.
|
|
||||||
That also solves external Lua modules loading problem.
|
|
||||||
|
|
||||||
|
|
||||||
## Release 5.3, March 10 2014
|
|
||||||
|
|
||||||
Changes in Libmongoose library:
|
|
||||||
|
|
||||||
* Moved to the evented API. Updated API documentation is at
|
|
||||||
http://cesanta.com/docs/Embed.shtml
|
|
||||||
http://cesanta.com/docs/API.shtml
|
|
||||||
* Added `MG_LUA` event for exporting custom variables to the Lua environment
|
|
||||||
* Added virtual hosts capability, see `url_rewrites` option description at
|
|
||||||
http://cesanta.com/docs/Options.shtml
|
|
||||||
* Added mjpg serving example
|
|
||||||
* Cleaned up and documented HTTP client API, with unit tests
|
|
||||||
* Added `mg_wakeup_server()` to awaken `mg_poll_server()`
|
|
||||||
from another thread
|
|
||||||
* Moved Mongoose IO core to [https://github.com/cesanta/net_skeleton](Net Skeleton)
|
|
||||||
* Added connection hexdump functionality for developers
|
|
||||||
* Bug fixes
|
|
||||||
|
|
||||||
Changes in pre-compiled binaries:
|
|
||||||
|
|
||||||
* New awesome Mongoose logos by our designer Katrin - thanks Katrin!
|
|
||||||
Check them out at http://cesanta.com/products.shtml
|
|
||||||
* Added Lua Server Pages support to the free version, quick intro is at
|
|
||||||
http://cesanta.com/docs/Lua.shtml
|
|
||||||
* Added quick "Set shared directory" menu item to set `document_root`
|
|
||||||
* Added SSI support to the Pro version
|
|
||||||
* Removed SSL support from the Pro version
|
|
||||||
|
|
||||||
## Release 5.2, Feb 1 2014
|
|
||||||
|
|
||||||
* Windows binary made fully UNICODE aware. In previous versions,
|
|
||||||
the presence of non-ASCII chars in document root, CGI script name,
|
|
||||||
or directory name might have broken Mongoose as stand-alone
|
|
||||||
or as Windows service. Now Mongoose works with non-ASCII paths properly.
|
|
||||||
Internally, Mongoose uses UTF8 encoding. When making WinAPI calls,
|
|
||||||
mongoose converts UTF8 strings to wide chars and calls UNICODE API.
|
|
||||||
* Enhanced authorization API by providing `mg_set_auth_handler()` and
|
|
||||||
`mg_authorize_digest()`
|
|
||||||
* Removed `mg_add_uri_handler()`, added `mg_set_request_handler()`.
|
|
||||||
There is only oneURI handler that handles all requests, just like in 4.x.
|
|
||||||
The reason for this change is to provide an ability to catch all URIs,
|
|
||||||
and at the same time signal Mongoose to continue handling specific URIs.
|
|
||||||
* Added `mg_parse_multipart()` API for file uploads.
|
|
||||||
Note that the restriction on uploading huge files still exists,
|
|
||||||
and will be eliminated in the next release.
|
|
||||||
* Allowing mongoose to bind to port 0, in which case it'll bind to any
|
|
||||||
random unused port.
|
|
||||||
* Moved `idle_timeout_ms` run-time option to compile-time flag
|
|
||||||
* Added asynchronous HTTP client, not documented yet. Documentation and
|
|
||||||
examples are coming in the next couple of weeks. Async Websocket client
|
|
||||||
is scheduled for the next release. See usage examples at `unit_test.c`
|
|
||||||
* Windows and MacOS pre-built binaries are now split to free and paid ones,
|
|
||||||
paid binaries include CGI, SSL, Lua, Sqlite, support and updates.
|
|
||||||
Linux pre-built binary includes all functionality and is free, and will
|
|
||||||
continue to be free. Source code for Windows and MacOS GUI is closed.
|
|
||||||
Disclaimer: source code for the command line stand-alone server,
|
|
||||||
as well as Mongoose library itself, will never be closed.
|
|
||||||
* Multiple bug fixes and minor enhancements
|
|
||||||
|
|
||||||
## Release 5.1, Jan 10 2014
|
|
||||||
|
|
||||||
* CGI-related bugs where fixed, primarily for Windows platform
|
|
||||||
* Bugs on Windows related to UNICODE support were fixed
|
|
||||||
* Added a feature to support "error pages" through redirect.
|
|
||||||
Done using `-url_redirects` option, details are on
|
|
||||||
http://cesanta.com/docs/Options.shtml
|
|
||||||
|
|
||||||
## Release 5.0, Jan 6 2014
|
|
||||||
|
|
||||||
* Internal core has been changed from blocking, thread-per-connection to
|
|
||||||
non-blocking, asynchronous, one thread for all.
|
|
||||||
* API modification for server creation and response creation. That allowed
|
|
||||||
keep-alive support for dynamic requests, boosting the embedded performance
|
|
||||||
to 100+ thousands requests per second on a single core
|
|
||||||
(as measured on my development MacBook laptop)
|
|
||||||
* Unified handling of POST requests and Websocket requests by putting a
|
|
||||||
payload into `conn->content`, `conn->content_len` attributes.
|
|
||||||
That simplified user code and eliminated the need of `mg_read()`,
|
|
||||||
since mongoose buffers all data prior to calling the callback
|
|
||||||
* keep-alive support is the default
|
|
||||||
* Dropped SSI support and throttling support
|
|
||||||
* Several configuraition parameters are gone:
|
|
||||||
* `cgi_environment` (replaced with MONGOOSE_CGI),
|
|
||||||
* `protect_uri` (not useful)
|
|
||||||
* `ssi_pattern` (SSI support is gone)
|
|
||||||
* `throttle` (throttling support is gone)
|
|
||||||
* `error_log_file` (not used)
|
|
||||||
* `enable_keep_alive` (enabled by default)
|
|
||||||
* `listening_ports` (renamed to listening_port)
|
|
||||||
* `num_threads` (core has changed to single thread)
|
|
||||||
* `put_delete_auth_file` (renamed to dav_auth_file)
|
|
||||||
* `authentication_domain` (renamed to auth_domain)
|
|
||||||
* Due to the async, non-blocking nature of the core, few restrictions
|
|
||||||
are now in place:
|
|
||||||
* user callbacks must not block
|
|
||||||
* POST and Websocket data are now buffered, and cannot be huge
|
|
||||||
* mongoose is now capable on listening on only one port
|
|
||||||
|
|
||||||
## Release 4.1, Oct 2013
|
|
||||||
## Release 4.0, Oct 2013
|
|
||||||
## Release 3.8, Sep 2013
|
|
||||||
|
|
||||||
## Release 3.7, Feb 2 2013
|
|
||||||
|
|
||||||
* Added "redirect to SSL port" functionality, e.g. if you specify
|
|
||||||
`-listening_ports 8080r,8043s`
|
|
||||||
then all requests to HTTP port 8080 will be redirected to HTTPS port 8043
|
|
||||||
* Added `mg_download()` API, an HTTP client interface!
|
|
||||||
* Lua server pages now must output HTTP headers -- full control for Lua
|
|
||||||
* Added pre-built binary for MacOS, with initial GUI support
|
|
||||||
* API change: got rid of events, moved to struct `mg_callbacks`
|
|
||||||
* Bugfixes, thanks to contributors
|
|
||||||
|
|
||||||
|
|
||||||
## Release 3.7, Jan 18 2013
|
|
||||||
* Fixed source code archive (main.c was missing)
|
|
||||||
* Extended Windows GUI functionality:
|
|
||||||
* Added "Start browser" systray popup menu item
|
|
||||||
* Enhanced configuration editor
|
|
||||||
* Renamed config options:
|
|
||||||
* `put_delete_passwords_file` -> `put_delete_auth_file`
|
|
||||||
* `global_passwords_file` -> `global_auth_file`
|
|
||||||
* `select()` changed to `poll()`, to avoid big file descriptor
|
|
||||||
`FD_SET` problem on UNIX
|
|
||||||
* Couple of bugfixes, thanks to contributors
|
|
||||||
|
|
||||||
|
|
||||||
Eearlier release notes could be found by searching
|
|
||||||
[Mongoose mailing list](https://groups.google.com/forum/#!forum/mongoose-users)
|
|
||||||
-70
@@ -1,70 +0,0 @@
|
|||||||
# Mongoose SSL guide
|
|
||||||
|
|
||||||
SSL is a protocol that makes web communication secure. To enable SSL
|
|
||||||
in mongoose, 2 steps are required:
|
|
||||||
|
|
||||||
1. Create valid SSL certificate file
|
|
||||||
2. Append SSL certificate file path to the `listening_ports` option
|
|
||||||
|
|
||||||
Below is the `mongoose.conf` file snippet for typical SSL setup:
|
|
||||||
|
|
||||||
document_root www_root # Serve files in www_root directory
|
|
||||||
listening_ports 80,443:cert.pem # Listen on ports 80 and 443
|
|
||||||
|
|
||||||
## How to create SSL certificate file
|
|
||||||
|
|
||||||
SSL certificate file is a text file that must contain at least two
|
|
||||||
sections:
|
|
||||||
|
|
||||||
1. A private key
|
|
||||||
2. A certificate
|
|
||||||
|
|
||||||
Both sections should be chunks of text in PEM format. When PEM file is
|
|
||||||
opened in a text editor, it looks like this:
|
|
||||||
|
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEogIBAAKCAQEAwONaLOP7EdegqjRuQKSDXzvHmFMZfBufjhELhNjo5KsL4ieH
|
|
||||||
hYN0Zii2yTb63jGxKY6gH1R/r9dL8kXaJmcZrfSa3AgywnteJWg=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIDBjCCAe4CCQCX05m0b053QzANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJB
|
|
||||||
SEGI4JSxV56lYg==
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
|
|
||||||
Two aforementioned sections are clearly seen. Typically, those section
|
|
||||||
are bigger then in the example shown. The text between the `BEGIN` and
|
|
||||||
`END` is the text representation of binary data, a private key and a
|
|
||||||
certificate. Therefore, in order to create a certificate file,
|
|
||||||
|
|
||||||
* private key must be converted to PEM format
|
|
||||||
* certificate must be converted to PEM format
|
|
||||||
* those two should be concatenated into a single file
|
|
||||||
|
|
||||||
If the certificate chain in used, a chain file also needs to be
|
|
||||||
converted into PEM format and appended to the certificate file.
|
|
||||||
|
|
||||||
## How SSL works
|
|
||||||
|
|
||||||
SSL is a protocol that can encrypt communication between two parties. If third
|
|
||||||
party observes all messages passed by, it would be very
|
|
||||||
hard for the third party (though not impossible) to decrypt the communication.
|
|
||||||
|
|
||||||
The idea is based on so-called public key encryption. Communicating parties
|
|
||||||
have two keys: a public key and a private key. A public key is advertised
|
|
||||||
to everybody, and it is contained in a certificate. A private key is kept
|
|
||||||
secret. Security algorithm works in a way that anybody can encrypt
|
|
||||||
a message using public key, and only private key can decrypt it.
|
|
||||||
|
|
||||||
This is why web server needs both private key and certificate: private key
|
|
||||||
is used to decrypt incoming messages, and certificate is used to tell the
|
|
||||||
public key to the other party. When communication starts, parties exchange
|
|
||||||
their public keys, and keep private keys to themselves. Man-in-the-middle
|
|
||||||
who observes the communication is unable to decrypt the messages cause
|
|
||||||
private keys are required for decryption.
|
|
||||||
|
|
||||||
Encryption algorithms are built on top of hard mathematical problem, which
|
|
||||||
makes it very expensive for man-in-the-middle to compute private keys.
|
|
||||||
For example, RSA algorithm is based on a mathematical problem of factorization.
|
|
||||||
It is easy to generate two very large prime numbers `P` and `Q` and make
|
|
||||||
a product `P * Q`. But given a product, it is very hard to recover these
|
|
||||||
two prime numbers - this is called factorization.
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
# Mongoose User Guide
|
|
||||||
|
|
||||||
Mongoose is small and easy to use web server built on top of
|
|
||||||
mongoose library. It is designed with maximum simplicity in mind. For example,
|
|
||||||
to share any directory, just drop mongoose executable in that directory,
|
|
||||||
double-click it (on UNIX, run it from shell) and launch a browser at
|
|
||||||
[http://localhost:8080](http://localhost:8080) Note that 'localhost' should
|
|
||||||
be changed to a machine's name if a folder is accessed from other computer.
|
|
||||||
|
|
||||||
On Windows and Mac, Mongoose iconifies itself to the system tray when started.
|
|
||||||
Right-click on the icon to pop up a menu, where it is possible to stop
|
|
||||||
mongoose, or configure it.
|
|
||||||
|
|
||||||
On UNIX, `mongoose` is a command line utility. Running `mongoose` in
|
|
||||||
terminal, optionally followed by configuration parameters
|
|
||||||
(`mongoose [OPTIONS]`) or configuration file name
|
|
||||||
(`mongoose [config_file_name]`) starts the
|
|
||||||
web server:
|
|
||||||
|
|
||||||
$ mongoose -document_root /var/www # Running mongoose with cmdline options
|
|
||||||
$ mongoose /etc/my_config.txt # Running mongoose with config file
|
|
||||||
$ mongoose # Running with no parameters. This will
|
|
||||||
# serve current directory on port 8080
|
|
||||||
|
|
||||||
Mongoose does not detach from terminal. Pressing `Ctrl-C` keys
|
|
||||||
stops the server.
|
|
||||||
|
|
||||||
When started, mongoose first searches for the configuration file.
|
|
||||||
If configuration file is specified explicitly in the command line, then
|
|
||||||
specified configuration file is used.
|
|
||||||
Otherwise, mongoose would search for file `mongoose.conf` in the same directory
|
|
||||||
where binary is located, and use it. Configuration file can be absent.
|
|
||||||
|
|
||||||
Configuration file is a sequence of lines, each line containing
|
|
||||||
command line argument name and it's value. Empty lines and lines beginning
|
|
||||||
with `#` are ignored. Here is the example of `mongoose.conf` file:
|
|
||||||
|
|
||||||
# This is a comment
|
|
||||||
document_root C:\www
|
|
||||||
listening_port 80
|
|
||||||
ssl_certificate C:\mongoose\ssl_cert.pem
|
|
||||||
|
|
||||||
Command line arguments are highest priority and can override
|
|
||||||
configuration file settings. For example, if `mongoose.conf` has line
|
|
||||||
`document_root /var/www`, and mongoose has been started as
|
|
||||||
`mongoose -document_root /etc`, then `/etc` directory will be used as
|
|
||||||
document root.
|
|
||||||
|
|
||||||
Note that configuration options on the command line must start with `-`,
|
|
||||||
and their names are the same as in the config file. Exampli gratia,
|
|
||||||
the following two setups are equivalent:
|
|
||||||
|
|
||||||
$ mongoose -listening_port 1234 -document_root /var/www
|
|
||||||
|
|
||||||
$ cat > mongoose.conf
|
|
||||||
listening_ports 1234
|
|
||||||
document_root /var/www
|
|
||||||
^D
|
|
||||||
$ mongoose
|
|
||||||
|
|
||||||
Mongoose can also be used to modify `.htpasswd` passwords file:
|
|
||||||
|
|
||||||
$ mongoose -A .htpasswd mydomain.com user_name user_password
|
|
||||||
|
|
||||||
Unlike other web servers, mongoose does not require CGI scripts be located in
|
|
||||||
a special directory. CGI scripts can be anywhere. CGI (and SSI) files are
|
|
||||||
recognized by the file name pattern. Mongoose uses shell-like glob
|
|
||||||
patterns. Pattern match starts at the beginning of the string, so essentially
|
|
||||||
patterns are prefix patterns. Syntax is as follows:
|
|
||||||
|
|
||||||
** Matches everything
|
|
||||||
* Matches everything but slash character, '/'
|
|
||||||
? Matches any character
|
|
||||||
$ Matches the end of the string
|
|
||||||
| Matches if pattern on the left side or the right side matches.
|
|
||||||
|
|
||||||
All other characters in the pattern match themselves. Examples:
|
|
||||||
|
|
||||||
# Pattern Meaning
|
|
||||||
**.cgi$ Any string that ends with .cgi
|
|
||||||
/foo Any string that begins with /foo
|
|
||||||
**a$|**b$ Any string that ends with a or b
|
|
||||||
|
|
||||||
To restrict CGI files only to `/cgi-bin/` directory, use this setting:
|
|
||||||
|
|
||||||
$ mongoose -cgi_pattern /cgi-bin/*.cgi # Emulate /cgi-bin/ restriction
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
title: "CoAP API reference"
|
||||||
|
symbol_kind: "intro"
|
||||||
|
decl_name: "coap.h"
|
||||||
|
items:
|
||||||
|
- { name: mg_set_protocol_coap.md }
|
||||||
|
- { name: mg_coap_add_option.md }
|
||||||
|
- { name: mg_coap_free_options.md }
|
||||||
|
- { name: mg_coap_send_message.md }
|
||||||
|
- { name: mg_coap_send_ack.md }
|
||||||
|
- { name: mg_coap_parse.md }
|
||||||
|
- { name: mg_coap_compose.md }
|
||||||
|
- { name: struct_mg_coap_option.md }
|
||||||
|
- { name: struct_mg_coap_message.md }
|
||||||
|
---
|
||||||
|
|
||||||
|
CoAP message format:
|
||||||
|
|
||||||
|
```
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||||
|
|Ver| T | TKL | Code | Message ID | Token (if any, TKL bytes) ...
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||||
|
| Options (if any) ... |1 1 1 1 1 1 1 1| Payload (if any) ...
|
||||||
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title: "mg_coap_add_option()"
|
||||||
|
decl_name: "mg_coap_add_option"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
struct mg_coap_option *mg_coap_add_option(struct mg_coap_message *cm,
|
||||||
|
uint32_t number, char *value,
|
||||||
|
size_t len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Adds a new option to mg_coap_message structure.
|
||||||
|
Returns pointer to the newly created option.
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: "mg_coap_compose()"
|
||||||
|
decl_name: "mg_coap_compose"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
uint32_t mg_coap_compose(struct mg_coap_message *cm, struct mbuf *io);
|
||||||
|
---
|
||||||
|
|
||||||
|
Composes CoAP message from mg_coap_message structure.
|
||||||
|
This is a helper function.
|
||||||
|
Return value: see `mg_coap_send_message()`
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: "mg_coap_free_options()"
|
||||||
|
decl_name: "mg_coap_free_options"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_coap_free_options(struct mg_coap_message *cm);
|
||||||
|
---
|
||||||
|
|
||||||
|
Frees the memory allocated for options.
|
||||||
|
If the cm paramater doesn't contain any option it does nothing.
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
title: "mg_coap_parse()"
|
||||||
|
decl_name: "mg_coap_parse"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
uint32_t mg_coap_parse(struct mbuf *io, struct mg_coap_message *cm);
|
||||||
|
---
|
||||||
|
|
||||||
|
Parses CoAP message and fills mg_coap_message and returns cm->flags.
|
||||||
|
This is a helper function.
|
||||||
|
|
||||||
|
NOTE: usually CoAP works over UDP, so lack of data means format error.
|
||||||
|
But, in theory, it is possible to use CoAP over TCP (according to RFC)
|
||||||
|
|
||||||
|
The caller has to check results and treat COAP_NOT_ENOUGH_DATA according to
|
||||||
|
underlying protocol:
|
||||||
|
|
||||||
|
- in case of UDP COAP_NOT_ENOUGH_DATA means COAP_FORMAT_ERROR,
|
||||||
|
- in case of TCP client can try to receive more data
|
||||||
|
|
||||||
|
Return value: see `mg_coap_send_message()`
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: "mg_coap_send_ack()"
|
||||||
|
decl_name: "mg_coap_send_ack"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
uint32_t mg_coap_send_ack(struct mg_connection *nc, uint16_t msg_id);
|
||||||
|
---
|
||||||
|
|
||||||
|
Composes CoAP acknowledgement from `mg_coap_message`
|
||||||
|
and sends it into `nc` connection.
|
||||||
|
Return value: see `mg_coap_send_message()`
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: "mg_coap_send_message()"
|
||||||
|
decl_name: "mg_coap_send_message"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
uint32_t mg_coap_send_message(struct mg_connection *nc,
|
||||||
|
struct mg_coap_message *cm);
|
||||||
|
---
|
||||||
|
|
||||||
|
Composes a CoAP message from `mg_coap_message`
|
||||||
|
and sends it into `nc` connection.
|
||||||
|
Returns 0 on success. On error, it is a bitmask:
|
||||||
|
|
||||||
|
- `#define MG_COAP_ERROR 0x10000`
|
||||||
|
- `#define MG_COAP_FORMAT_ERROR (MG_COAP_ERROR | 0x20000)`
|
||||||
|
- `#define MG_COAP_IGNORE (MG_COAP_ERROR | 0x40000)`
|
||||||
|
- `#define MG_COAP_NOT_ENOUGH_DATA (MG_COAP_ERROR | 0x80000)`
|
||||||
|
- `#define MG_COAP_NETWORK_ERROR (MG_COAP_ERROR | 0x100000)`
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_set_protocol_coap()"
|
||||||
|
decl_name: "mg_set_protocol_coap"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_set_protocol_coap(struct mg_connection *nc);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sets CoAP protocol handler - triggers CoAP specific events.
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: "struct mg_coap_message"
|
||||||
|
decl_name: "struct mg_coap_message"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct mg_coap_message {
|
||||||
|
uint32_t flags;
|
||||||
|
uint8_t msg_type;
|
||||||
|
uint8_t code_class;
|
||||||
|
uint8_t code_detail;
|
||||||
|
uint16_t msg_id;
|
||||||
|
struct mg_str token;
|
||||||
|
struct mg_coap_option *options;
|
||||||
|
struct mg_str payload;
|
||||||
|
struct mg_coap_option *optiomg_tail;
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
CoAP message. See RFC 7252 for details.
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
title: "struct mg_coap_option"
|
||||||
|
decl_name: "struct mg_coap_option"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct mg_coap_option {
|
||||||
|
struct mg_coap_option *next;
|
||||||
|
uint32_t number;
|
||||||
|
struct mg_str value;
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
CoAP options.
|
||||||
|
Use mg_coap_add_option and mg_coap_free_options
|
||||||
|
for creation and destruction.
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: "DNS API reference"
|
||||||
|
symbol_kind: "intro"
|
||||||
|
decl_name: "dns.h"
|
||||||
|
items:
|
||||||
|
- { name: mg_dns_parse_record_data.md }
|
||||||
|
- { name: mg_send_dns_query.md }
|
||||||
|
- { name: mg_dns_insert_header.md }
|
||||||
|
- { name: mg_dns_copy_questions.md }
|
||||||
|
- { name: mg_dns_encode_record.md }
|
||||||
|
- { name: mg_dns_encode_name.md }
|
||||||
|
- { name: mg_parse_dns.md }
|
||||||
|
- { name: mg_dns_uncompress_name.md }
|
||||||
|
- { name: mg_set_protocol_dns.md }
|
||||||
|
- { name: struct_mg_dns_resource_record.md }
|
||||||
|
- { name: struct_mg_dns_message.md }
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_copy_questions()"
|
||||||
|
decl_name: "mg_dns_copy_questions"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
|
||||||
|
---
|
||||||
|
|
||||||
|
Appends already encoded questions from an existing message.
|
||||||
|
|
||||||
|
This is useful when generating a DNS reply message which includes
|
||||||
|
all question records.
|
||||||
|
|
||||||
|
Returns the number of appended bytes.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_encode_name()"
|
||||||
|
decl_name: "mg_dns_encode_name"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_dns_encode_name(struct mbuf *io, const char *name, size_t len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Encodes a DNS name.
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_encode_record()"
|
||||||
|
decl_name: "mg_dns_encode_record"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_dns_encode_record(struct mbuf *io, struct mg_dns_resource_record *rr,
|
||||||
|
const char *name, size_t nlen, const void *rdata,
|
||||||
|
size_t rlen);
|
||||||
|
---
|
||||||
|
|
||||||
|
Encodes and appends a DNS resource record to an IO buffer.
|
||||||
|
|
||||||
|
The record metadata is taken from the `rr` parameter, while the name and data
|
||||||
|
are taken from the parameters, encoded in the appropriate format depending on
|
||||||
|
record type and stored in the IO buffer. The encoded values might contain
|
||||||
|
offsets within the IO buffer. It's thus important that the IO buffer doesn't
|
||||||
|
get trimmed while a sequence of records are encoded while preparing a DNS
|
||||||
|
reply.
|
||||||
|
|
||||||
|
This function doesn't update the `name` and `rdata` pointers in the `rr`
|
||||||
|
struct because they might be invalidated as soon as the IO buffer grows
|
||||||
|
again.
|
||||||
|
|
||||||
|
Returns the number of bytes appened or -1 in case of error.
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_insert_header()"
|
||||||
|
decl_name: "mg_dns_insert_header"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_dns_insert_header(struct mbuf *io, size_t pos,
|
||||||
|
struct mg_dns_message *msg);
|
||||||
|
---
|
||||||
|
|
||||||
|
Inserts a DNS header to an IO buffer.
|
||||||
|
|
||||||
|
Returns the number of bytes inserted.
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_parse_record_data()"
|
||||||
|
decl_name: "mg_dns_parse_record_data"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_dns_parse_record_data(struct mg_dns_message *msg,
|
||||||
|
struct mg_dns_resource_record *rr, void *data,
|
||||||
|
size_t data_len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Parses the record data from a DNS resource record.
|
||||||
|
|
||||||
|
- A: struct in_addr *ina
|
||||||
|
- AAAA: struct in6_addr *ina
|
||||||
|
- CNAME: char buffer
|
||||||
|
|
||||||
|
Returns -1 on error.
|
||||||
|
|
||||||
|
TODO(mkm): MX
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_uncompress_name()"
|
||||||
|
decl_name: "mg_dns_uncompress_name"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
size_t mg_dns_uncompress_name(struct mg_dns_message *msg, struct mg_str *name,
|
||||||
|
char *dst, int dst_len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Uncompresses a DNS compressed name.
|
||||||
|
|
||||||
|
The containing DNS message is required because of the compressed encoding
|
||||||
|
and reference suffixes present elsewhere in the packet.
|
||||||
|
|
||||||
|
If the name is less than `dst_len` characters long, the remainder
|
||||||
|
of `dst` is terminated with `\0` characters. Otherwise, `dst` is not
|
||||||
|
terminated.
|
||||||
|
|
||||||
|
If `dst_len` is 0 `dst` can be NULL.
|
||||||
|
Returns the uncompressed name length.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_parse_dns()"
|
||||||
|
decl_name: "mg_parse_dns"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_parse_dns(const char *buf, int len, struct mg_dns_message *msg);
|
||||||
|
---
|
||||||
|
|
||||||
|
Low-level: parses a DNS response.
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: "mg_send_dns_query()"
|
||||||
|
decl_name: "mg_send_dns_query"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_send_dns_query(struct mg_connection *nc, const char *name,
|
||||||
|
int query_type);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a DNS query to the remote end.
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: "mg_set_protocol_dns()"
|
||||||
|
decl_name: "mg_set_protocol_dns"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_set_protocol_dns(struct mg_connection *nc);
|
||||||
|
---
|
||||||
|
|
||||||
|
Attaches a built-in DNS event handler to the given listening connection.
|
||||||
|
|
||||||
|
The DNS event handler parses the incoming UDP packets, treating them as DNS
|
||||||
|
requests. If an incoming packet gets successfully parsed by the DNS event
|
||||||
|
handler, a user event handler will receive an `MG_DNS_REQUEST` event, with
|
||||||
|
`ev_data` pointing to the parsed `struct mg_dns_message`.
|
||||||
|
|
||||||
|
See
|
||||||
|
[captive_dns_server](https://github.com/cesanta/mongoose/tree/master/examples/captive_dns_server)
|
||||||
|
example on how to handle DNS request and send DNS reply.
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
title: "struct mg_dns_message"
|
||||||
|
decl_name: "struct mg_dns_message"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct mg_dns_message {
|
||||||
|
struct mg_str pkt; /* packet body */
|
||||||
|
uint16_t flags;
|
||||||
|
uint16_t transaction_id;
|
||||||
|
int num_questions;
|
||||||
|
int num_answers;
|
||||||
|
struct mg_dns_resource_record questions[MG_MAX_DNS_QUESTIONS];
|
||||||
|
struct mg_dns_resource_record answers[MG_MAX_DNS_ANSWERS];
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
DNS message (request and response).
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: "struct mg_dns_resource_record"
|
||||||
|
decl_name: "struct mg_dns_resource_record"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct mg_dns_resource_record {
|
||||||
|
struct mg_str name; /* buffer with compressed name */
|
||||||
|
int rtype;
|
||||||
|
int rclass;
|
||||||
|
int ttl;
|
||||||
|
enum mg_dns_resource_record_kind kind;
|
||||||
|
struct mg_str rdata; /* protocol data (can be a compressed name) */
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
DNS resource record.
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: "DNS server API reference"
|
||||||
|
symbol_kind: "intro"
|
||||||
|
decl_name: "dns_server.h"
|
||||||
|
items:
|
||||||
|
- { name: mg_dns_create_reply.md }
|
||||||
|
- { name: mg_dns_reply_record.md }
|
||||||
|
- { name: mg_dns_send_reply.md }
|
||||||
|
---
|
||||||
|
|
||||||
|
Disabled by default; enable with `-DMG_ENABLE_DNS_SERVER`.
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_create_reply()"
|
||||||
|
decl_name: "mg_dns_create_reply"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
struct mg_dns_reply mg_dns_create_reply(struct mbuf *io,
|
||||||
|
struct mg_dns_message *msg);
|
||||||
|
---
|
||||||
|
|
||||||
|
Creates a DNS reply.
|
||||||
|
|
||||||
|
The reply will be based on an existing query message `msg`.
|
||||||
|
The query body will be appended to the output buffer.
|
||||||
|
"reply + recursion allowed" will be added to the message flags and the
|
||||||
|
message's num_answers will be set to 0.
|
||||||
|
|
||||||
|
Answer records can be appended with `mg_dns_send_reply` or by lower
|
||||||
|
level function defined in the DNS API.
|
||||||
|
|
||||||
|
In order to send a reply use `mg_dns_send_reply`.
|
||||||
|
It's possible to use a connection's send buffer as reply buffer,
|
||||||
|
and it will work for both UDP and TCP connections.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```c
|
||||||
|
reply = mg_dns_create_reply(&nc->send_mbuf, msg);
|
||||||
|
for (i = 0; i < msg->num_questions; i++) {
|
||||||
|
rr = &msg->questions[i];
|
||||||
|
if (rr->rtype == MG_DNS_A_RECORD) {
|
||||||
|
mg_dns_reply_record(&reply, rr, 3600, &dummy_ip_addr, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mg_dns_send_reply(nc, &reply);
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_reply_record()"
|
||||||
|
decl_name: "mg_dns_reply_record"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_dns_reply_record(struct mg_dns_reply *reply,
|
||||||
|
struct mg_dns_resource_record *question,
|
||||||
|
const char *name, int rtype, int ttl, const void *rdata,
|
||||||
|
size_t rdata_len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Appends a DNS reply record to the IO buffer and to the DNS message.
|
||||||
|
|
||||||
|
The message's num_answers field will be incremented. It's the caller's duty
|
||||||
|
to ensure num_answers is properly initialised.
|
||||||
|
|
||||||
|
Returns -1 on error.
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: "mg_dns_send_reply()"
|
||||||
|
decl_name: "mg_dns_send_reply"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_dns_send_reply(struct mg_connection *nc, struct mg_dns_reply *r);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a DNS reply through a connection.
|
||||||
|
|
||||||
|
The DNS data is stored in an IO buffer pointed by reply structure in `r`.
|
||||||
|
This function mutates the content of that buffer in order to ensure that
|
||||||
|
the DNS header reflects the size and flags of the message, that might have
|
||||||
|
been updated either with `mg_dns_reply_record` or by direct manipulation of
|
||||||
|
`r->message`.
|
||||||
|
|
||||||
|
Once sent, the IO buffer will be trimmed unless the reply IO buffer
|
||||||
|
is the connection's send buffer and the connection is not in UDP mode.
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
title: "Common API reference"
|
||||||
|
symbol_kind: "intro"
|
||||||
|
decl_name: "http.h"
|
||||||
|
items:
|
||||||
|
- { name: mg_set_protocol_http_websocket.md }
|
||||||
|
- { name: mg_send_websocket_handshake.md }
|
||||||
|
- { name: mg_send_websocket_handshake2.md }
|
||||||
|
- { name: mg_connect_ws.md }
|
||||||
|
- { name: mg_connect_ws_opt.md }
|
||||||
|
- { name: mg_send_websocket_frame.md }
|
||||||
|
- { name: mg_send_websocket_framev.md }
|
||||||
|
- { name: mg_printf_websocket_frame.md }
|
||||||
|
- { name: mg_url_decode.md }
|
||||||
|
- { name: struct_http_message.md }
|
||||||
|
- { name: struct_websocket_message.md }
|
||||||
|
- { name: struct_mg_http_multipart_part.md }
|
||||||
|
- { name: struct_mg_ssi_call_ctx.md }
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
title: "mg_connect_ws()"
|
||||||
|
decl_name: "mg_connect_ws"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
struct mg_connection *mg_connect_ws(struct mg_mgr *mgr,
|
||||||
|
mg_event_handler_t event_handler,
|
||||||
|
const char *url, const char *protocol,
|
||||||
|
const char *extra_headers);
|
||||||
|
---
|
||||||
|
|
||||||
|
Helper function that creates an outbound WebSocket connection.
|
||||||
|
|
||||||
|
`url` is a URL to connect to. It must be properly URL-encoded, e.g. have
|
||||||
|
no spaces, etc. By default, `mg_connect_ws()` sends Connection and
|
||||||
|
Host headers. `extra_headers` is an extra HTTP header to send, e.g.
|
||||||
|
`"User-Agent: my-app\r\n"`.
|
||||||
|
If `protocol` is not NULL, then a `Sec-WebSocket-Protocol` header is sent.
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
```c
|
||||||
|
nc1 = mg_connect_ws(mgr, ev_handler_1, "ws://echo.websocket.org", NULL,
|
||||||
|
NULL);
|
||||||
|
nc2 = mg_connect_ws(mgr, ev_handler_1, "wss://echo.websocket.org", NULL,
|
||||||
|
NULL);
|
||||||
|
nc3 = mg_connect_ws(mgr, ev_handler_1, "ws://api.cesanta.com",
|
||||||
|
"clubby.cesanta.com", NULL);
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: "mg_connect_ws_opt()"
|
||||||
|
decl_name: "mg_connect_ws_opt"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
struct mg_connection *mg_connect_ws_opt(struct mg_mgr *mgr,
|
||||||
|
mg_event_handler_t ev_handler,
|
||||||
|
struct mg_connect_opts opts,
|
||||||
|
const char *url, const char *protocol,
|
||||||
|
const char *extra_headers);
|
||||||
|
---
|
||||||
|
|
||||||
|
Helper function that creates an outbound WebSocket connection
|
||||||
|
|
||||||
|
Mostly identical to `mg_connect_ws`, but allows to provide extra parameters
|
||||||
|
(for example, SSL parameters)
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
title: "mg_printf_websocket_frame()"
|
||||||
|
decl_name: "mg_printf_websocket_frame"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_printf_websocket_frame(struct mg_connection *nc, int op_and_flags,
|
||||||
|
const char *fmt, ...);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends WebSocket frame to the remote end.
|
||||||
|
|
||||||
|
Like `mg_send_websocket_frame()`, but allows to create formatted messages
|
||||||
|
with `printf()`-like semantics.
|
||||||
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
title: "mg_send_websocket_frame()"
|
||||||
|
decl_name: "mg_send_websocket_frame"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_send_websocket_frame(struct mg_connection *nc, int op_and_flags,
|
||||||
|
const void *data, size_t data_len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Send WebSocket frame to the remote end.
|
||||||
|
|
||||||
|
`op_and_flags` specifies the frame's type. It's one of:
|
||||||
|
|
||||||
|
- WEBSOCKET_OP_CONTINUE
|
||||||
|
- WEBSOCKET_OP_TEXT
|
||||||
|
- WEBSOCKET_OP_BINARY
|
||||||
|
- WEBSOCKET_OP_CLOSE
|
||||||
|
- WEBSOCKET_OP_PING
|
||||||
|
- WEBSOCKET_OP_PONG
|
||||||
|
|
||||||
|
Orred with one of the flags:
|
||||||
|
|
||||||
|
- WEBSOCKET_DONT_FIN: Don't set the FIN flag on the frame to be sent.
|
||||||
|
|
||||||
|
`data` and `data_len` contain frame data.
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title: "mg_send_websocket_framev()"
|
||||||
|
decl_name: "mg_send_websocket_framev"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_send_websocket_framev(struct mg_connection *nc, int op_and_flags,
|
||||||
|
const struct mg_str *strings, int num_strings);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends multiple websocket frames.
|
||||||
|
|
||||||
|
Like `mg_send_websocket_frame()`, but composes a frame from multiple buffers.
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
title: "mg_send_websocket_handshake()"
|
||||||
|
decl_name: "mg_send_websocket_handshake"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_send_websocket_handshake(struct mg_connection *nc, const char *uri,
|
||||||
|
const char *extra_headers);
|
||||||
|
---
|
||||||
|
|
||||||
|
Send websocket handshake to the server.
|
||||||
|
|
||||||
|
`nc` must be a valid connection, connected to a server. `uri` is an URI
|
||||||
|
to fetch, extra_headers` is extra HTTP headers to send or `NULL`.
|
||||||
|
|
||||||
|
This function is intended to be used by websocket client.
|
||||||
|
|
||||||
|
Note that the Host header is mandatory in HTTP/1.1 and must be
|
||||||
|
included in `extra_headers`. `mg_send_websocket_handshake2` offers
|
||||||
|
a better API for that.
|
||||||
|
|
||||||
|
Deprecated in favour of `mg_send_websocket_handshake2`
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: "mg_send_websocket_handshake2()"
|
||||||
|
decl_name: "mg_send_websocket_handshake2"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_send_websocket_handshake2(struct mg_connection *nc, const char *path,
|
||||||
|
const char *host, const char *protocol,
|
||||||
|
const char *extra_headers);
|
||||||
|
---
|
||||||
|
|
||||||
|
Send websocket handshake to the server.
|
||||||
|
|
||||||
|
`nc` must be a valid connection, connected to a server. `uri` is an URI
|
||||||
|
to fetch, `host` goes into the `Host` header, `protocol` goes into the
|
||||||
|
`Sec-WebSocket-Proto` header (NULL to omit), extra_headers` is extra HTTP
|
||||||
|
headers to send or `NULL`.
|
||||||
|
|
||||||
|
This function is intended to be used by websocket client.
|
||||||
|
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
---
|
||||||
|
title: "mg_set_protocol_http_websocket()"
|
||||||
|
decl_name: "mg_set_protocol_http_websocket"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_set_protocol_http_websocket(struct mg_connection *nc);
|
||||||
|
---
|
||||||
|
|
||||||
|
Attaches a built-in HTTP event handler to the given connection.
|
||||||
|
The user-defined event handler will receive following extra events:
|
||||||
|
|
||||||
|
- MG_EV_HTTP_REQUEST: HTTP request has arrived. Parsed HTTP request
|
||||||
|
is passed as
|
||||||
|
`struct http_message` through the handler's `void *ev_data` pointer.
|
||||||
|
- MG_EV_HTTP_MULTIPART_REQUEST: A multipart POST request has received.
|
||||||
|
This event is sent before body is parsed. After this, the user
|
||||||
|
should expect a sequence of MG_EV_HTTP_PART_BEGIN/DATA/END requests.
|
||||||
|
This is also the last time when headers and other request fields are
|
||||||
|
accessible.
|
||||||
|
- MG_EV_HTTP_REPLY: The HTTP reply has arrived. The parsed HTTP reply is
|
||||||
|
passed as `struct http_message` through the handler's `void *ev_data`
|
||||||
|
pointer.
|
||||||
|
- MG_EV_HTTP_CHUNK: The HTTP chunked-encoding chunk has arrived.
|
||||||
|
The parsed HTTP reply is passed as `struct http_message` through the
|
||||||
|
handler's `void *ev_data` pointer. `http_message::body` would contain
|
||||||
|
incomplete, reassembled HTTP body.
|
||||||
|
It will grow with every new chunk that arrives, and it can
|
||||||
|
potentially consume a lot of memory. An event handler may process
|
||||||
|
the body as chunks are coming, and signal Mongoose to delete processed
|
||||||
|
body by setting `MG_F_DELETE_CHUNK` in `mg_connection::flags`. When
|
||||||
|
the last zero chunk is received,
|
||||||
|
Mongoose sends `MG_EV_HTTP_REPLY` event with
|
||||||
|
full reassembled body (if handler did not signal to delete chunks) or
|
||||||
|
with empty body (if handler did signal to delete chunks).
|
||||||
|
- MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received the WebSocket
|
||||||
|
handshake request. `ev_data` contains parsed HTTP request.
|
||||||
|
- MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed the WebSocket
|
||||||
|
handshake. `ev_data` is `NULL`.
|
||||||
|
- MG_EV_WEBSOCKET_FRAME: new WebSocket frame has arrived. `ev_data` is
|
||||||
|
`struct websocket_message *`
|
||||||
|
- MG_EV_HTTP_PART_BEGIN: new part of multipart message is started,
|
||||||
|
extra parameters are passed in mg_http_multipart_part
|
||||||
|
- MG_EV_HTTP_PART_DATA: new portion of data from the multiparted message
|
||||||
|
no additional headers are available, only data and data size
|
||||||
|
- MG_EV_HTTP_PART_END: final boundary received, analogue to maybe used to
|
||||||
|
find the end of packet
|
||||||
|
Note: Mongoose should be compiled with MG_ENABLE_HTTP_STREAMING_MULTIPART
|
||||||
|
to enable MG_EV_HTTP_MULTIPART_REQUEST, MG_EV_HTTP_REQUEST_END,
|
||||||
|
MG_EV_HTTP_REQUEST_CANCEL, MG_EV_HTTP_PART_BEGIN, MG_EV_HTTP_PART_DATA,
|
||||||
|
MG_EV_HTTP_PART_END constants
|
||||||
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
title: "mg_url_decode()"
|
||||||
|
decl_name: "mg_url_decode"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_url_decode(const char *src, int src_len, char *dst, int dst_len,
|
||||||
|
int is_form_url_encoded);
|
||||||
|
---
|
||||||
|
|
||||||
|
Decodes a URL-encoded string.
|
||||||
|
|
||||||
|
Source string is specified by (`src`, `src_len`), and destination is
|
||||||
|
(`dst`, `dst_len`). If `is_form_url_encoded` is non-zero, then
|
||||||
|
`+` character is decoded as a blank space character. This function
|
||||||
|
guarantees to NUL-terminate the destination. If destination is too small,
|
||||||
|
then the source string is partially decoded and `-1` is returned. Otherwise,
|
||||||
|
a length of the decoded string is returned, not counting final NUL.
|
||||||
|
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
title: "struct http_message"
|
||||||
|
decl_name: "struct http_message"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct http_message {
|
||||||
|
struct mg_str message; /* Whole message: request line + headers + body */
|
||||||
|
|
||||||
|
/* HTTP Request line (or HTTP response line) */
|
||||||
|
struct mg_str method; /* "GET" */
|
||||||
|
struct mg_str uri; /* "/my_file.html" */
|
||||||
|
struct mg_str proto; /* "HTTP/1.1" -- for both request and response */
|
||||||
|
|
||||||
|
/* For responses, code and response status message are set */
|
||||||
|
int resp_code;
|
||||||
|
struct mg_str resp_status_msg;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Query-string part of the URI. For example, for HTTP request
|
||||||
|
* GET /foo/bar?param1=val1¶m2=val2
|
||||||
|
* | uri | query_string |
|
||||||
|
*
|
||||||
|
* Note that question mark character doesn't belong neither to the uri,
|
||||||
|
* nor to the query_string
|
||||||
|
*/
|
||||||
|
struct mg_str query_string;
|
||||||
|
|
||||||
|
/* Headers */
|
||||||
|
struct mg_str header_names[MG_MAX_HTTP_HEADERS];
|
||||||
|
struct mg_str header_values[MG_MAX_HTTP_HEADERS];
|
||||||
|
|
||||||
|
/* Message body */
|
||||||
|
struct mg_str body; /* Zero-length for requests with no body */
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
HTTP message
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
title: "struct mg_http_multipart_part"
|
||||||
|
decl_name: "struct mg_http_multipart_part"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct mg_http_multipart_part {
|
||||||
|
const char *file_name;
|
||||||
|
const char *var_name;
|
||||||
|
struct mg_str data;
|
||||||
|
int status; /* <0 on error */
|
||||||
|
void *user_data;
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
HTTP multipart part
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
title: "struct mg_ssi_call_ctx"
|
||||||
|
decl_name: "struct mg_ssi_call_ctx"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct mg_ssi_call_ctx {
|
||||||
|
struct http_message *req; /* The request being processed. */
|
||||||
|
struct mg_str file; /* Filesystem path of the file being processed. */
|
||||||
|
struct mg_str arg; /* The argument passed to the tag: <!-- call arg -->. */
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
SSI call context
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
title: "struct websocket_message"
|
||||||
|
decl_name: "struct websocket_message"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct websocket_message {
|
||||||
|
unsigned char *data;
|
||||||
|
size_t size;
|
||||||
|
unsigned char flags;
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
WebSocket message
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: "Client API reference"
|
||||||
|
symbol_kind: "intro"
|
||||||
|
decl_name: "http_client.h"
|
||||||
|
items:
|
||||||
|
- { name: mg_connect_http.md }
|
||||||
|
- { name: mg_connect_http_opt.md }
|
||||||
|
- { name: mg_http_create_digest_auth_header.md }
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
title: "mg_connect_http()"
|
||||||
|
decl_name: "mg_connect_http"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
struct mg_connection *mg_connect_http(struct mg_mgr *mgr,
|
||||||
|
mg_event_handler_t event_handler,
|
||||||
|
const char *url,
|
||||||
|
const char *extra_headers,
|
||||||
|
const char *post_data);
|
||||||
|
---
|
||||||
|
|
||||||
|
Helper function that creates an outbound HTTP connection.
|
||||||
|
|
||||||
|
`url` is the URL to fetch. It must be properly URL-encoded, e.g. have
|
||||||
|
no spaces, etc. By default, `mg_connect_http()` sends the Connection and
|
||||||
|
Host headers. `extra_headers` is an extra HTTP header to send, e.g.
|
||||||
|
`"User-Agent: my-app\r\n"`.
|
||||||
|
If `post_data` is NULL, then a GET request is created. Otherwise, a POST
|
||||||
|
request is created with the specified POST data. Note that if the data being
|
||||||
|
posted is a form submission, the `Content-Type` header should be set
|
||||||
|
accordingly (see example below).
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
|
||||||
|
```c
|
||||||
|
nc1 = mg_connect_http(mgr, ev_handler_1, "http://www.google.com", NULL,
|
||||||
|
NULL);
|
||||||
|
nc2 = mg_connect_http(mgr, ev_handler_1, "https://github.com", NULL, NULL);
|
||||||
|
nc3 = mg_connect_http(
|
||||||
|
mgr, ev_handler_1, "my_server:8000/form_submit/",
|
||||||
|
"Content-Type: application/x-www-form-urlencoded\r\n",
|
||||||
|
"var_1=value_1&var_2=value_2");
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
title: "mg_connect_http_opt()"
|
||||||
|
decl_name: "mg_connect_http_opt"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
struct mg_connection *mg_connect_http_opt(struct mg_mgr *mgr,
|
||||||
|
mg_event_handler_t ev_handler,
|
||||||
|
struct mg_connect_opts opts,
|
||||||
|
const char *url,
|
||||||
|
const char *extra_headers,
|
||||||
|
const char *post_data);
|
||||||
|
---
|
||||||
|
|
||||||
|
Helper function that creates an outbound HTTP connection.
|
||||||
|
|
||||||
|
Mostly identical to mg_connect_http, but allows you to provide extra
|
||||||
|
*parameters
|
||||||
|
(for example, SSL parameters)
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title: "mg_http_create_digest_auth_header()"
|
||||||
|
decl_name: "mg_http_create_digest_auth_header"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_http_create_digest_auth_header(char *buf, size_t buf_len,
|
||||||
|
const char *method, const char *uri,
|
||||||
|
const char *auth_domain, const char *user,
|
||||||
|
const char *passwd);
|
||||||
|
---
|
||||||
|
|
||||||
|
Creates digest authentication header for a client request.
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
title: "Server API reference"
|
||||||
|
symbol_kind: "intro"
|
||||||
|
decl_name: "http_server.h"
|
||||||
|
items:
|
||||||
|
- { name: mg_parse_http.md }
|
||||||
|
- { name: mg_get_http_header.md }
|
||||||
|
- { name: mg_http_parse_header.md }
|
||||||
|
- { name: mg_parse_multipart.md }
|
||||||
|
- { name: mg_get_http_var.md }
|
||||||
|
- { name: mg_serve_http.md }
|
||||||
|
- { name: mg_http_serve_file.md }
|
||||||
|
- { name: mg_register_http_endpoint.md }
|
||||||
|
- { name: mg_file_upload_handler.md }
|
||||||
|
- { name: mg_http_check_digest_auth.md }
|
||||||
|
- { name: mg_send_http_chunk.md }
|
||||||
|
- { name: mg_printf_http_chunk.md }
|
||||||
|
- { name: mg_send_response_line.md }
|
||||||
|
- { name: mg_http_send_redirect.md }
|
||||||
|
- { name: mg_send_head.md }
|
||||||
|
- { name: mg_printf_html_escape.md }
|
||||||
|
- { name: mg_fu_fname_fn.md }
|
||||||
|
- { name: struct_mg_serve_http_opts.md }
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
title: "mg_file_upload_handler()"
|
||||||
|
decl_name: "mg_file_upload_handler"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_file_upload_handler(struct mg_connection *nc, int ev, void *ev_data,
|
||||||
|
mg_fu_fname_fn local_name_fn);
|
||||||
|
---
|
||||||
|
|
||||||
|
File upload handler.
|
||||||
|
This handler can be used to implement file uploads with minimum code.
|
||||||
|
This handler will process MG_EV_HTTP_PART_* events and store file data into
|
||||||
|
a local file.
|
||||||
|
`local_name_fn` will be invoked with whatever name was provided by the client
|
||||||
|
and will expect the name of the local file to open. A return value of NULL
|
||||||
|
will abort file upload (client will get a "403 Forbidden" response). If
|
||||||
|
non-null, the returned string must be heap-allocated and will be freed by
|
||||||
|
the caller.
|
||||||
|
Exception: it is ok to return the same string verbatim.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```c
|
||||||
|
struct mg_str upload_fname(struct mg_connection *nc, struct mg_str fname) {
|
||||||
|
// Just return the same filename. Do not actually do this except in test!
|
||||||
|
// fname is user-controlled and needs to be sanitized.
|
||||||
|
return fname;
|
||||||
|
}
|
||||||
|
void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||||
|
switch (ev) {
|
||||||
|
...
|
||||||
|
case MG_EV_HTTP_PART_BEGIN:
|
||||||
|
case MG_EV_HTTP_PART_DATA:
|
||||||
|
case MG_EV_HTTP_PART_END:
|
||||||
|
mg_file_upload_handler(nc, ev, ev_data, upload_fname);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: "mg_fu_fname_fn"
|
||||||
|
decl_name: "mg_fu_fname_fn"
|
||||||
|
symbol_kind: "typedef"
|
||||||
|
signature: |
|
||||||
|
typedef struct mg_str (*mg_fu_fname_fn)(struct mg_connection *nc,
|
||||||
|
struct mg_str fname);
|
||||||
|
---
|
||||||
|
|
||||||
|
Callback prototype for `mg_file_upload_handler()`.
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title: "mg_get_http_header()"
|
||||||
|
decl_name: "mg_get_http_header"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name);
|
||||||
|
---
|
||||||
|
|
||||||
|
Searches and returns the header `name` in parsed HTTP message `hm`.
|
||||||
|
If header is not found, NULL is returned. Example:
|
||||||
|
|
||||||
|
struct mg_str *host_hdr = mg_get_http_header(hm, "Host");
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
title: "mg_get_http_var()"
|
||||||
|
decl_name: "mg_get_http_var"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst,
|
||||||
|
size_t dst_len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Fetches a HTTP form variable.
|
||||||
|
|
||||||
|
Fetches a variable `name` from a `buf` into a buffer specified by `dst`,
|
||||||
|
`dst_len`. The destination is always zero-terminated. Returns the length of
|
||||||
|
a fetched variable. If not found, 0 is returned. `buf` must be valid
|
||||||
|
url-encoded buffer. If destination is too small, `-1` is returned.
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: "mg_http_check_digest_auth()"
|
||||||
|
decl_name: "mg_http_check_digest_auth"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_http_check_digest_auth(struct http_message *hm, const char *auth_domain,
|
||||||
|
FILE *fp);
|
||||||
|
---
|
||||||
|
|
||||||
|
Authenticates a HTTP request against an opened password file.
|
||||||
|
Returns 1 if authenticated, 0 otherwise.
|
||||||
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
title: "mg_http_parse_header()"
|
||||||
|
decl_name: "mg_http_parse_header"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_http_parse_header(struct mg_str *hdr, const char *var_name, char *buf,
|
||||||
|
size_t buf_size);
|
||||||
|
---
|
||||||
|
|
||||||
|
Parses the HTTP header `hdr`. Finds variable `var_name` and stores its value
|
||||||
|
in the buffer `buf`, `buf_size`. Returns 0 if variable not found, non-zero
|
||||||
|
otherwise.
|
||||||
|
|
||||||
|
This function is supposed to parse cookies, authentication headers, etc.
|
||||||
|
Example (error handling omitted):
|
||||||
|
|
||||||
|
char user[20];
|
||||||
|
struct mg_str *hdr = mg_get_http_header(hm, "Authorization");
|
||||||
|
mg_http_parse_header(hdr, "username", user, sizeof(user));
|
||||||
|
|
||||||
|
Returns the length of the variable's value. If buffer is not large enough,
|
||||||
|
or variable not found, 0 is returned.
|
||||||
|
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: "mg_http_send_redirect()"
|
||||||
|
decl_name: "mg_http_send_redirect"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_http_send_redirect(struct mg_connection *nc, int status_code,
|
||||||
|
const struct mg_str location,
|
||||||
|
const struct mg_str extra_headers);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a redirect response.
|
||||||
|
`status_code` should be either 301 or 302 and `location` point to the
|
||||||
|
new location.
|
||||||
|
If `extra_headers` is not empty, then `extra_headers` are also sent
|
||||||
|
after the reponse line. `extra_headers` must NOT end end with new line.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
mg_http_send_redirect(nc, 302, mg_mk_str("/login"), mg_mk_str(NULL));
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
title: "mg_http_serve_file()"
|
||||||
|
decl_name: "mg_http_serve_file"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_http_serve_file(struct mg_connection *nc, struct http_message *hm,
|
||||||
|
const char *path, const struct mg_str mime_type,
|
||||||
|
const struct mg_str extra_headers);
|
||||||
|
---
|
||||||
|
|
||||||
|
Serves a specific file with a given MIME type and optional extra headers.
|
||||||
|
|
||||||
|
Example code snippet:
|
||||||
|
|
||||||
|
```c
|
||||||
|
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||||
|
switch (ev) {
|
||||||
|
case MG_EV_HTTP_REQUEST: {
|
||||||
|
struct http_message *hm = (struct http_message *) ev_data;
|
||||||
|
mg_http_serve_file(nc, hm, "file.txt",
|
||||||
|
mg_mk_str("text/plain"), mg_mk_str(""));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title: "mg_parse_http()"
|
||||||
|
decl_name: "mg_parse_http"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
|
||||||
|
---
|
||||||
|
|
||||||
|
Parses a HTTP message.
|
||||||
|
|
||||||
|
`is_req` should be set to 1 if parsing a request, 0 if reply.
|
||||||
|
|
||||||
|
Returns the number of bytes parsed. If HTTP message is
|
||||||
|
incomplete `0` is returned. On parse error, a negative number is returned.
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
title: "mg_parse_multipart()"
|
||||||
|
decl_name: "mg_parse_multipart"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
size_t mg_parse_multipart(const char *buf, size_t buf_len, char *var_name,
|
||||||
|
size_t var_name_len, char *file_name,
|
||||||
|
size_t file_name_len, const char **chunk,
|
||||||
|
size_t *chunk_len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Parses the buffer `buf`, `buf_len` that contains multipart form data chunks.
|
||||||
|
Stores the chunk name in a `var_name`, `var_name_len` buffer.
|
||||||
|
If a chunk is an uploaded file, then `file_name`, `file_name_len` is
|
||||||
|
filled with an uploaded file name. `chunk`, `chunk_len`
|
||||||
|
points to the chunk data.
|
||||||
|
|
||||||
|
Return: number of bytes to skip to the next chunk or 0 if there are
|
||||||
|
no more chunks.
|
||||||
|
|
||||||
|
Usage example:
|
||||||
|
|
||||||
|
```c
|
||||||
|
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||||
|
switch(ev) {
|
||||||
|
case MG_EV_HTTP_REQUEST: {
|
||||||
|
struct http_message *hm = (struct http_message *) ev_data;
|
||||||
|
char var_name[100], file_name[100];
|
||||||
|
const char *chunk;
|
||||||
|
size_t chunk_len, n1, n2;
|
||||||
|
|
||||||
|
n1 = n2 = 0;
|
||||||
|
while ((n2 = mg_parse_multipart(hm->body.p + n1,
|
||||||
|
hm->body.len - n1,
|
||||||
|
var_name, sizeof(var_name),
|
||||||
|
file_name, sizeof(file_name),
|
||||||
|
&chunk, &chunk_len)) > 0) {
|
||||||
|
printf("var: %s, file_name: %s, size: %d, chunk: [%.*s]\n",
|
||||||
|
var_name, file_name, (int) chunk_len,
|
||||||
|
(int) chunk_len, chunk);
|
||||||
|
n1 += n2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_printf_html_escape()"
|
||||||
|
decl_name: "mg_printf_html_escape"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a printf-formatted HTTP chunk, escaping HTML tags.
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: "mg_printf_http_chunk()"
|
||||||
|
decl_name: "mg_printf_http_chunk"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a printf-formatted HTTP chunk.
|
||||||
|
Functionality is similar to `mg_send_http_chunk()`.
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
---
|
||||||
|
title: "mg_register_http_endpoint()"
|
||||||
|
decl_name: "mg_register_http_endpoint"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_register_http_endpoint(struct mg_connection *nc, const char *uri_path,
|
||||||
|
mg_event_handler_t handler);
|
||||||
|
---
|
||||||
|
|
||||||
|
Registers a callback for a specified http endpoint
|
||||||
|
Note: if callback is registered it is called instead of the
|
||||||
|
callback provided in mg_bind
|
||||||
|
|
||||||
|
Example code snippet:
|
||||||
|
|
||||||
|
```c
|
||||||
|
static void handle_hello1(struct mg_connection *nc, int ev, void *ev_data) {
|
||||||
|
(void) ev; (void) ev_data;
|
||||||
|
mg_printf(nc, "HTTP/1.0 200 OK\r\n\r\n[I am Hello1]");
|
||||||
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_hello1(struct mg_connection *nc, int ev, void *ev_data) {
|
||||||
|
(void) ev; (void) ev_data;
|
||||||
|
mg_printf(nc, "HTTP/1.0 200 OK\r\n\r\n[I am Hello2]");
|
||||||
|
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() {
|
||||||
|
nc = mg_bind(&mgr, local_addr, cb1);
|
||||||
|
mg_register_http_endpoint(nc, "/hello1", handle_hello1);
|
||||||
|
mg_register_http_endpoint(nc, "/hello1/hello2", handle_hello2);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
title: "mg_send_head()"
|
||||||
|
decl_name: "mg_send_head"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_send_head(struct mg_connection *n, int status_code,
|
||||||
|
int64_t content_length, const char *extra_headers);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends the response line and headers.
|
||||||
|
This function sends the response line with the `status_code`, and
|
||||||
|
automatically
|
||||||
|
sends one header: either "Content-Length" or "Transfer-Encoding".
|
||||||
|
If `content_length` is negative, then "Transfer-Encoding: chunked" header
|
||||||
|
is sent, otherwise, "Content-Length" header is sent.
|
||||||
|
|
||||||
|
NOTE: If `Transfer-Encoding` is `chunked`, then message body must be sent
|
||||||
|
using `mg_send_http_chunk()` or `mg_printf_http_chunk()` functions.
|
||||||
|
Otherwise, `mg_send()` or `mg_printf()` must be used.
|
||||||
|
Extra headers could be set through `extra_headers`. Note `extra_headers`
|
||||||
|
must NOT be terminated by a new line.
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
title: "mg_send_http_chunk()"
|
||||||
|
decl_name: "mg_send_http_chunk"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends buffer `buf` of size `len` to the client using chunked HTTP encoding.
|
||||||
|
This function sends the buffer size as hex number + newline first, then
|
||||||
|
the buffer itself, then the newline. For example,
|
||||||
|
`mg_send_http_chunk(nc, "foo", 3)` whill append the `3\r\nfoo\r\n` string
|
||||||
|
to the `nc->send_mbuf` output IO buffer.
|
||||||
|
|
||||||
|
NOTE: The HTTP header "Transfer-Encoding: chunked" should be sent prior to
|
||||||
|
using this function.
|
||||||
|
|
||||||
|
NOTE: do not forget to send an empty chunk at the end of the response,
|
||||||
|
to tell the client that everything was sent. Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
mg_printf_http_chunk(nc, "%s", "my response!");
|
||||||
|
mg_send_http_chunk(nc, "", 0); // Tell the client we're finished
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
title: "mg_send_response_line()"
|
||||||
|
decl_name: "mg_send_response_line"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_send_response_line(struct mg_connection *nc, int status_code,
|
||||||
|
const char *extra_headers);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends the response status line.
|
||||||
|
If `extra_headers` is not NULL, then `extra_headers` are also sent
|
||||||
|
after the reponse line. `extra_headers` must NOT end end with new line.
|
||||||
|
Example:
|
||||||
|
|
||||||
|
mg_send_response_line(nc, 200, "Access-Control-Allow-Origin: *");
|
||||||
|
|
||||||
|
Will result in:
|
||||||
|
|
||||||
|
HTTP/1.1 200 OK\r\n
|
||||||
|
Access-Control-Allow-Origin: *\r\n
|
||||||
|
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
title: "mg_serve_http()"
|
||||||
|
decl_name: "mg_serve_http"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_serve_http(struct mg_connection *nc, struct http_message *hm,
|
||||||
|
struct mg_serve_http_opts opts);
|
||||||
|
---
|
||||||
|
|
||||||
|
Serves given HTTP request according to the `options`.
|
||||||
|
|
||||||
|
Example code snippet:
|
||||||
|
|
||||||
|
```c
|
||||||
|
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
|
||||||
|
struct http_message *hm = (struct http_message *) ev_data;
|
||||||
|
struct mg_serve_http_opts opts = { .document_root = "/var/www" }; // C99
|
||||||
|
|
||||||
|
switch (ev) {
|
||||||
|
case MG_EV_HTTP_REQUEST:
|
||||||
|
mg_serve_http(nc, hm, opts);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
@@ -0,0 +1,161 @@
|
|||||||
|
---
|
||||||
|
title: "struct mg_serve_http_opts"
|
||||||
|
decl_name: "struct mg_serve_http_opts"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct mg_serve_http_opts {
|
||||||
|
/* Path to web root directory */
|
||||||
|
const char *document_root;
|
||||||
|
|
||||||
|
/* List of index files. Default is "" */
|
||||||
|
const char *index_files;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Leave as NULL to disable authentication.
|
||||||
|
* To enable directory protection with authentication, set this to ".htpasswd"
|
||||||
|
* Then, creating ".htpasswd" file in any directory automatically protects
|
||||||
|
* it with digest authentication.
|
||||||
|
* Use `mongoose` web server binary, or `htdigest` Apache utility to
|
||||||
|
* create/manipulate passwords file.
|
||||||
|
* Make sure `auth_domain` is set to a valid domain name.
|
||||||
|
*/
|
||||||
|
const char *per_directory_auth_file;
|
||||||
|
|
||||||
|
/* Authorization domain (domain name of this web server) */
|
||||||
|
const char *auth_domain;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Leave as NULL to disable authentication.
|
||||||
|
* Normally, only selected directories in the document root are protected.
|
||||||
|
* If absolutely every access to the web server needs to be authenticated,
|
||||||
|
* regardless of the URI, set this option to the path to the passwords file.
|
||||||
|
* Format of that file is the same as ".htpasswd" file. Make sure that file
|
||||||
|
* is located outside document root to prevent people fetching it.
|
||||||
|
*/
|
||||||
|
const char *global_auth_file;
|
||||||
|
|
||||||
|
/* Set to "no" to disable directory listing. Enabled by default. */
|
||||||
|
const char *enable_directory_listing;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SSI files pattern. If not set, "**.shtml$|**.shtm$" is used.
|
||||||
|
*
|
||||||
|
* All files that match ssi_pattern are treated as SSI.
|
||||||
|
*
|
||||||
|
* Server Side Includes (SSI) is a simple interpreted server-side scripting
|
||||||
|
* language which is most commonly used to include the contents of a file
|
||||||
|
* into a web page. It can be useful when it is desirable to include a common
|
||||||
|
* piece of code throughout a website, for example, headers and footers.
|
||||||
|
*
|
||||||
|
* In order for a webpage to recognize an SSI-enabled HTML file, the
|
||||||
|
* filename should end with a special extension, by default the extension
|
||||||
|
* should be either .shtml or .shtm
|
||||||
|
*
|
||||||
|
* Unknown SSI directives are silently ignored by Mongoose. Currently,
|
||||||
|
* the following SSI directives are supported:
|
||||||
|
* <!--#include FILE_TO_INCLUDE -->
|
||||||
|
* <!--#exec "COMMAND_TO_EXECUTE" -->
|
||||||
|
* <!--#call COMMAND -->
|
||||||
|
*
|
||||||
|
* Note that <!--#include ...> directive supports three path
|
||||||
|
*specifications:
|
||||||
|
*
|
||||||
|
* <!--#include virtual="path" --> Path is relative to web server root
|
||||||
|
* <!--#include abspath="path" --> Path is absolute or relative to the
|
||||||
|
* web server working dir
|
||||||
|
* <!--#include file="path" -->, Path is relative to current document
|
||||||
|
* <!--#include "path" -->
|
||||||
|
*
|
||||||
|
* The include directive may be used to include the contents of a file or
|
||||||
|
* the result of running a CGI script.
|
||||||
|
*
|
||||||
|
* The exec directive is used to execute
|
||||||
|
* a command on a server, and show command's output. Example:
|
||||||
|
*
|
||||||
|
* <!--#exec "ls -l" -->
|
||||||
|
*
|
||||||
|
* The call directive is a way to invoke a C handler from the HTML page.
|
||||||
|
* On each occurence of <!--#call COMMAND OPTIONAL_PARAMS> directive,
|
||||||
|
* Mongoose calls a registered event handler with MG_EV_SSI_CALL event,
|
||||||
|
* and event parameter will point to the COMMAND OPTIONAL_PARAMS string.
|
||||||
|
* An event handler can output any text, for example by calling
|
||||||
|
* `mg_printf()`. This is a flexible way of generating a web page on
|
||||||
|
* server side by calling a C event handler. Example:
|
||||||
|
*
|
||||||
|
* <!--#call foo --> ... <!--#call bar -->
|
||||||
|
*
|
||||||
|
* In the event handler:
|
||||||
|
* case MG_EV_SSI_CALL: {
|
||||||
|
* const char *param = (const char *) ev_data;
|
||||||
|
* if (strcmp(param, "foo") == 0) {
|
||||||
|
* mg_printf(c, "hello from foo");
|
||||||
|
* } else if (strcmp(param, "bar") == 0) {
|
||||||
|
* mg_printf(c, "hello from bar");
|
||||||
|
* }
|
||||||
|
* break;
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
const char *ssi_pattern;
|
||||||
|
|
||||||
|
/* IP ACL. By default, NULL, meaning all IPs are allowed to connect */
|
||||||
|
const char *ip_acl;
|
||||||
|
|
||||||
|
/* URL rewrites.
|
||||||
|
*
|
||||||
|
* Comma-separated list of `uri_pattern=file_or_directory_path` rewrites.
|
||||||
|
* When HTTP request is received, Mongoose constructs a file name from the
|
||||||
|
* requested URI by combining `document_root` and the URI. However, if the
|
||||||
|
* rewrite option is used and `uri_pattern` matches requested URI, then
|
||||||
|
* `document_root` is ignored. Instead, `file_or_directory_path` is used,
|
||||||
|
* which should be a full path name or a path relative to the web server's
|
||||||
|
* current working directory. Note that `uri_pattern`, as all Mongoose
|
||||||
|
* patterns, is a prefix pattern.
|
||||||
|
*
|
||||||
|
* If uri_pattern starts with `@` symbol, then Mongoose compares it with the
|
||||||
|
* HOST header of the request. If they are equal, Mongoose sets document root
|
||||||
|
* to `file_or_directory_path`, implementing virtual hosts support.
|
||||||
|
* Example: `@foo.com=/document/root/for/foo.com`
|
||||||
|
*
|
||||||
|
* If `uri_pattern` starts with `%` symbol, then Mongoose compares it with
|
||||||
|
* the listening port. If they match, then Mongoose issues a 301 redirect.
|
||||||
|
* For example, to redirect all HTTP requests to the
|
||||||
|
* HTTPS port, do `%80=https://my.site.com`. Note that the request URI is
|
||||||
|
* automatically appended to the redirect location.
|
||||||
|
*/
|
||||||
|
const char *url_rewrites;
|
||||||
|
|
||||||
|
/* DAV document root. If NULL, DAV requests are going to fail. */
|
||||||
|
const char *dav_document_root;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DAV passwords file. If NULL, DAV requests are going to fail.
|
||||||
|
* If passwords file is set to "-", then DAV auth is disabled.
|
||||||
|
*/
|
||||||
|
const char *dav_auth_file;
|
||||||
|
|
||||||
|
/* Glob pattern for the files to hide. */
|
||||||
|
const char *hidden_file_pattern;
|
||||||
|
|
||||||
|
/* Set to non-NULL to enable CGI, e.g. **.cgi$|**.php$" */
|
||||||
|
const char *cgi_file_pattern;
|
||||||
|
|
||||||
|
/* If not NULL, ignore CGI script hashbang and use this interpreter */
|
||||||
|
const char *cgi_interpreter;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Comma-separated list of Content-Type overrides for path suffixes, e.g.
|
||||||
|
* ".txt=text/plain; charset=utf-8,.c=text/plain"
|
||||||
|
*/
|
||||||
|
const char *custom_mime_types;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Extra HTTP headers to add to each server response.
|
||||||
|
* Example: to enable CORS, set this to "Access-Control-Allow-Origin: *".
|
||||||
|
*/
|
||||||
|
const char *extra_headers;
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
This structure defines how `mg_serve_http()` works.
|
||||||
|
Best practice is to set only required settings, and leave the rest as NULL.
|
||||||
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
items:
|
||||||
|
- { name: mbuf.h }
|
||||||
|
- { name: net.h }
|
||||||
|
- { name: http.h }
|
||||||
|
- { name: http_server.h }
|
||||||
|
- { name: http_client.h }
|
||||||
|
- { name: dns.h }
|
||||||
|
- { name: dns_server.h }
|
||||||
|
- { name: resolv.h }
|
||||||
|
- { name: mqtt.h }
|
||||||
|
- { name: mqtt_server.h }
|
||||||
|
- { name: coap.h }
|
||||||
|
- { name: util.h }
|
||||||
|
- { name: uri.h }
|
||||||
|
---
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
title: "Memory Buffers"
|
||||||
|
symbol_kind: "intro"
|
||||||
|
decl_name: "mbuf.h"
|
||||||
|
items:
|
||||||
|
- { name: mbuf_init.md }
|
||||||
|
- { name: mbuf_free.md }
|
||||||
|
- { name: mbuf_append.md }
|
||||||
|
- { name: mbuf_insert.md }
|
||||||
|
- { name: mbuf_remove.md }
|
||||||
|
- { name: mbuf_resize.md }
|
||||||
|
- { name: mbuf_trim.md }
|
||||||
|
- { name: struct_mbuf.md }
|
||||||
|
---
|
||||||
|
|
||||||
|
Mbufs are mutable/growing memory buffers, like C++ strings.
|
||||||
|
Mbuf can append data to the end of a buffer or insert data into arbitrary
|
||||||
|
position in the middle of a buffer. The buffer grows automatically when
|
||||||
|
needed.
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: "mbuf_append()"
|
||||||
|
decl_name: "mbuf_append"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
size_t mbuf_append(struct mbuf *, const void *data, size_t data_size);
|
||||||
|
---
|
||||||
|
|
||||||
|
Appends data to the Mbuf.
|
||||||
|
|
||||||
|
Returns the number of bytes appended or 0 if out of memory.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mbuf_free()"
|
||||||
|
decl_name: "mbuf_free"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mbuf_free(struct mbuf *);
|
||||||
|
---
|
||||||
|
|
||||||
|
Frees the space allocated for the mbuffer and resets the mbuf structure.
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: "mbuf_init()"
|
||||||
|
decl_name: "mbuf_init"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mbuf_init(struct mbuf *, size_t initial_capacity);
|
||||||
|
---
|
||||||
|
|
||||||
|
Initialises an Mbuf.
|
||||||
|
`initial_capacity` specifies the initial capacity of the mbuf.
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
title: "mbuf_insert()"
|
||||||
|
decl_name: "mbuf_insert"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
size_t mbuf_insert(struct mbuf *, size_t, const void *, size_t);
|
||||||
|
---
|
||||||
|
|
||||||
|
Inserts data at a specified offset in the Mbuf.
|
||||||
|
|
||||||
|
Existing data will be shifted forwards and the buffer will
|
||||||
|
be grown if necessary.
|
||||||
|
Returns the number of bytes inserted.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mbuf_remove()"
|
||||||
|
decl_name: "mbuf_remove"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mbuf_remove(struct mbuf *, size_t data_size);
|
||||||
|
---
|
||||||
|
|
||||||
|
Removes `data_size` bytes from the beginning of the buffer.
|
||||||
|
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
title: "mbuf_resize()"
|
||||||
|
decl_name: "mbuf_resize"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mbuf_resize(struct mbuf *, size_t new_size);
|
||||||
|
---
|
||||||
|
|
||||||
|
Resizes an Mbuf.
|
||||||
|
|
||||||
|
If `new_size` is smaller than buffer's `len`, the
|
||||||
|
resize is not performed.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mbuf_trim()"
|
||||||
|
decl_name: "mbuf_trim"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mbuf_trim(struct mbuf *);
|
||||||
|
---
|
||||||
|
|
||||||
|
Shrinks an Mbuf by resizing its `size` to `len`.
|
||||||
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
title: "struct mbuf"
|
||||||
|
decl_name: "struct mbuf"
|
||||||
|
symbol_kind: "struct"
|
||||||
|
signature: |
|
||||||
|
struct mbuf {
|
||||||
|
char *buf; /* Buffer pointer */
|
||||||
|
size_t len; /* Data length. Data is located between offset 0 and len. */
|
||||||
|
size_t size; /* Buffer size allocated by realloc(1). Must be >= len */
|
||||||
|
};
|
||||||
|
---
|
||||||
|
|
||||||
|
Memory buffer descriptor
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
title: "MQTT API reference"
|
||||||
|
symbol_kind: "intro"
|
||||||
|
decl_name: "mqtt.h"
|
||||||
|
items:
|
||||||
|
- { name: mg_set_protocol_mqtt.md }
|
||||||
|
- { name: mg_send_mqtt_handshake.md }
|
||||||
|
- { name: mg_send_mqtt_handshake_opt.md }
|
||||||
|
- { name: mg_mqtt_publish.md }
|
||||||
|
- { name: mg_mqtt_subscribe.md }
|
||||||
|
- { name: mg_mqtt_unsubscribe.md }
|
||||||
|
- { name: mg_mqtt_disconnect.md }
|
||||||
|
- { name: mg_mqtt_connack.md }
|
||||||
|
- { name: mg_mqtt_puback.md }
|
||||||
|
- { name: mg_mqtt_pubrec.md }
|
||||||
|
- { name: mg_mqtt_pubrel.md }
|
||||||
|
- { name: mg_mqtt_pubcomp.md }
|
||||||
|
- { name: mg_mqtt_suback.md }
|
||||||
|
- { name: mg_mqtt_unsuback.md }
|
||||||
|
- { name: mg_mqtt_ping.md }
|
||||||
|
- { name: mg_mqtt_pong.md }
|
||||||
|
- { name: mg_mqtt_next_subscribe_topic.md }
|
||||||
|
- { name: struct_mg_mqtt_topic_expression.md }
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_connack()"
|
||||||
|
decl_name: "mg_mqtt_connack"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_connack(struct mg_connection *nc, uint8_t return_code);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a CONNACK command with a given `return_code`.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_disconnect()"
|
||||||
|
decl_name: "mg_mqtt_disconnect"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_disconnect(struct mg_connection *nc);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a DISCONNECT command.
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_next_subscribe_topic()"
|
||||||
|
decl_name: "mg_mqtt_next_subscribe_topic"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
int mg_mqtt_next_subscribe_topic(struct mg_mqtt_message *msg,
|
||||||
|
struct mg_str *topic, uint8_t *qos, int pos);
|
||||||
|
---
|
||||||
|
|
||||||
|
Extracts the next topic expression from a SUBSCRIBE command payload.
|
||||||
|
|
||||||
|
The topic expression name will point to a string in the payload buffer.
|
||||||
|
Returns the pos of the next topic expression or -1 when the list
|
||||||
|
of topics is exhausted.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_ping()"
|
||||||
|
decl_name: "mg_mqtt_ping"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_ping(struct mg_connection *nc);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a PINGREQ command.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_pong()"
|
||||||
|
decl_name: "mg_mqtt_pong"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_pong(struct mg_connection *nc);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a PINGRESP command.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_puback()"
|
||||||
|
decl_name: "mg_mqtt_puback"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_puback(struct mg_connection *nc, uint16_t message_id);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a PUBACK command with a given `message_id`.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_pubcomp()"
|
||||||
|
decl_name: "mg_mqtt_pubcomp"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_pubcomp(struct mg_connection *nc, uint16_t message_id);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a PUBCOMP command with a given `message_id`.
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_publish()"
|
||||||
|
decl_name: "mg_mqtt_publish"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_publish(struct mg_connection *nc, const char *topic,
|
||||||
|
uint16_t message_id, int flags, const void *data,
|
||||||
|
size_t len);
|
||||||
|
---
|
||||||
|
|
||||||
|
Publishes a message to a given topic.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_pubrec()"
|
||||||
|
decl_name: "mg_mqtt_pubrec"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_pubrec(struct mg_connection *nc, uint16_t message_id);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a PUBREC command with a given `message_id`.
|
||||||
|
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_pubrel()"
|
||||||
|
decl_name: "mg_mqtt_pubrel"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_pubrel(struct mg_connection *nc, uint16_t message_id);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a PUBREL command with a given `message_id`.
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
title: "mg_mqtt_suback()"
|
||||||
|
decl_name: "mg_mqtt_suback"
|
||||||
|
symbol_kind: "func"
|
||||||
|
signature: |
|
||||||
|
void mg_mqtt_suback(struct mg_connection *nc, uint8_t *qoss, size_t qoss_len,
|
||||||
|
uint16_t message_id);
|
||||||
|
---
|
||||||
|
|
||||||
|
Sends a SUBACK command with a given `message_id`
|
||||||
|
and a sequence of granted QoSs.
|
||||||
|
|
||||||
Loaded 100 of 492 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user