Beispiel #1
0
        private void session_ReceiveBodyComplete(object sender, ReceiveBodyCompleteEventArgs e)
        {
            logger.Debug("{0} receive body complete", _connectionToken.Substring(0, 6));

            _lastActiveTime = DateTime.Now;
            _workStatus     = SessionWorkStatus.Busy;

            try
            {
                _lastProcessor.RequestBodyArrival(e.Data, e.DataLength);

                if (e.TotalHasReceivedLength >= e.TotalPlanReceivingLength)
                {
                    //all body receive complete
                    _lastProcessor.AllRequestBodyReceived();
                }
            }
            catch (Exception ex)
            {
                //exception occur while append request body to handler,
                //only PUT and POST will occur.
                logger.Warn("{0} append request to processor {1} body error: {2}",
                            _connectionToken.Substring(0, 6),
                            _lastProcessor.GetType().Name,
                            ex.Message);
                Close();
                return;
            }

            if (e.TotalHasReceivedLength >= e.TotalPlanReceivingLength)
            {
                //handle complete, send response
                sendResponse();
            }
            else
            {
                //continue to receive body
                _workStatus = SessionWorkStatus.ReceivingRequestBody;
                _session.ContinueReceivingBody(_bodyBuffer, 0, _bodyBuffer.Length);
            }
        }