biasedbit / BBHTTP

A modern HTTP client framework for iOS/OSX built on top of libcurl.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Expose request timeout conditions as properties on BBHTTPRequest

biasedbit opened this issue · comments

I'm thinking about exposing both CURLOPT_LOW_SPEED_LIMIT and CURLOPT_LOW_SPEED_TIME as a single property:

struct BBTransferRate {
    unsigned long bytesPerSecond;
    NSTimeInterval duration;
};
typedef struct BBTransferRate BBTransferRate;

BBTransferRate BBTransferRateMake(unsigned long bytesPerSecond, NSTimeInterval duration)
{
    BBTransferRate threshold;
    threshold.bytesPerSecond = bytesPerSecond;
    threshold.duration = duration;

    return threshold;
}

NSString* NSStringFromBBTransferRate(BBTransferRate transferRate)
{
    return [NSString stringWithFormat:@"%lu/s for %.0f seconds", transferRate.bytesPerSecond, transferRate.duration];
}

I think it's way more meaningful than two separate properties.

The property on BBHTTPRequest should probably be named requestTimeoutThreshold.

Sounds good to me. . .