コード例 #1
0
ファイル: Http.cs プロジェクト: Crystallinqq/osu-2005
 private void WriteRequestData(Stream requestBody)
 {
     if (requestBody.Length > 0L)
     {
         InitProgress(requestBody.Position, requestBody.Length);
         TcpClientConnection connection = base.Connection;
         connection.Progress =
             (SocketProgressEventHandler)
             Delegate.Combine(connection.Progress, new SocketProgressEventHandler(DoDataSendProgress));
         try
         {
             base.Connection.WriteData(requestBody);
             if (!progressHandled)
             {
                 OnSendProgress(new SocketProgressEventArgs(requestBody.Length, requestBody.Length));
             }
         }
         finally
         {
             TcpClientConnection connection2 = base.Connection;
             connection2.Progress =
                 (SocketProgressEventHandler)
                 Delegate.Remove(connection2.Progress, new SocketProgressEventHandler(DoDataSendProgress));
         }
     }
 }
コード例 #2
0
        protected TcpClient()
        {
            string str = (Environment.Version.Major > 1) ? "2.0.0.0" : "1.0.3300.0";

            connection = new TcpClientConnection();
            BatchSize  = 0x2000;
            TimeOut    = 0xea60;
            BitsPerSec = 0;
            port       = GetDefaultPort();
            server     = string.Empty;
        }
コード例 #3
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (connection != null)
         {
             Close();
             connection.Dispose();
             connection = null;
         }
         base.Dispose(disposing);
     }
     catch { }
 }
コード例 #4
0
ファイル: Http.cs プロジェクト: Crystallinqq/osu-2005
        private void ReadResponseBody(StringCollectionEx responseHeader, long extraSize, Stream extraData,
                                      Stream responseBody)
        {
            Stream stream = null;
            TcpClientConnection connection = base.Connection;

            connection.Progress =
                (SocketProgressEventHandler)
                Delegate.Combine(connection.Progress, new SocketProgressEventHandler(DoDataReceiveProgress));
            try
            {
                Stream destination = responseBody;
                if (string.Compare("chunked", ResponseHeader.TransferEncoding, true, CultureInfo.InvariantCulture) == 0)
                {
                    using (var stream3 = new ChunkedStream(destination))
                    {
                        if (extraSize > 0L)
                        {
                            StreamUtils.Copy(extraData, stream3, extraSize);
                        }
                        InitProgress(extraSize, -1L);
                        if (base.Active)
                        {
                            while (!stream3.IsCompleted)
                            {
                                base.Connection.ReadData(stream3);
                            }
                        }
                        if (!progressHandled)
                        {
                            OnReceiveProgress(new SocketProgressEventArgs(base.Connection.BytesProceed, -1L));
                        }
                        goto Label_01AC;
                    }
                }
                if (extraSize > 0L)
                {
                    StreamUtils.Copy(extraData, destination, extraSize);
                }
                long responseLength = GetResponseLength();
                long totalBytes     = responseLength;
                InitProgress(extraSize, totalBytes);
                if (responseLength < 0L)
                {
                    if (base.Active)
                    {
                        base.Connection.IsReadUntilClose = true;
                        base.Connection.ReadData(destination);
                    }
                }
                else
                {
                    long bytesProceed = base.Connection.BytesProceed;
                    responseLength -= extraSize;
                    if (base.Active)
                    {
                        while ((base.Connection.BytesProceed - bytesProceed) < responseLength)
                        {
                            base.Connection.ReadData(destination);
                        }
                    }
                }
                if (!progressHandled)
                {
                    OnReceiveProgress(new SocketProgressEventArgs(totalBytes, totalBytes));
                }
            }
            finally
            {
                TcpClientConnection connection2 = base.Connection;
                connection2.Progress =
                    (SocketProgressEventHandler)
                    Delegate.Remove(connection2.Progress, new SocketProgressEventHandler(DoDataReceiveProgress));
                if (stream != null)
                {
                    stream.Close();
                }
                stream = null;
            }
Label_01AC:
            ReadCookies(responseHeader);
        }