aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/test_upgrade_ssl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/test_upgrade_ssl.c')
-rw-r--r--src/microhttpd/test_upgrade_ssl.c51
1 files changed, 40 insertions, 11 deletions
diff --git a/src/microhttpd/test_upgrade_ssl.c b/src/microhttpd/test_upgrade_ssl.c
index f0e6d09e..26fd53fa 100644
--- a/src/microhttpd/test_upgrade_ssl.c
+++ b/src/microhttpd/test_upgrade_ssl.c
@@ -55,6 +55,11 @@ static pthread_t pt;
55static MHD_socket usock; 55static MHD_socket usock;
56 56
57/** 57/**
58 * Thread we use to run the interaction with the upgraded socket.
59 */
60static pthread_t pt_client;
61
62/**
58 * Fork child that connects via OpenSSL to our @a port. Allows us to 63 * Fork child that connects via OpenSSL to our @a port. Allows us to
59 * talk to our port over a socket in @a sp without having to worry 64 * talk to our port over a socket in @a sp without having to worry
60 * about TLS. 65 * about TLS.
@@ -257,6 +262,31 @@ run_usock (void *cls)
257 262
258 263
259/** 264/**
265 * Main function for the thread that runs the client-side of the
266 * interaction with the upgraded socket.
267 *
268 * @param cls the client socket
269 */
270static void *
271run_usock_client (void *cls)
272{
273 MHD_socket *sock = cls;
274
275 send_all (*sock,
276 "GET / HTTP/1.1\r\nConnection: Upgrade\r\n\r\n");
277 recv_hdr (*sock);
278 recv_all (*sock,
279 "Hello");
280 send_all (*sock,
281 "World");
282 recv_all (*sock,
283 "Finished");
284 MHD_socket_close_ (*sock);
285 return NULL;
286}
287
288
289/**
260 * Function called after a protocol "upgrade" response was sent 290 * Function called after a protocol "upgrade" response was sent
261 * successfully and the socket should now be controlled by some 291 * successfully and the socket should now be controlled by some
262 * protocol other than HTTP. 292 * protocol other than HTTP.
@@ -418,19 +448,18 @@ test_upgrade_internal (int flags,
418 return 4; 448 return 4;
419 } 449 }
420 450
421 send_all (sock, 451 pthread_create (&pt_client,
422 "GET / HTTP/1.1\r\nConnection: Upgrade\r\n\r\n"); 452 NULL,
423 recv_hdr (sock); 453 &run_usock_client,
424 recv_all (sock, 454 &sock);
425 "Hello"); 455
426 send_all (sock, 456 pthread_join (pt_client,
427 "World"); 457 NULL);
428 recv_all (sock,
429 "Finished");
430 MHD_socket_close_ (sock);
431 pthread_join (pt, 458 pthread_join (pt,
432 NULL); 459 NULL);
433 waitpid (pid, NULL, 0); 460 waitpid (pid,
461 NULL,
462 0);
434 MHD_stop_daemon (d); 463 MHD_stop_daemon (d);
435 return 0; 464 return 0;
436} 465}