forked from etr/libhttpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlibhttpserver.texi
More file actions
312 lines (229 loc) · 9.96 KB
/
libhttpserver.texi
File metadata and controls
312 lines (229 loc) · 9.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
\input texinfo
@setfilename libhttpserver.info
@include version.texi
@settitle The libhttpserver Reference Manual
@c Unify all the indices into concept index.
@syncodeindex fn cp
@syncodeindex vr cp
@syncodeindex ky cp
@syncodeindex pg cp
@syncodeindex tp cp
@copying
This manual is for libhttpserver
(version @value{VERSION}, @value{UPDATED}), C++ library for creating an
embedded Rest HTTP server (and more).
Copyright @copyright{} 2011--2013 Sebastiano Merlino
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. A copy of the license is included in the section entitled "GNU
Free Documentation License".
@end quotation
@end copying
@dircategory Software libraries
@direntry
* libhttpserver: (libhttpserver). C++ library for creating an
embedded Rest HTTP server (and more).
@end direntry
@c
@c Titlepage
@c
@titlepage
@title The libhttpserver Reference Manual
@subtitle Version @value{VERSION}
@subtitle @value{UPDATED}
@author Sebastiano Merlino (@email{electrictwister2000@@gmail.com})
@page
@vskip 0pt plus 1filll
@insertcopying
@end titlepage
@ifnottex
@node Top
@top The libhttpserver Library
@insertcopying
@end ifnottex
@c @summarycontents
@c @contents
@c ------------------------------------------------------------
@menu
* httpserver-intro:: Introduction.
* httpserver-const:: Constants.
* httpserver-struct:: Structures and classes type definition.
* httpserver-cb:: Callback functions definition.
* httpserver-init:: Create and work with server.
* httpserver-resources:: Registering resources.
* httpserver-responses:: Building responses to requests.
* httpserver-bans:: Whitelists and Blacklists.
* httpserver-comet:: Simple comet semantics.
* httpserver-dauth:: Utilizing Authentication.
* httpserver-info:: Obtaining and modifying status information.
Appendices
* GNU-LGPL:: The GNU Lesser General Public License says how you
can copy and share almost all of `libhttpserver'.
* GNU-FDL:: The GNU Free Documentation License says how you
can copy and share the documentation of `libhttpserver'.
Indices
* Concept Index:: Index of concepts and programs.
* Function and Data Index:: Index of functions, variables and data types.
* Type Index:: Index of data types.
@end menu
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-intro
@chapter Introduction
@noindent
libhttpserver is meant to constitute an easy system to build HTTP
servers with REST fashion.
libhttpserver is based on libmicrohttpd and, like this, it is a
daemon library.
The mission of this library is to support all possible HTTP features
directly and with a simple semantic allowing then the user to concentrate
only on his application and not on HTTP request handling details.
The library is supposed to work transparently for the client Implementing
the business logic and using the library itself to realize an interface.
If the user wants it must be able to change every behavior of the library
itself through the registration of callbacks.
Like the api is based on (libmicrohttpd), libhttpserver is able to decode
certain body format a and automatically format them in object oriented
fashion. This is true for query arguments and for @code{POST} and @code{PUT}
requests bodies if @code{application/x-www-form-urlencoded} or
@code{multipart/form-data} header are passed.
The header reproduce all the constants defined by libhttpserver.
These maps various constant used by the HTTP protocol that are exported
as a convenience for users of the library. Is is possible for the user
to define their own extensions of the HTTP standard and use those with
libhttpserver.
All functions are guaranteed to be completely reentrant and
thread-safe.
Additionally, clients can specify resource limits on the overall
number of connections, number of connections per IP address and memory
used per connection to avoid resource exhaustion.
@section Compiling libhttpserver
@cindex compilation
@cindex embedded systems
@cindex portability
libhttpserver uses the standard system where the usual build process
involves running
@verbatim
$ ./bootstrap
$ mkdir build
$ cd build
$ ./configure
$ make
$ make install
@end verbatim
@c ------------------------------------------------------------
@node httpserver-const
@chapter Constants
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-struct
@chapter Structures and classes type definition
@deftp {CPP Class} http_resource
Represents the resource corresponding to a specific endpoint.
@end deftp
@deftp {CPP Class} http_request
Represents the request received by the resource that process it.
@end deftp
@deftp {CPP Class} http_response
Represents the response sent by the server once the resource
finished its work.
@end deftp
@deftp {CPP Class} webserver
Represents the daemon listening on a socket for HTTP traffic.
@end deftp
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-cb
@chapter Callback functions definition
Callbacks are functions defined by the client and then used by the library. This way
it is possible to extend the library itself.
@deftypefn {Function Pointer} void {*log_access_ptr} (const std::string& uri)
Invoked by the library when a new connection is opened by the client.
@table @var
@item uri
A string containing the uri called by the client and the method it used.
@end table
@end deftypefn
@deftypefn {Function Pointer} void {*log_error_ptr} (const std::string& message)
Invoked by the library to send error messages.
@table @var
@item message
A string containing the message to log.
@end table
@end deftypefn
@deftypefn {Function Pointer} void {*unescaper_ptr} (char* uri)
Invoked by the library to unescape the uri requested by the client.
If no unescaper_ptr is passed to the webserver it uses the internal defined
unescaper function.
@table @var
@item uri
A c-style string containing the uri to unescape.
@end table
@end deftypefn
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-init
@chapter Create and work with server
@deftypemethod {webserver}{} webserver (int port, const http_utils::start_method_T& start_method, int max_threads, int max_connections, int memory_limit, int connection_timeout, int per_IP_connection_limit, log_access_ptr log_access, log_error_ptr log_error, validator_ptr validator, unescaper_ptr unescaper, const struct sockaddr* bind_address, int bind_socket, int max_thread_stack_size, bool use_ssl, bool use_ipv6, bool debug, bool pedantic, const std::string& https_mem_key, const std::string& https_mem_cert, const std::string& https_mem_trust, const std::string& https_mem_priorities, const http_utils::cred_type_T& cred_type, const std::string digest_auth_random, int nonce_nc_size, const http_utils::policy_T& default_policy, bool basic_auth_enabled, bool digest_auth_enabled, bool regex_checking, bool ban_system_enabled, bool post_process_enabled, render_ptr single_resource, render_ptr not_found_resource, render_ptr method_not_allowed_resource, render_ptr method_not_acceptable_resource, render_ptr internal_error_resource)
@end deftypemethod
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c -----------------------------------------------------------
@node httpserver-resources
@chapter Registering resources
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-responses
@chapter Building responses to requests
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@c @node httpserver-response create
@c @section Creating a response object
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@c @node httpserver-response headers
@c @section Adding headers to a response
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@c @node httpserver-response inspect
@c @section Inspecting a response object
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-dauth
@chapter Utilizing Authentication
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-info
@chapter Obtaining and modifying status information.
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-bans
@chapter AAAA
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c ------------------------------------------------------------
@node httpserver-comet
@chapter AAAA
@c ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@c **********************************************************
@c ******************* Appendices *************************
@c **********************************************************
@node GNU-LGPL
@unnumbered GNU-LGPL
@cindex license
@include lgpl.texi
@node GNU-FDL
@unnumbered GNU-FDL
@cindex license
@include fdl-1.3.texi
@node Concept Index
@unnumbered Concept Index
@printindex cp
@node Function and Data Index
@unnumbered Function and Data Index
@printindex fn
@node Type Index
@unnumbered Type Index
@printindex tp
@bye