public void Send() { if (Sent) { throw new InvalidOperationException("Everything have already been sent."); } if (m_context.MAXRequests == 0 || _keepAlive == 0) { Connection = ConnectionType.Close; m_context.TimeoutKeepAlive = 0; } else { if (_keepAlive > 0) { m_context.TimeoutKeepAlive = _keepAlive * 1000; } } m_headerBytes = GetHeaders(); if (RawBuffer != null) { if (RawBufferStart < 0 || RawBufferStart > RawBuffer.Length) { return; } if (RawBufferLen < 0) { RawBufferLen = RawBuffer.Length; } if (RawBufferLen + RawBufferStart > RawBuffer.Length) { RawBufferLen = RawBuffer.Length - RawBufferStart; } int tlen = m_headerBytes.Length + RawBufferLen; if (RawBufferLen > 0 && tlen < 16384) { byte[] tmp = new byte[tlen]; Array.Copy(m_headerBytes, tmp, m_headerBytes.Length); Array.Copy(RawBuffer, RawBufferStart, tmp, m_headerBytes.Length, RawBufferLen); m_headerBytes = null; RawBuffer = tmp; RawBufferStart = 0; RawBufferLen = tlen; } } m_context.StartSendResponse(this); }
public void Send() { if (m_context.IsClosing) { return; } if (Sent) { throw new InvalidOperationException("Everything have already been sent."); } if (m_context.MaxRequests == 0 || m_keepAlive == 0) { Connection = ConnectionType.Close; m_context.TimeoutKeepAlive = 0; } else { if (m_keepAlive > 0) { m_context.TimeoutKeepAlive = m_keepAlive * 1000; } } if (RawBuffer != null) { if (RawBufferStart > RawBuffer.Length) { return; } if (RawBufferStart < 0) { RawBufferStart = 0; } if (RawBufferLen < 0) { RawBufferLen = RawBuffer.Length; } if (RawBufferLen + RawBufferStart > RawBuffer.Length) { RawBufferLen = RawBuffer.Length - RawBufferStart; } } m_headerBytes = GetHeaders(); if (RawBuffer != null && RawBufferLen > 0) { int tlen = m_headerBytes.Length + RawBufferLen; if (tlen < 8 * 1024) { byte[] tmp = new byte[tlen]; Buffer.BlockCopy(m_headerBytes, 0, tmp, 0, m_headerBytes.Length); Buffer.BlockCopy(RawBuffer, RawBufferStart, tmp, m_headerBytes.Length, RawBufferLen); m_headerBytes = null; RawBuffer = tmp; RawBufferStart = 0; RawBufferLen = tlen; } if (RawBufferLen == 0) { RawBuffer = null; } } if (m_body != null && m_body.Length == 0) { m_body.Dispose(); m_body = null; } if (m_headerBytes == null && RawBuffer == null && m_body == null) { Sent = true; m_context.EndSendResponse(requestID, Connection); } else { m_context.StartSendResponse(this); } }
public void Send() { if (m_context.IsClosing) { return; } if (Sent) { throw new InvalidOperationException("Everything have already been sent."); } if (m_context.MaxRequests == 0 || m_keepAlive == 0) { Connection = ConnectionType.Close; m_context.TimeoutKeepAlive = 0; } else { if (m_keepAlive > 0) { m_context.TimeoutKeepAlive = m_keepAlive * 1000; } } if (RawBuffer != null) { if (RawBufferStart > RawBuffer.Length) { return; } if (RawBufferStart < 0) { RawBufferStart = 0; } if (RawBufferLen < 0) { RawBufferLen = RawBuffer.Length; } if (RawBufferLen + RawBufferStart > RawBuffer.Length) { RawBufferLen = RawBuffer.Length - RawBufferStart; } } m_headerBytes = GetHeaders(); /* * if (RawBuffer != null) * { * int tlen = m_headerBytes.Length + RawBufferLen; * if(RawBufferLen > 0 && tlen < 16384) * { * byte[] tmp = new byte[tlen]; * Buffer.BlockCopy(m_headerBytes, 0, tmp, 0, m_headerBytes.Length); * Buffer.BlockCopy(RawBuffer, RawBufferStart, tmp, m_headerBytes.Length, RawBufferLen); * m_headerBytes = null; * RawBuffer = tmp; * RawBufferStart = 0; * RawBufferLen = tlen; * } * } */ m_context.StartSendResponse(this); }