示例#1
0
 /// <summary>
 /// Closes the save stream if there's any and sets it to null
 /// </summary>
 internal void CloseSaveStream()
 {
     if (this.SaveStream != null)
     {
         DataServiceSaveStream stream = this.SaveStream;
         this.SaveStream = null;
         stream.Close();
     }
 }
示例#2
0
        /// <summary>
        /// Sets the content and the headers of the media resource request
        /// </summary>
        /// <param name="headers">The header collection to setup.</param>
        /// <param name="saveStream">DataServiceSaveStream instance containing all information about the stream.</param>
        /// <param name="etag">ETag header value to be set. If passed null, etag header is not set.</param>
        /// <remarks>This only works with the V2 MR support (SetSaveStream), this will not setup
        /// the request for V1 property based MRs.</remarks>
        private void SetupMediaResourceRequest(HeaderCollection headers, DataServiceSaveStream saveStream, string etag)
        {
            // Get the write stream for this MR
            this.mediaResourceRequestStream = saveStream.Stream;

            // Copy over headers for the request, except the accept header
            headers.SetHeaders(saveStream.Args.Headers.Where(h => !string.Equals(h.Key, XmlConstants.HttpRequestAccept, StringComparison.OrdinalIgnoreCase)));

            if (etag != null)
            {
                headers.SetHeader(XmlConstants.HttpRequestIfMatch, etag);
            }

            // Do NOT set the ContentLength since we don't know if the stream even supports reporting its length
        }
示例#3
0
        /// <summary>
        /// Sets the content and the headers of the media resource request
        /// </summary>
        /// <param name="headers">The header collection to setup.</param>
        /// <param name="saveStream">DataServiceSaveStream instance containing all information about the stream.</param>
        /// <param name="etag">ETag header value to be set. If passed null, etag header is not set.</param>
        /// <remarks>This only works with the V2 MR support (SetSaveStream), this will not setup
        /// the request for V1 property based MRs.</remarks>
        private void SetupMediaResourceRequest(HeaderCollection headers, DataServiceSaveStream saveStream, string etag)
        {
            // Get the write stream for this MR
            this.mediaResourceRequestStream = saveStream.Stream;

            // Copy over headers for the request, except the accept header
            headers.SetHeaders(saveStream.Args.Headers.Where(h => !string.Equals(h.Key, XmlConstants.HttpRequestAccept, StringComparison.OrdinalIgnoreCase)));

            if (etag != null)
            {
                headers.SetHeader(XmlConstants.HttpRequestIfMatch, etag);
            }

            // Do NOT set the ContentLength since we don't know if the stream even supports reporting its length
        }