in Source/TNLRequestOperation.m [1571:1608]
static void _network_prepStep_sanitizeHostForScratchURLRequest(TNLRequestOperation * __nullable const self, tnl_request_preparation_block_t nextBlock)
{
if (!self) {
return;
}
TNLAssert(nextBlock != nil);
TNLAssert([self _network_isPreparing]);
NSString *host = self->_scratchURLRequest.URL.host;
self->_hostSanitizer = (self->_requestConfiguration.skipHostSanitization) ? nil : [TNLGlobalConfiguration sharedInstance].hostSanitizer;
if (self->_hostSanitizer) {
[self->_hostSanitizer tnl_host:host
wasEncounteredForURLRequest:[self->_scratchURLRequest copy]
asRedirect:NO
completion:^(TNLHostSanitizerBehavior behavior, NSString *newHost) {
tnl_dispatch_async_autoreleasing(tnl_network_queue(), ^{
TNLAssert([host isEqualToString:self->_scratchURLRequest.URL.host]);
NSError *error = nil;
const TNLHostReplacementResult hostReplacementResult = [self->_scratchURLRequest tnl_replaceURLHost:newHost
behavior:behavior
error:&error];
if (TNLHostReplacementResultSuccess == hostReplacementResult) {
[self _network_notifySanitizedHost:host toHost:newHost];
}
if (error) {
[self _network_fail:error];
} else {
nextBlock();
}
});
}];
} else {
nextBlock();
}
}