internal void Populate(IDictionary <string, string> headers) { var copyHeaderValue = OssUtils.BuildCopyObjectSource(SourceBucketName, SourceKey); if (!string.IsNullOrEmpty(SourceVersionId)) { copyHeaderValue = copyHeaderValue + "?versionId=" + SourceVersionId; } headers.Add(OssHeaders.CopyObjectSource, copyHeaderValue); if (ModifiedSinceConstraint != null) { headers.Add(OssHeaders.CopySourceIfModifedSince, DateUtils.FormatRfc822Date(ModifiedSinceConstraint.Value)); } if (UnmodifiedSinceConstraint != null) { headers.Add(OssHeaders.CopySourceIfUnmodifiedSince, DateUtils.FormatRfc822Date(UnmodifiedSinceConstraint.Value)); } if (_matchingETagConstraints.Count > 0) { headers.Add(OssHeaders.CopySourceIfMatch, OssUtils.JoinETag(_matchingETagConstraints)); } if (_nonmatchingETagConstraints.Count > 0) { headers.Add(OssHeaders.CopySourceIfNoneMatch, OssUtils.JoinETag(_nonmatchingETagConstraints)); } if (NewObjectMetadata != null) { headers.Add(OssHeaders.CopyObjectMetaDataDirective, "REPLACE"); NewObjectMetadata.Populate(headers); } // Remove Content-Length header, ObjectMeta#Populate will create // ContentLength header, but we do not need it for the request body is empty. headers.Remove(HttpHeaders.ContentLength); if (RequestPayer == RequestPayer.Requester) { headers.Add(OssHeaders.OssRequestPayer, RequestPayer.Requester.ToString().ToLowerInvariant()); } if (TrafficLimit > 0) { headers.Add(OssHeaders.OssTrafficLimit, TrafficLimit.ToString()); } }
/// <summary> /// Populate the http headers according to the properties of this object. /// </summary> /// <param name="headers">The generated http headers</param> internal void Populate(IDictionary <string, string> headers) { if (Range != null && (Range[0] >= 0 || Range[1] >= 0)) { var rangeHeaderValue = new StringBuilder(); rangeHeaderValue.Append("bytes="); if (Range[0] >= 0) { rangeHeaderValue.Append(Range[0].ToString(CultureInfo.InvariantCulture)); } rangeHeaderValue.Append("-"); if (Range[1] >= 0) { rangeHeaderValue.Append(Range[1].ToString(CultureInfo.InvariantCulture)); } headers.Add(HttpHeaders.Range, rangeHeaderValue.ToString()); } if (ModifiedSinceConstraint != null) { headers.Add(OssHeaders.GetObjectIfModifiedSince, DateUtils.FormatRfc822Date(ModifiedSinceConstraint.Value)); } if (UnmodifiedSinceConstraint != null) { headers.Add(OssHeaders.GetObjectIfUnmodifiedSince, DateUtils.FormatRfc822Date(UnmodifiedSinceConstraint.Value)); } if (_matchingETagConstraints.Count > 0) { headers.Add(OssHeaders.GetObjectIfMatch, OssUtils.JoinETag(_matchingETagConstraints)); } if (_nonmatchingEtagConstraints.Count > 0) { headers.Add(OssHeaders.GetObjectIfNoneMatch, OssUtils.JoinETag(_nonmatchingEtagConstraints)); } if (RequestPayer == RequestPayer.Requester) { headers.Add(OssHeaders.OssRequestPayer, RequestPayer.Requester.ToString().ToLowerInvariant()); } if (TrafficLimit > 0) { headers.Add(OssHeaders.OssTrafficLimit, TrafficLimit.ToString()); } }