Skip to content

Commit 1402238

Browse files
committed
Port http load test to SSL/non-SSL
1 parent 68fcce6 commit 1402238

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/http_load_test.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
#include <libusockets.h>
44

5+
#ifndef LIBUS_NO_SSL
6+
#define us_socket us_ssl_socket
7+
#define us_socket_context us_ssl_socket_context
8+
#define us_socket_write us_ssl_socket_write
9+
#define us_socket_close us_ssl_socket_close
10+
#define us_socket_shutdown us_ssl_socket_shutdown
11+
#define us_socket_context_on_end us_ssl_socket_context_on_end
12+
#define us_socket_context_on_open us_ssl_socket_context_on_open
13+
#define us_socket_context_on_close us_ssl_socket_context_on_close
14+
#define us_socket_context_on_writable us_ssl_socket_context_on_writable
15+
#define us_socket_context_on_data us_ssl_socket_context_on_data
16+
#define us_socket_context_on_timeout us_ssl_socket_context_on_timeout
17+
#define us_socket_ext us_ssl_socket_ext
18+
#define us_socket_context_ext us_ssl_socket_context_ext
19+
#define us_socket_get_context us_ssl_socket_get_context
20+
#define us_socket_context_listen us_ssl_socket_context_listen
21+
#define us_socket_timeout us_ssl_socket_timeout
22+
#define us_socket_context_connect us_ssl_socket_context_connect
23+
#endif
24+
525
#include <stdio.h>
626
#include <stdlib.h>
727
#include <string.h>
@@ -103,7 +123,12 @@ int main(int argc, char **argv) {
103123
struct us_loop *loop = us_create_loop(1, on_wakeup, on_pre, on_post, 0);
104124

105125
/* Create a socket context for HTTP */
126+
#ifndef LIBUS_NO_SSL
127+
struct us_ssl_socket_context_options ssl_options = {};
128+
struct us_socket_context *http_context = us_create_ssl_socket_context(loop, 0, ssl_options);
129+
#else
106130
struct us_socket_context *http_context = us_create_socket_context(loop, 0);
131+
#endif
107132

108133
/* Set up event handlers */
109134
us_socket_context_on_open(http_context, on_http_socket_open);

0 commit comments

Comments
 (0)