@@ -26,11 +26,11 @@ @class OFHTTPRequest; @class OFHTTPResponse; @class OFStream; @class OFTCPSocket; @class OFTLSStream; -@class OFURL; +@class OFURI; /** * @protocol OFHTTPClientDelegate OFHTTPClient.h ObjFW/OFHTTPClient.h * * @brief A delegate for OFHTTPClient. @@ -117,25 +117,25 @@ * This callback will only be called if the OFHTTPClient will follow a * redirect. If the maximum number of redirects has been reached already, this * callback will not be called. * * @param client The OFHTTPClient which wants to follow a redirect - * @param URL The URL to which it will follow a redirect + * @param URI The URI to which it will follow a redirect * @param statusCode The status code for the redirection * @param request The request for which the OFHTTPClient wants to redirect. * You are allowed to change the request's headers from this * callback and they will be used when following the redirect - * (e.g. to set the cookies for the new URL), however, keep in + * (e.g. to set the cookies for the new URI), however, keep in * mind that this will change the request you originally passed. * @param response The response indicating the redirect * @return A boolean whether the OFHTTPClient should follow the redirect */ -- (bool)client: (OFHTTPClient *)client - shouldFollowRedirect: (OFURL *)URL - statusCode: (short)statusCode - request: (OFHTTPRequest *)request - response: (OFHTTPResponse *)response; +- (bool)client: (OFHTTPClient *)client + shouldFollowRedirectToURI: (OFURI *)URI + statusCode: (short)statusCode + request: (OFHTTPRequest *)request + response: (OFHTTPResponse *)response; @end /** * @class OFHTTPClient OFHTTPClient.h ObjFW/OFHTTPClient.h * @@ -142,17 +142,17 @@ * @brief A class for performing HTTP requests. */ OF_SUBCLASSING_RESTRICTED @interface OFHTTPClient: OFObject { -#ifdef OF_HTTPCLIENT_M +#ifdef OF_HTTP_CLIENT_M @public #endif OFObject *_Nullable _delegate; bool _allowsInsecureRedirects, _inProgress; OFStream *_Nullable _stream; - OFURL *_Nullable _lastURL; + OFURI *_Nullable _lastURI; bool _lastWasHEAD; OFHTTPResponse *_Nullable _lastResponse; } /** @@ -180,10 +180,15 @@ * running! If you want to change the delegate during the request, * perform an asynchronous request instead! * * @param request The request to perform * @return The OFHTTPResponse for the request + * @throw OFHTTPRequestFailedException The HTTP request failed + * @throw OFInvalidServerResponseException The server sent an invalid response + * @throw OFUnsupportedVersionException The server responded in an unsupported + * version + * @throw OFAlreadyConnectedException The client is already performing a request */ - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request; /** * @brief Synchronously performs the specified HTTP request. @@ -195,18 +200,24 @@ * @param request The request to perform * @param redirects The maximum number of redirects after which no further * attempt is done to follow the redirect, but instead the * redirect is treated as an OFHTTPResponse * @return The OFHTTPResponse for the request + * @throw OFHTTPRequestFailedException The HTTP request failed + * @throw OFInvalidServerResponseException The server sent an invalid response + * @throw OFUnsupportedVersionException The server responded in an unsupported + * version + * @throw OFAlreadyConnectedException The client is already performing a request */ - (OFHTTPResponse *)performRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects; /** * @brief Asynchronously performs the specified HTTP request. * * @param request The request to perform + * @throw OFAlreadyConnectedException The client is already performing a request */ - (void)asyncPerformRequest: (OFHTTPRequest *)request; /** * @brief Asynchronously performs the specified HTTP request. @@ -213,10 +224,11 @@ * * @param request The request to perform * @param redirects The maximum number of redirects after which no further * attempt is done to follow the redirect, but instead the * redirect is treated as an OFHTTPResponse + * @throw OFAlreadyConnectedException The client is already performing a request */ - (void)asyncPerformRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects; /**