From: Eugene Adell Date: Sun, 26 Apr 2026 17:50:26 +0000 (+0200) Subject: demos/guide: switch clients to HTTP/1.1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28b235549c32595ec25bbb626c304bc031e5c843;p=thirdparty%2Fopenssl.git demos/guide: switch clients to HTTP/1.1 The Host Header comes with HTTP/1.1, not 1.0, and some Web Server now doesn't want to answer to such requests. Reviewed-by: Eugene Syromiatnikov Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell MergeDate: Sun May 3 15:21:35 2026 (Merged from https://github.com/openssl/openssl/pull/30981) --- diff --git a/demos/guide/quic-client-block.c b/demos/guide/quic-client-block.c index dd3e1e12a51..805569d8eb1 100644 --- a/demos/guide/quic-client-block.c +++ b/demos/guide/quic-client-block.c @@ -109,8 +109,8 @@ static BIO *create_socket_bio(const char *hostname, const char *port, } /* - * Simple application to send a basic HTTP/1.0 request to a server and - * print the response on the screen. Note that HTTP/1.0 over QUIC is + * Simple application to send a basic HTTP/1.1 request to a server and + * print the response on the screen. Note that HTTP/1.1 over QUIC is * non-standard and will not typically be supported by real world servers. This * is for demonstration purposes only. */ @@ -121,8 +121,8 @@ int main(int argc, char *argv[]) BIO *bio = NULL; int res = EXIT_FAILURE; int ret; - unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '1', '.', '0' }; - const char *request_start = "GET / HTTP/1.0\r\nConnection: close\r\nHost: "; + unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '1', '.', '1' }; + const char *request_start = "GET / HTTP/1.1\r\nConnection: close\r\nHost: "; const char *request_end = "\r\n\r\n"; size_t written, readbytes; char buf[160]; diff --git a/demos/guide/quic-client-non-block.c b/demos/guide/quic-client-non-block.c index 34a0000788e..02712857733 100644 --- a/demos/guide/quic-client-non-block.c +++ b/demos/guide/quic-client-non-block.c @@ -216,8 +216,8 @@ static int handle_io_failure(SSL *ssl, int res) } } /* - * Simple application to send a basic HTTP/1.0 request to a server and - * print the response on the screen. Note that HTTP/1.0 over QUIC is + * Simple application to send a basic HTTP/1.1 request to a server and + * print the response on the screen. Note that HTTP/1.1 over QUIC is * non-standard and will not typically be supported by real world servers. This * is for demonstration purposes only. */ @@ -228,8 +228,8 @@ int main(int argc, char *argv[]) BIO *bio = NULL; int res = EXIT_FAILURE; int ret; - unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '1', '.', '0' }; - const char *request_start = "GET / HTTP/1.0\r\nConnection: close\r\nHost: "; + unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '1', '.', '1' }; + const char *request_start = "GET / HTTP/1.1\r\nConnection: close\r\nHost: "; const char *request_end = "\r\n\r\n"; size_t written, readbytes = 0; char buf[160]; diff --git a/demos/guide/quic-multi-stream.c b/demos/guide/quic-multi-stream.c index 8d3170593df..fd922432255 100644 --- a/demos/guide/quic-multi-stream.c +++ b/demos/guide/quic-multi-stream.c @@ -126,8 +126,8 @@ static int write_a_request(SSL *stream, const char *request_start, } /* - * Simple application to send basic HTTP/1.0 requests to a server and print the - * response on the screen. Note that HTTP/1.0 over QUIC is not a real protocol + * Simple application to send basic HTTP/1.1 requests to a server and print the + * response on the screen. Note that HTTP/1.1 over QUIC is not a real protocol * and will not be supported by real world servers. This is for demonstration * purposes only. */ @@ -139,9 +139,9 @@ int main(int argc, char *argv[]) BIO *bio = NULL; int res = EXIT_FAILURE; int ret; - unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '1', '.', '0' }; - const char *request1_start = "GET /request1.html HTTP/1.0\r\nConnection: close\r\nHost: "; - const char *request2_start = "GET /request2.html HTTP/1.0\r\nConnection: close\r\nHost: "; + unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '1', '.', '1' }; + const char *request1_start = "GET /request1.html HTTP/1.1\r\nConnection: close\r\nHost: "; + const char *request2_start = "GET /request2.html HTTP/1.1\r\nConnection: close\r\nHost: "; size_t readbytes; char buf[160]; BIO_ADDR *peer_addr = NULL; @@ -351,7 +351,7 @@ int main(int argc, char *argv[]) } /* - * In our hypothetical HTTP/1.0 over QUIC protocol that we are using we + * In our hypothetical HTTP/1.1 over QUIC protocol that we are using we * assume that the server will respond with a server initiated stream * containing the data requested in our uni-directional stream. This doesn't * really make sense to do in a real protocol, but its just for diff --git a/demos/guide/quic-server-block.c b/demos/guide/quic-server-block.c index 3ec6d885ae0..434516679b3 100644 --- a/demos/guide/quic-server-block.c +++ b/demos/guide/quic-server-block.c @@ -268,7 +268,7 @@ err: return ok; } -/* Minimal QUIC HTTP/1.0 server. */ +/* Minimal QUIC HTTP/1.1 server. */ int main(int argc, char *argv[]) { int res = EXIT_FAILURE; diff --git a/demos/guide/quic-server-non-block.c b/demos/guide/quic-server-non-block.c index 3a5c0b63ce3..eb954f9f79f 100644 --- a/demos/guide/quic-server-non-block.c +++ b/demos/guide/quic-server-non-block.c @@ -454,7 +454,7 @@ err: return ok; } -/* Minimal QUIC HTTP/1.0 server. */ +/* Minimal QUIC HTTP/1.1 server. */ int main(int argc, char *argv[]) { int res = EXIT_FAILURE; diff --git a/demos/guide/tls-client-block.c b/demos/guide/tls-client-block.c index 57119d8620c..c94e09cc079 100644 --- a/demos/guide/tls-client-block.c +++ b/demos/guide/tls-client-block.c @@ -94,7 +94,7 @@ static BIO *create_socket_bio(const char *hostname, const char *port, int family } /* - * Simple application to send a basic HTTP/1.0 request to a server and + * Simple application to send a basic HTTP/1.1 request to a server and * print the response on the screen. */ int main(int argc, char *argv[]) @@ -104,7 +104,7 @@ int main(int argc, char *argv[]) BIO *bio = NULL; int res = EXIT_FAILURE; int ret; - const char *request_start = "GET / HTTP/1.0\r\nConnection: close\r\nHost: "; + const char *request_start = "GET / HTTP/1.1\r\nConnection: close\r\nHost: "; const char *request_end = "\r\n\r\n"; size_t written, readbytes; char buf[160]; diff --git a/demos/guide/tls-client-non-block.c b/demos/guide/tls-client-non-block.c index aafd7dadb48..9c21a5df1e1 100644 --- a/demos/guide/tls-client-non-block.c +++ b/demos/guide/tls-client-non-block.c @@ -171,7 +171,7 @@ static int handle_io_failure(SSL *ssl, int res) } /* - * Simple application to send a basic HTTP/1.0 request to a server and + * Simple application to send a basic HTTP/1.1 request to a server and * print the response on the screen. */ int main(int argc, char *argv[]) @@ -181,7 +181,7 @@ int main(int argc, char *argv[]) BIO *bio = NULL; int res = EXIT_FAILURE; int ret; - const char *request_start = "GET / HTTP/1.0\r\nConnection: close\r\nHost: "; + const char *request_start = "GET / HTTP/1.1\r\nConnection: close\r\nHost: "; const char *request_end = "\r\n\r\n"; size_t written, readbytes = 0; char buf[160]; diff --git a/doc/man7/ossl-guide-quic-client-block.pod b/doc/man7/ossl-guide-quic-client-block.pod index 394580b2de1..9d5bc62da53 100644 --- a/doc/man7/ossl-guide-quic-client-block.pod +++ b/doc/man7/ossl-guide-quic-client-block.pod @@ -16,7 +16,7 @@ ossl-guide-quic-client-block This page will present various source code samples demonstrating how to write a simple blocking QUIC client application which connects to a server, sends an -HTTP/1.0 request to it, and reads back the response. Note that HTTP/1.0 over +HTTP/1.1 request to it, and reads back the response. Note that HTTP/1.1 over QUIC is non-standard and will not be supported by real world servers. This is for demonstration purposes only. @@ -205,7 +205,7 @@ simple client that we developed in L did not use it. However QUIC mandates that the TLS handshake used in establishing a QUIC connection must use ALPN. - unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '1', '.', '0' }; + unsigned char alpn[] = { 8, 'h', 't', 't', 'p', '/', '1', '.', '1' }; /* SSL_set_alpn_protos returns 0 for success! */ if (SSL_set_alpn_protos(ssl, alpn, sizeof(alpn)) != 0) { @@ -215,7 +215,7 @@ connection must use ALPN. The ALPN is specified using a length prefixed array of unsigned chars (it is not a NUL terminated string). Our original TLS blocking client demo was using -HTTP/1.0. We will use the same for this example. Unlike most OpenSSL functions +HTTP/1.1. We will use the same for this example. Unlike most OpenSSL functions L returns zero for success and nonzero for failure. =head2 Setting the peer address diff --git a/doc/man7/ossl-guide-quic-multi-stream.pod b/doc/man7/ossl-guide-quic-multi-stream.pod index 1493d1c2b2e..f2b8084bd5a 100644 --- a/doc/man7/ossl-guide-quic-multi-stream.pod +++ b/doc/man7/ossl-guide-quic-multi-stream.pod @@ -159,7 +159,7 @@ object it will return NULL. This section will present various source code samples demonstrating how to write a simple multi-stream QUIC client application which connects to a server, send -some HTTP/1.0 requests to it, and read back the responses. Note that HTTP/1.0 +some HTTP/1.1 requests to it, and read back the responses. Note that HTTP/1.1 over QUIC is non-standard and will not be supported by real world servers. This is for demonstration purposes only. @@ -349,7 +349,7 @@ arrived and is available for us to accept. In the event of an error it will return B. /* - * In our hypothetical HTTP/1.0 over QUIC protocol that we are using we + * In our hypothetical HTTP/1.1 over QUIC protocol that we are using we * assume that the server will respond with a server initiated stream * containing the data requested in our uni-directional stream. This doesn't * really make sense to do in a real protocol, but its just for diff --git a/doc/man7/ossl-guide-quic-server-block.pod b/doc/man7/ossl-guide-quic-server-block.pod index d44c60613fb..ec78a0ada85 100644 --- a/doc/man7/ossl-guide-quic-server-block.pod +++ b/doc/man7/ossl-guide-quic-server-block.pod @@ -19,7 +19,7 @@ simple, non-concurrent, QUIC "echo" server application which accepts one client connection at a time, echoing input from the client back to the same client. Once the current client disconnects, the next client connection is accepted. -The server only accepts HTTP/1.0 requests, which is non-standard and will not +The server only accepts HTTP/1.1 requests, which is non-standard and will not be supported by real world servers. This is for demonstration purposes only. Both the accepting socket and client connections are "blocking". A more typical @@ -130,14 +130,14 @@ select an ALPN the server considers acceptable. /* Setup ALPN negotiation callback to decide which ALPN is accepted. */ SSL_CTX_set_alpn_select_cb(ctx, select_alpn, NULL); -In this case, we only accept "http/1.0" and "hq-interop". +In this case, we only accept "http/1.1" and "hq-interop". /* - * ALPN strings for TLS handshake. Only 'http/1.0' and 'hq-interop' + * ALPN strings for TLS handshake. Only 'http/1.1' and 'hq-interop' * are accepted. */ static const unsigned char alpn_ossltest[] = { - 8, 'h', 't', 't', 'p', '/', '1', '.', '0', + 8, 'h', 't', 't', 'p', '/', '1', '.', '1', 10, 'h', 'q', '-', 'i', 'n', 't', 'e', 'r', 'o', 'p', }; diff --git a/doc/man7/ossl-guide-quic-server-non-block.pod b/doc/man7/ossl-guide-quic-server-non-block.pod index d5f0b91dff7..2a5cfaa603a 100644 --- a/doc/man7/ossl-guide-quic-server-non-block.pod +++ b/doc/man7/ossl-guide-quic-server-non-block.pod @@ -19,14 +19,14 @@ simple, non-concurrent, QUIC "echo" server application which accepts one client connection at a time, echoing input from the client back to the same client. Once the current client disconnects, the next client connection is accepted. -The server only accepts C and C ALPN's and doesn't actually +The server only accepts C and C ALPN's and doesn't actually implement HTTP but only does a simple echo. This is non-standard and will not be supported by real world servers. This is for demonstration purposes only. There are various methods to test this server: B and -B will send a basic HTTP/1.0 request, which the server +B will send a basic HTTP/1.1 request, which the server will echo back. You can also test this server by running -C and entering +C and entering text that will be echoed back by the server. Both the listening socket and connected socket are "nonblocking". However, @@ -140,14 +140,14 @@ select an ALPN the server considers acceptable. /* Setup ALPN negotiation callback to decide which ALPN is accepted. */ SSL_CTX_set_alpn_select_cb(ctx, select_alpn, NULL); -In this case, we only accept "http/1.0" and "hq-interop". +In this case, we only accept "http/1.1" and "hq-interop". /* - * ALPN strings for TLS handshake. Only 'http/1.0' and 'hq-interop' + * ALPN strings for TLS handshake. Only 'http/1.1' and 'hq-interop' * are accepted. */ static const unsigned char alpn_ossltest[] = { - 8, 'h', 't', 't', 'p', '/', '1', '.', '0', + 8, 'h', 't', 't', 'p', '/', '1', '.', '1', 10, 'h', 'q', '-', 'i', 'n', 't', 'e', 'r', 'o', 'p', }; diff --git a/doc/man7/ossl-guide-tls-client-block.pod b/doc/man7/ossl-guide-tls-client-block.pod index dc731e66859..e508eb23ecd 100644 --- a/doc/man7/ossl-guide-tls-client-block.pod +++ b/doc/man7/ossl-guide-tls-client-block.pod @@ -15,7 +15,7 @@ ossl-guide-tls-client-block =head1 SIMPLE BLOCKING TLS CLIENT EXAMPLE This page will present various source code samples demonstrating how to write -a simple TLS client application which connects to a server, sends an HTTP/1.0 +a simple TLS client application which connects to a server, sends an HTTP/1.1 request to it, and reads back the response. We use a blocking socket for the purposes of this example. This means that @@ -353,7 +353,7 @@ chunks. First we write the start of the request. Secondly we write the hostname we are sending the request to. Finally we send the end of the request. size_t written; - const char *request_start = "GET / HTTP/1.0\r\nConnection: close\r\nHost: "; + const char *request_start = "GET / HTTP/1.1\r\nConnection: close\r\nHost: "; const char *request_end = "\r\n\r\n"; /* Write an HTTP GET request to the peer */