Beispiel #1
0
		private static void OnRead(IAsyncResult result)
		{
			if (result == null) {
                return;
            }

            HttpClientResponse req = result.AsyncState as HttpClientResponse;
            if (req == null)
                return;

            try {
                if (req.m_Client != null)
                    req.m_Client.ResetReadTimeOut();
                int read = req.m_OrgStream.EndRead(result);
                if (read > 0) {
                    req.DoFlush(read);
                    req.m_ReadBytes += read;
                    // MaxReadBytes为-1,说明忽略了ContentLength
                    if (req.IsIngoreMaxReadBytes || req.ReadBytes < req.MaxReadBytes)
                        req.m_OrgStream.BeginRead(req.m_Buf, 0, req.m_Buf.Length, m_ReadCallBack, req);
                    else {
                        req.DoClose();
                    }
                } else if (req.IsIngoreMaxReadBytes && read == 0) {
                    // 说明HTTP忽略了ContentLength
                    req.DoFlush(read);
                    req.DoClose();
                } else {
                    req.DoClose();
                }
            } catch {
                req.OnError(-1);
            }
		}
        private static void OnRead(IAsyncResult result)
        {
            //	UnityEngine.Debug.Log("OnRead Start");

            if (result == null)
            {
                return;
            }

            HttpClientResponse req = result.AsyncState as HttpClientResponse;

            if (req == null)
            {
                return;
            }

            int read = req.m_OrgStream.EndRead(result);

            if (read > 0)
            {
                req.DoFlush(read);
                req.m_ReadBytes += read;
                if (req.ReadBytes < req.MaxReadBytes)
                {
                    req.m_OrgStream.BeginRead(req.m_Buf, 0, req.m_Buf.Length, m_ReadCallBack, req);
                }
                else
                {
                    req.DoClose();
                }
            }
            else
            {
                req.DoClose();
                //	UnityEngine.Debug.Log("OnRead Close");
            }
        }