static void _network_prepStep_validateConfiguration()

in Source/TNLRequestOperation.m [1294:1326]


static void _network_prepStep_validateConfiguration(TNLRequestOperation * __nullable const self, tnl_request_preparation_block_t nextBlock)
{
    if (!self) {
        return;
    }

    TNLAssert(nextBlock != nil);
    TNLAssert([self _network_isPreparing]);

    TNLRequestConfiguration *config = self->_requestConfiguration;

    const BOOL hasAttemptTimeout = config.attemptTimeout >= MIN_TIMER_INTERVAL;
    const BOOL hasIdleTimeout = config.idleTimeout >= MIN_TIMER_INTERVAL;
    const BOOL hasOperationTimeout = config.operationTimeout >= MIN_TIMER_INTERVAL;

    if (hasAttemptTimeout && hasIdleTimeout && (config.attemptTimeout - config.idleTimeout < -0.05)) {
        TNLLogWarning(@"Attempt Timeout (%.2f) should not be shorter than the Idle Timeout (%.2f)!", config.attemptTimeout, config.idleTimeout);
    }

    if (hasOperationTimeout && hasAttemptTimeout && (config.operationTimeout - config.attemptTimeout < -0.05)) {
        TNLLogWarning(@"Operation Timeout (%.2f) should not be shorter than the Attempt Timeout (%.2f)!", config.operationTimeout, config.attemptTimeout);
    }

    if (config.executionMode == TNLRequestExecutionModeBackground) {
        if (config.redirectPolicy != TNLRequestRedirectPolicyDoRedirect) {
            NSString *message = @"The operation will execute in the background and follow all redirects however the operation's configuration specified a policy that differs.  Operation will continue by ignoring the policy and following redirects.";
            TNLLogWarning(@"%@", message);
            TNLAssertMessage(config.redirectPolicy == TNLRequestRedirectPolicyDoRedirect, @"%@", message);
        }
    }

    nextBlock();
}