public static CacheValidationStatus TryConditionalRequest(HttpRequestCacheValidator ctx) {
string ranges;
TriState isPartial = CheckForRangeRequest(ctx, out ranges);
if (isPartial == TriState.Invalid) {
// This is a user requested range, pass it as is
return CacheValidationStatus.Continue;
}
if(isPartial == TriState.Valid) {
// Not all proxy servers, support requesting a range on an FTP
// command, so to be safe, never try to mix the cache with a range
// response. Always get the whole thing fresh in the case of FTP
// over proxy.
if (ctx is FtpRequestCacheValidator)
return CacheValidationStatus.DoNotTakeFromCache;
// We only have a partial response, need to complete it
if (TryConditionalRangeRequest(ctx)){
// We can do a conditional range request
ctx.RequestRangeCache = true;
((HttpWebRequest)ctx.Request).AddRange((int)ctx.CacheEntry.StreamSize);
if(Logging.On)Logging.PrintInfo(Logging.RequestCache, SR.GetString(SR.net_log_cache_range, ctx.Request.Headers[HttpKnownHeaderNames.Range]));
return CacheValidationStatus.Continue;
}
return CacheValidationStatus.DoNotTakeFromCache;
}
//This is not a range request
return ConstructConditionalRequest(ctx);
}