コード例 #1
0
        internal Stream GetStreamAndRemoveFromContext(string streamId)
        {
            if (this.m_streamsFromServer == null)
            {
                throw new ArgumentOutOfRangeException("streamId");
            }
            ChunkStreamBuilder chunkStreamBuilder = this.m_streamsFromServer[streamId];

            this.m_streamsFromServer.Remove(streamId);
            return(chunkStreamBuilder.CreateReadonlyStream());
        }
コード例 #2
0
        internal void AddStream(string streamId, ChunkStreamBuilder stream)
        {
            if (this.m_streamsFromServer == null)
            {
                this.m_streamsFromServer = new Dictionary <string, ChunkStreamBuilder>();
            }
            ChunkStreamBuilder chunkStreamBuilder;

            if (this.m_streamsFromServer.TryGetValue(streamId, out chunkStreamBuilder) && chunkStreamBuilder != null)
            {
                chunkStreamBuilder.Close();
            }
            this.m_streamsFromServer[streamId] = stream;
        }
コード例 #3
0
 private void WriteMimeStream(ClientRequest.ExecuteQueryMimeInfo mimeInfo, ChunkStringBuilder sb, Stream requestStream)
 {
     MimeWriter mimeWriter = new MimeWriter(requestStream, mimeInfo.Boundary);
     mimeWriter.StartPart();
     mimeWriter.WriteHeader(MimeGlobals.ContentIDHeader, mimeInfo.MainPartCid);
     mimeWriter.WriteHeader(MimeGlobals.ContentTransferEncodingHeader, "8bit");
     mimeWriter.WriteHeader(MimeGlobals.ContentTypeHeader, "application/xop+xml;charset=utf-8;type=\"application/xml\"");
     mimeWriter.WriteHeader(MimeGlobals.ContentLengthHeader, sb.Length.ToString(CultureInfo.InvariantCulture));
     sb.WriteContentAsUTF8(mimeWriter.GetContentStream());
     foreach (StreamInfo current in this.SerializationContext.Streams)
     {
         mimeWriter.StartPart();
         mimeWriter.WriteHeader(MimeGlobals.ContentIDHeader, "<" + current.Id + ">");
         mimeWriter.WriteHeader(MimeGlobals.ContentTransferEncodingHeader, "binary");
         mimeWriter.WriteHeader(MimeGlobals.ContentTypeHeader, "application/octet-stream");
         mimeWriter.WriteHeader(MimeGlobals.ContentLengthHeader, current.Stream.Length.ToString(CultureInfo.InvariantCulture));
         Stream contentStream = mimeWriter.GetContentStream();
         ChunkStreamBuilder.CopyStream(current.Stream, contentStream);
         //Edited for .NET Core
         current.Stream.Dispose();//.Close();
     }
     mimeWriter.Close();
 }
コード例 #4
0
 private void ProcessResponse()
 {
     string responseContentType = this.RequestExecutor.ResponseContentType;
     HttpStatusCode statusCode = this.RequestExecutor.StatusCode;
     string boundary;
     bool flag = this.IsMultiPartMime(responseContentType, out boundary);
     if (statusCode != HttpStatusCode.OK || (!responseContentType.StartsWith("application/json") && !flag))
     {
         this.m_requestStatus = ClientRequestStatus.CompletedException;
         throw new ClientRequestException(Resources.GetString("RequestUnexpectedResponseWithContentTypeAndStatus", new object[]
         {
             responseContentType,
             statusCode
         }));
     }
     this.m_context.ProcessingResponse = true;
     try
     {
         using (Stream responseStream = this.RequestExecutor.GetResponseStream())
         {
             MimeReader mimeReader = null;
             Stream responseStream2 = responseStream;
             if (flag)
             {
                 mimeReader = new MimeReader(responseStream, boundary);
                 if (!mimeReader.ReadNextPart())
                 {
                     throw new ClientRequestException(Resources.GetString("RequestUnexpectedResponseWithContentTypeAndStatus", new object[]
                     {
                         responseContentType,
                         statusCode
                     }));
                 }
                 responseStream2 = mimeReader.GetContentStream();
             }
             this.ProcessResponseStream(responseStream2);
             if (flag)
             {
                 while (mimeReader.ReadNextPart())
                 {
                     int num = 2000;
                     int num2 = num;
                     MimeHeaders mimeHeaders = mimeReader.ReadHeaders(num, ref num2);
                     if (mimeHeaders.ContentID != null && !string.IsNullOrEmpty(mimeHeaders.ContentID.Value))
                     {
                         string text = mimeHeaders.ContentID.Value;
                         if (text.StartsWith("<", StringComparison.Ordinal) && text.EndsWith(">", StringComparison.Ordinal))
                         {
                             text = text.Substring(1, text.Length - 2);
                         }
                         ChunkStreamBuilder chunkStreamBuilder = new ChunkStreamBuilder();
                         chunkStreamBuilder.CopyFrom(mimeReader.GetContentStream());
                         this.Context.AddStream(text, chunkStreamBuilder);
                     }
                 }
             }
             this.m_requestStatus = ClientRequestStatus.CompletedSuccess;
         }
     }
     catch (Exception ex)
     {
         this.m_requestStatus = ClientRequestStatus.CompletedException;
         throw;
     }
     finally
     {
         this.m_context.ProcessingResponse = false;
         this.RequestExecutor.Dispose();
     }
 }
コード例 #5
0
 public ReadonlyChunkStream(ChunkStreamBuilder sb, bool owner)
 {
     this.m_sb     = sb;
     this.m_isOpen = true;
     this.m_owner  = owner;
 }