После соответствующих инициализаций существует бесконечный цикл для обслуживания входящих HTTPS-запросов, но только одно соединение на запрос (и при условии, что запросы требуют только одного чтения):
while TRUE do
begin // wait for incoming TCP connection
if listen(listen_socket, 100) 0 then continue; // listen failed
client_len := SizeOf(sa_cli);
sock := accept(listen_socket, @sa_cli, @client_len); // create socket for connection
if sock = INVALID_SOCKET then continue; // accept failed
ssl := SSL_new(ctx); // TCP connection ready, create ssl structure
if assigned(ssl) then
begin
SSL_set_fd(ssl, sock); // assign socket to ssl structure
if SSL_accept(ssl) = 1 then // handshake worked
begin
bytesin := SSL_read(ssl, buffer, sizeof(buffer)-1);
if bytesin > 0 then
begin
buffer[bytesin] := #0;
// decide on response here...
response := 'HTTP/1.0 200 OK'#13#10 + etc;
SSL_write(ssl, pchar(response)^, length(response));
end; // else read empty or failed
end; // else handshake failed
SSL_set_shutdown(ssl, SSL_SENT_SHUTDOWN or SSL_RECEIVED_SHUTDOWN);
CloseSocket(sock);
SSL_free(ssl);
end; // else ssl creation failed
end; // while
меняется
if ssl_accept(ssl) = 1 then
до
while ssl_accept(ssl) = 1 do
все, что необходимо для правильной поддержки поддержки HTTP 1.1 по умолчанию (т. Е. Нескольких запросов на соединение)?