public bool ProcessConditionalHeader(ConditionalHeaders condHeaders, NameValueCollection requestHeaders, OperationTypeForConditionParsing operationType, string requestVersion, ConditionInformation outputCondition) { bool?nullable; if (!string.IsNullOrEmpty(condHeaders.IfRange)) { return(false); } if (string.IsNullOrEmpty(condHeaders.IfMatch)) { return(false); } outputCondition.ConditionFailStatusCode = HttpStatusCode.PreconditionFailed; outputCondition.ResourceExistsCondition = new ResourceExistenceCondition?(ResourceExistenceCondition.MustExist); string ifMatch = condHeaders.IfMatch; string[] strArrays = new string[] { "," }; string[] strArrays1 = ifMatch.Split(strArrays, StringSplitOptions.RemoveEmptyEntries); List <DateTime> dateTimes = new List <DateTime>(); string[] strArrays2 = strArrays1; for (int i = 0; i < (int)strArrays2.Length; i++) { string str = strArrays2[i]; if (Comparison.StringEqualsIgnoreCase(str, "*")) { return(false); } try { dateTimes.Add(BasicHttpProcessor.GetLastModifiedTimeFromETag(str)); } catch (InvalidHeaderProtocolException invalidHeaderProtocolException1) { InvalidHeaderProtocolException invalidHeaderProtocolException = invalidHeaderProtocolException1; if (!VersioningHelper.IsPreSeptember09OrInvalidVersion(requestVersion)) { if (operationType == OperationTypeForConditionParsing.CopyOperation) { nullable = new bool?(false); } else { nullable = null; } throw new UnrecognizedIfMatchConditionException(nullable, invalidHeaderProtocolException); } throw; } } if (dateTimes.Count > 0) { outputCondition.IfMatch = dateTimes.ToArray(); } if (outputCondition != null && (int)outputCondition.IfMatch.Length > 0) { return(true); } return(false); }
protected override bool ProcessConditionalHeader(ConditionalHeaders condHeaders, NameValueCollection requestHeaders, OperationTypeForConditionParsing operationType, string requestVersion, out ConditionInformation outputCondition) { DateTime lastModifiedTimeFromETag; DateTime?nullable = null; if (!ConditionExtractor.ShouldThisVersionFailMultipleConditions(requestVersion)) { if (!string.IsNullOrEmpty(condHeaders.IfRange)) { outputCondition = null; return(false); } if (string.IsNullOrEmpty(condHeaders.CopySourceIfMatch)) { outputCondition = null; return(false); } if (!string.IsNullOrEmpty(condHeaders.CopySourceIfNoneMatch) || !string.IsNullOrEmpty(condHeaders.CopySourceIfModifiedSince)) { outputCondition = null; return(false); } if (Comparison.StringContains(condHeaders.CopySourceIfMatch, ",")) { throw new InvalidHeaderProtocolException("x-ms-source-if-match", condHeaders.CopySourceIfMatch); } if (!string.IsNullOrEmpty(condHeaders.CopySourceIfUnmodifiedSince) && !HttpUtilities.TryGetDateTimeFromHttpString(condHeaders.CopySourceIfUnmodifiedSince, out nullable)) { throw new InvalidHeaderProtocolException("x-ms-source-if-unmodified-since", condHeaders.CopySourceIfUnmodifiedSince); } } else { if (string.IsNullOrEmpty(condHeaders.CopySourceIfMatch)) { outputCondition = null; return(false); } if (!string.IsNullOrEmpty(condHeaders.CopySourceIfModifiedSince) || !string.IsNullOrEmpty(condHeaders.CopySourceIfNoneMatch)) { throw new MultipleConditionHeaderProtocolException(); } if (Comparison.StringContains(condHeaders.CopySourceIfMatch, ",")) { throw new MultipleConditionHeaderProtocolException(); } } ConditionInformation conditionInformation = new ConditionInformation() { ConditionFailStatusCode = HttpStatusCode.PreconditionFailed }; if (Comparison.StringEqualsIgnoreCase(condHeaders.CopySourceIfMatch, "*")) { outputCondition = null; return(false); } try { lastModifiedTimeFromETag = BasicHttpProcessor.GetLastModifiedTimeFromETag(condHeaders.CopySourceIfMatch); } catch (InvalidHeaderProtocolException invalidHeaderProtocolException1) { InvalidHeaderProtocolException invalidHeaderProtocolException = invalidHeaderProtocolException1; if (!VersioningHelper.IsPreSeptember09OrInvalidVersion(requestVersion)) { throw new UnrecognizedIfMatchConditionException(new bool?(true), invalidHeaderProtocolException); } throw; } if (!VersioningHelper.IsPreSeptember09OrInvalidVersion(requestVersion)) { conditionInformation.CopySourceIfMatch = new DateTime?(lastModifiedTimeFromETag); } else { conditionInformation.CopySourceIfNotModifiedSince = new DateTime?(lastModifiedTimeFromETag); } if (nullable.HasValue && !HttpUtilities.DateTimesEqualsUpToSeconds(nullable.Value, lastModifiedTimeFromETag)) { outputCondition = null; return(false); } outputCondition = conditionInformation; return(true); }
protected override bool ProcessConditionalHeader(ConditionalHeaders condHeaders, NameValueCollection requestHeaders, OperationTypeForConditionParsing operationType, string requestVersion, out ConditionInformation outputCondition) { DateTime lastModifiedTimeFromETag; bool? nullable; DateTime?nullable1 = null; if (!ConditionExtractor.ShouldThisVersionFailMultipleConditions(requestVersion)) { if (!string.IsNullOrEmpty(condHeaders.IfRange)) { outputCondition = null; return(false); } if (string.IsNullOrEmpty(condHeaders.IfMatch)) { outputCondition = null; return(false); } if (!string.IsNullOrEmpty(condHeaders.IfNoneMatch) || !string.IsNullOrEmpty(condHeaders.IfModifiedSince)) { outputCondition = null; return(false); } if (Comparison.StringContains(condHeaders.IfMatch, ",")) { throw new InvalidHeaderProtocolException("If-Match", condHeaders.IfMatch); } if (!string.IsNullOrEmpty(condHeaders.IfUnmodifiedSince) && !HttpUtilities.TryGetDateTimeFromHttpString(condHeaders.IfUnmodifiedSince, out nullable1)) { throw new InvalidHeaderProtocolException("If-Unmodified-Since", condHeaders.IfUnmodifiedSince); } } else { if (string.IsNullOrEmpty(condHeaders.IfMatch)) { outputCondition = null; return(false); } if (!string.IsNullOrEmpty(condHeaders.IfModifiedSince) || !string.IsNullOrEmpty(condHeaders.IfNoneMatch)) { throw new MultipleConditionHeaderProtocolException(); } if (Comparison.StringContains(condHeaders.IfMatch, ",")) { throw new MultipleConditionHeaderProtocolException(); } } ConditionInformation conditionInformation = new ConditionInformation() { ConditionFailStatusCode = HttpStatusCode.PreconditionFailed, ResourceExistsCondition = new ResourceExistenceCondition?(ResourceExistenceCondition.MustExist) }; if (!Comparison.StringEqualsIgnoreCase(condHeaders.IfMatch, "*")) { try { lastModifiedTimeFromETag = BasicHttpProcessor.GetLastModifiedTimeFromETag(condHeaders.IfMatch); } catch (InvalidHeaderProtocolException invalidHeaderProtocolException1) { InvalidHeaderProtocolException invalidHeaderProtocolException = invalidHeaderProtocolException1; if (!VersioningHelper.IsPreSeptember09OrInvalidVersion(requestVersion)) { if (operationType == OperationTypeForConditionParsing.CopyOperation) { nullable = new bool?(false); } else { nullable = null; } throw new UnrecognizedIfMatchConditionException(nullable, invalidHeaderProtocolException); } throw; } if (!VersioningHelper.IsPreSeptember09OrInvalidVersion(requestVersion)) { conditionInformation.IfMatch = new DateTime[] { lastModifiedTimeFromETag }; } else { conditionInformation.IfNotModifiedSince = new DateTime?(lastModifiedTimeFromETag); conditionInformation.ResourceExistsCondition = new ResourceExistenceCondition?(ResourceExistenceCondition.MayExist); } if (nullable1.HasValue && !HttpUtilities.DateTimesEqualsUpToSeconds(nullable1.Value, lastModifiedTimeFromETag)) { outputCondition = null; return(false); } } else { if (operationType == OperationTypeForConditionParsing.ReadOperation) { outputCondition = null; return(false); } if (nullable1.HasValue) { conditionInformation.IfNotModifiedSince = new DateTime?((nullable1.Value < DateTime.MaxValue.AddSeconds(-1) ? nullable1.Value.AddSeconds(1) : nullable1.Value)); } } outputCondition = conditionInformation; return(true); }