Index: src/OFHTTPClient.h ================================================================== --- src/OFHTTPClient.h +++ src/OFHTTPClient.h @@ -82,16 +82,18 @@ * * @param client The OFHTTPClient which wants to follow a redirect * @param URL The URL 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 + * @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: (int)statusCode - request: (OFHTTPRequest*)request; + request: (OFHTTPRequest*)request + response: (OFHTTPResponse*)response; @end /*! * @class OFHTTPClient OFHTTPClient.h ObjFW/OFHTTPClient.h * Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -616,16 +616,17 @@ bool follow; newURL = [OFURL URLWithString: redirect relativeToURL: URL]; - if ([_delegate respondsToSelector: - @selector(client:shouldFollowRedirect:statusCode:request:)]) + if ([_delegate respondsToSelector: @selector(client: + shouldFollowRedirect:statusCode:request:response:)]) follow = [_delegate client: self shouldFollowRedirect: newURL statusCode: status - request: request]; + request: request + response: response]; else { /* * 301, 302 and 307 should only redirect with user * confirmation if the request method is not GET or * HEAD. Asking the delegate and getting true returned Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -324,14 +324,34 @@ - (bool)client: (OFHTTPClient*)client shouldFollowRedirect: (OFURL*)URL statusCode: (int)statusCode request: (OFHTTPRequest*)request + response: (OFHTTPResponse*)response { if (!_quiet) - [of_stdout writeFormat: @" āžœ %d\nā˜‡ %@", - statusCode, [URL string]]; + [of_stdout writeFormat: @" āžœ %d\n", statusCode]; + + if (_verbose) { + void *pool = objc_autoreleasePoolPush(); + OFDictionary OF_GENERIC(OFString*, OFString*) *headers = + [response headers]; + OFEnumerator *keyEnumerator = [headers keyEnumerator]; + OFEnumerator *objectEnumerator = + [headers objectEnumerator]; + OFString *key, *object; + + while ((key = [keyEnumerator nextObject]) != nil && + (object = [objectEnumerator nextObject]) != nil) + [of_stdout writeFormat: @" %@: %@\n", + key, object]; + + objc_autoreleasePoolPop(pool); + } + + if (!_quiet) + [of_stdout writeFormat: @"ā˜‡ %@", [URL string]]; return true; } - (OFHTTPResponse*)performRequest: (OFHTTPRequest*)request