|
@@ -258,7 +258,7 @@ directory is commonly referenced as dot (`.`).
|
|
Path to SSL certificate file. This option is only required when at least one
|
|
Path to SSL certificate file. This option is only required when at least one
|
|
of the `listening_ports` is SSL. The file must be in PEM format,
|
|
of the `listening_ports` is SSL. The file must be in PEM format,
|
|
and it must have both private key and certificate, see for example
|
|
and it must have both private key and certificate, see for example
|
|
-[ssl_cert.pem](https://github.com/valenok/civetweb/blob/master/build/ssl_cert.pem)
|
|
|
|
|
|
+[ssl_cert.pem](https://github.com/sunsetbrew/civetweb/blob/master/build/ssl_cert.pem)
|
|
|
|
|
|
### num_threads `50`
|
|
### num_threads `50`
|
|
Number of worker threads. Civetweb handles each incoming connection in a
|
|
Number of worker threads. Civetweb handles each incoming connection in a
|
|
@@ -332,10 +332,10 @@ are accessible from the Lua code (please check reference manual for details),
|
|
and also information about the request is available in `mg.request_info` object,
|
|
and also information about the request is available in `mg.request_info` object,
|
|
like request method, all headers, etcetera. Please refer to
|
|
like request method, all headers, etcetera. Please refer to
|
|
`struct mg_request_info` definition in
|
|
`struct mg_request_info` definition in
|
|
-[civetweb.h](https://github.com/valenok/civetweb/blob/master/civetweb.h)
|
|
|
|
|
|
+[civetweb.h](https://github.com/sunsetbrew/civetweb/blob/master/civetweb.h)
|
|
to see what kind of information is present in `mg.request_info` object. Also,
|
|
to see what kind of information is present in `mg.request_info` object. Also,
|
|
-[page.lp](https://github.com/valenok/civetweb/blob/master/test/page.lp) and
|
|
|
|
-[prime_numbers.lp](https://github.com/valenok/civetweb/blob/master/examples/lua/prime_numbers.lp)
|
|
|
|
|
|
+[page.lp](https://github.com/sunsetbrew/civetweb/blob/master/test/page.lp) and
|
|
|
|
+[prime_numbers.lp](https://github.com/sunsetbrew/civetweb/blob/master/examples/lua/prime_numbers.lp)
|
|
contains some example code that uses `request_info` and other functions(form submitting for example).
|
|
contains some example code that uses `request_info` and other functions(form submitting for example).
|
|
|
|
|
|
Civetweb exports the following to the Lua server page:
|
|
Civetweb exports the following to the Lua server page:
|
|
@@ -397,59 +397,8 @@ variable is visible in the block that follows.
|
|
flag in Visual Studio compiler.
|
|
flag in Visual Studio compiler.
|
|
|
|
|
|
# Embedding
|
|
# Embedding
|
|
-Embedding Civetweb is easy. Copy
|
|
|
|
-[civetweb.c](https://github.com/valenok/civetweb/blob/master/civetweb.c) and
|
|
|
|
-[civetweb.h](https://github.com/valenok/civetweb/blob/master/civetweb.h)
|
|
|
|
-to your application's source tree and include them in the build. For
|
|
|
|
-example, your application's code lives in C file `my_app.c`, then on UNIX
|
|
|
|
-this command embeds Civetweb:
|
|
|
|
-
|
|
|
|
- $ ls
|
|
|
|
- my_app.c civetweb.c civetweb.h
|
|
|
|
- $ gcc my_app.c civetweb.c -o my_app -ldl -pthread
|
|
|
|
-
|
|
|
|
-Somewhere in the application code, call `mg_start()` to start the server.
|
|
|
|
-Pass configuration options and event handlers to `mg_start()`.
|
|
|
|
-Civetweb then calls handlers when certain events happen.
|
|
|
|
-For example, when new request arrives, Civetweb calls `begin_request`
|
|
|
|
-handler function to let user handle the request. In the handler, user code
|
|
|
|
-can get all information about the request -- parsed headers, etcetera.
|
|
|
|
-
|
|
|
|
-Civetweb API is logically divided in three categories: server setup/shutdown
|
|
|
|
-functions, functions to be used by user-written event handlers, and
|
|
|
|
-convenience utility functions.
|
|
|
|
-
|
|
|
|
-### Starting and stopping embedded web server
|
|
|
|
-To start the embedded web server, call `mg_start()`. To stop it, call
|
|
|
|
-`mg_stop()`.
|
|
|
|
-
|
|
|
|
- // This structure needs to be passed to mg_start(), to let civetweb know
|
|
|
|
- // which callbacks to invoke. For detailed description, see
|
|
|
|
- // https://github.com/valenok/civetweb/blob/master/UserManual.md
|
|
|
|
- struct mg_callbacks {
|
|
|
|
- int (*begin_request)(struct mg_connection *);
|
|
|
|
- void (*end_request)(const struct mg_connection *, int reply_status_code);
|
|
|
|
- int (*log_message)(const struct mg_connection *, const char *message);
|
|
|
|
- int (*init_ssl)(void *ssl_context);
|
|
|
|
- int (*websocket_connect)(const struct mg_connection *);
|
|
|
|
- void (*websocket_ready)(struct mg_connection *);
|
|
|
|
- int (*websocket_data)(struct mg_connection *);
|
|
|
|
- const char * (*open_file)(const struct mg_connection *,
|
|
|
|
- const char *path, size_t *data_len);
|
|
|
|
- void (*init_lua)(struct mg_connection *, void *lua_context);
|
|
|
|
- void (*upload)(struct mg_connection *, const char *file_name);
|
|
|
|
- int (*http_error)(struct mg_connection *, int status);
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
-[hello.c](https://github.com/valenok/civetweb/blob/master/examples/hello.c)
|
|
|
|
-provides a minimalistic example.
|
|
|
|
-
|
|
|
|
-Common pattern is to implement `begin_request` callback, and serve static files
|
|
|
|
-from memory, and/or construct dynamic replies on the fly. Here is
|
|
|
|
-my [embed.c](https://gist.github.com/valenok/4714740) gist
|
|
|
|
-that shows how to easily any data can be embedded
|
|
|
|
-directly into the executable. If such data needs to be encrypted, then
|
|
|
|
-encrypted database or encryption dongles would be a better choice.
|
|
|
|
|
|
+
|
|
|
|
+See [Embedding.md](https://github.com/sunsetbrew/civetweb/blob/master/Embedding.md) for more information.
|
|
|
|
|
|
# Build on Android
|
|
# Build on Android
|
|
|
|
|
|
@@ -502,7 +451,7 @@ limit on number of simultaneous requests that can be handled by civetweb.
|
|
|
|
|
|
When master thread accepts new connection, a new accepted socket (described by
|
|
When master thread accepts new connection, a new accepted socket (described by
|
|
`struct socket`) it placed into the accepted sockets queue,
|
|
`struct socket`) it placed into the accepted sockets queue,
|
|
-which has size of 20 (see [code](https://github.com/valenok/civetweb/blob/3892e0199e6ca9613b160535d9d107ede09daa43/civetweb.c#L486)). Any idle worker thread
|
|
|
|
|
|
+which has size of 20 (see [code](https://github.com/sunsetbrew/civetweb/blob/3892e0199e6ca9613b160535d9d107ede09daa43/civetweb.c#L486)). Any idle worker thread
|
|
can grab accepted sockets from that queue. If all worker threads are busy,
|
|
can grab accepted sockets from that queue. If all worker threads are busy,
|
|
master thread can accept and queue up to 20 more TCP connections,
|
|
master thread can accept and queue up to 20 more TCP connections,
|
|
filling up the queue.
|
|
filling up the queue.
|