Initialize global state in the server examples
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
http_global_init();
|
||||
|
||||
// Choose the interface to listen on and the port.
|
||||
// Currently, servers can only bind to IPv4 addresses.
|
||||
HTTP_String addr = HTTP_STR("127.0.0.1");
|
||||
@@ -90,6 +92,7 @@ int main(void)
|
||||
// your server in a way to exit gracefully, this is
|
||||
// you the server object is freed:
|
||||
http_server_free(server);
|
||||
http_global_free();
|
||||
|
||||
// Have fun. Bye!
|
||||
return 0;
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
http_global_init();
|
||||
|
||||
// All the setup is identical to the previous example.
|
||||
// The only thing that changes where "http_response_body"
|
||||
// is called.
|
||||
@@ -90,5 +92,6 @@ int main(void)
|
||||
}
|
||||
|
||||
http_server_free(server);
|
||||
http_global_free();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
http_global_init();
|
||||
|
||||
HTTP_Server *server = http_server_init(HTTP_STR("127.0.0.1"), 8080);
|
||||
if (server == NULL)
|
||||
return -1;
|
||||
@@ -52,5 +54,6 @@ int main(void)
|
||||
}
|
||||
|
||||
http_server_free(server);
|
||||
http_global_free();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ ThreadReturn worker(void*)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
http_global_free();
|
||||
init_job_queue();
|
||||
|
||||
HTTP_Server *server = http_server_init(HTTP_STR("127.0.0.1"), 8080);
|
||||
@@ -177,6 +178,7 @@ int main(void)
|
||||
|
||||
http_server_free(server);
|
||||
free_job_queue();
|
||||
http_global_free();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
http_global_init();
|
||||
|
||||
// To setup an HTTPS server, we need to use the *_ex variant
|
||||
// of the server initialization function as it offers more
|
||||
// control. Server objects can serve HTTP traffic, HTTPS
|
||||
@@ -71,5 +73,6 @@ int main(void)
|
||||
}
|
||||
|
||||
http_server_free(server);
|
||||
http_global_free();
|
||||
return 0;
|
||||
}
|
||||
@@ -8,6 +8,8 @@ int setup_test_certificates(void);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
http_global_init();
|
||||
|
||||
// First, create three certificates for the domains:
|
||||
//
|
||||
// websiteA.com
|
||||
@@ -118,6 +120,7 @@ int main(void)
|
||||
}
|
||||
|
||||
http_server_free(server);
|
||||
http_global_free();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user