@@ -1,7 +1,7 @@ /* - * Copyright (c) 2008-2021 Jonathan Schleifer + * Copyright (c) 2008-2022 Jonathan Schleifer * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in @@ -25,10 +25,11 @@ @class OFHTTPClient; @class OFHTTPRequest; @class OFHTTPResponse; @class OFStream; @class OFTCPSocket; +@class OFTLSStream; @class OFURL; /** * @protocol OFHTTPClientDelegate OFHTTPClient.h ObjFW/OFHTTPClient.h * @@ -48,24 +49,36 @@ response: (nullable OFHTTPResponse *)response exception: (nullable id)exception; @optional /** - * @brief A callback which is called when an OFHTTPClient creates a socket. - * - * This is useful if the connection is using HTTPS and the server requires a - * client certificate. This callback can then be used to tell the TLS socket - * about the certificate. Another use case is to tell the socket about a SOCKS5 - * proxy it should use for this connection. - * - * @param client The OFHTTPClient that created a socket - * @param socket The socket created by the OFHTTPClient - * @param request The request for which the socket was created - */ -- (void)client: (OFHTTPClient *)client - didCreateSocket: (OFTCPSocket *)socket - request: (OFHTTPRequest *)request; + * @brief A callback which is called when an OFHTTPClient creates a TCP socket. + * + * This can be used to tell the socket about a SOCKS5 proxy it should use for + * this connection. + * + * @param client The OFHTTPClient that created a TCP socket + * @param TCPSocket The socket created by the OFHTTPClient + * @param request The request for which the TCP socket was created + */ +- (void)client: (OFHTTPClient *)client + didCreateTCPSocket: (OFTCPSocket *)TCPSocket + request: (OFHTTPRequest *)request; + +/** + * @brief A callback which is called when an OFHTTPClient creates a TLS stream. + * + * This can be used to tell the TLS stream about a client certificate it should + * use before performing the TLS handshake. + * + * @param client The OFHTTPClient that created a TLS stream + * @param TLSStream The TLS stream created by the OFHTTPClient + * @param request The request for which the TLS stream was created + */ +- (void)client: (OFHTTPClient *)client + didCreateTLSStream: (OFTLSStream *)TLSStream + request: (OFHTTPRequest *)request; /** * @brief A callback which is called when an OFHTTPClient wants to send the * body for a request. * @@ -134,11 +147,11 @@ #ifdef OF_HTTPCLIENT_M @public #endif OFObject *_Nullable _delegate; bool _allowsInsecureRedirects, _inProgress; - OFTCPSocket *_Nullable _socket; + OFStream *_Nullable _stream; OFURL *_Nullable _lastURL; bool _lastWasHEAD; OFHTTPResponse *_Nullable _lastResponse; }