Example #1
0
        protected override void OnReceived(Byte[] buffer, Int64 offset, Int64 size)
        {
            // Receive HTTP request header
            if (NetworkRequest.IsPendingHeader())
            {
                if (NetworkRequest.ReceiveHeader(buffer, (Int32)offset, (Int32)size))
                {
                    OnReceivedRequestHeader(NetworkRequest);
                }

                size = 0;
            }

            // Check for HTTP request error
            if (NetworkRequest.IsErrorSet)
            {
                OnReceivedRequestError(NetworkRequest, "Invalid HTTP request!");
                NetworkRequest.Clear();
                Disconnect();
                return;
            }

            // Receive HTTP request body
            if (NetworkRequest.ReceiveBody(buffer, (Int32)offset, (Int32)size))
            {
                OnReceivedRequestInternal(NetworkRequest);
                NetworkRequest.Clear();
                return;
            }

            // Check for HTTP request error
            if (!NetworkRequest.IsErrorSet)
            {
                return;
            }

            OnReceivedRequestError(NetworkRequest, "Invalid HTTP request!");
            NetworkRequest.Clear();
            Disconnect();
        }