/// <summary> /// Updates the HTTP WEB header collection to prepare it for request. /// For each property set it adds member to m_httpResponseHeaders. /// m_httpResponseHeaders is serializes to string and sent to client. /// </summary> private void PrepareHeaders() { // Adds content length if it was present. if (m_ContentLength != -1) { m_httpResponseHeaders.ChangeInternal(HttpKnownHeaderNames.ContentLength, m_ContentLength.ToString()); } // Since we do not support persistent connection, send close always. string connection = m_KeepAlive ? "Keep-Alive" : "Close"; m_httpResponseHeaders.ChangeInternal(HttpKnownHeaderNames.Connection, connection); // Adds content type if user set it: if (m_contentType != null) { m_httpResponseHeaders.AddWithoutValidate(HttpKnownHeaderNames.ContentType, m_contentType); } if (m_redirectLocation != null) { m_httpResponseHeaders.AddWithoutValidate(HttpKnownHeaderNames.Location, m_redirectLocation); m_ResponseStatusCode = (int)HttpStatusCode.Redirect; } }