Index: src/OFHTTPRequest.h ================================================================== --- src/OFHTTPRequest.h +++ src/OFHTTPRequest.h @@ -19,10 +19,11 @@ @class OFString; @class OFDictionary; @class OFURL; @class OFHTTPRequest; @class OFHTTPRequestResult; +@class OFTCPSocket; @class OFDataArray; typedef enum of_http_request_type_t { OF_HTTP_REQUEST_TYPE_GET, OF_HTTP_REQUEST_TYPE_POST, @@ -38,10 +39,24 @@ @protocol OFHTTPRequestDelegate #endif #ifdef OF_HAVE_OPTIONAL_PROTOCOLS @optional #endif +/** + * \brief A callback which is called when an OFHTTPRequest 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 request The OFHTTPRequest that created a socket + * \param socket The socket created by the OFHTTPRequest + */ +- (void)request: (OFHTTPRequest*)request + didCreateSocket: (OFTCPSocket*)socket; + /** * \brief A callback which is called when an OFHTTPRequest received headers. * * \param request The OFHTTPRequest which received the headers * \param headers The headers received Index: src/OFHTTPRequest.m ================================================================== --- src/OFHTTPRequest.m +++ src/OFHTTPRequest.m @@ -203,10 +203,13 @@ sock = [[[of_http_request_tls_socket_class alloc] init] autorelease]; } + [delegate request: self + didCreateSocket: sock]; + @try { OFString *line, *path; OFMutableDictionary *serverHeaders; OFDataArray *data; OFEnumerator *keyEnumerator, *objectEnumerator; @@ -456,10 +459,15 @@ return [[data retain] autorelease]; } @end @implementation OFObject (OFHTTPRequestDelegate) +- (void)request: (OFHTTPRequest*)request + didCreateSocket: (OFTCPSocket*)socket +{ +} + - (void)request: (OFHTTPRequest*)request didReceiveHeaders: (OFDictionary*)headers withStatusCode: (int)statusCode { }