Mono.WebServer.XSPWorkerRequest.SendResponseFromMemory C# (CSharp) Method

SendResponseFromMemory() public method

public SendResponseFromMemory ( byte data, int length ) : void
data byte
length int
return void
        public override void SendResponseFromMemory(byte [] data, int length)
        {
            if (requestBroker == null || length <= 0)
                return;

            if (data.Length < length)
                length = data.Length;

            bool uncork = false;
            if (!headersSent) {
                Cork (true);
                uncork = true;
                SendHeaders ();
            }

            Send (data, 0, length);
            if (uncork)
                Cork (false);
        }

Usage Example

コード例 #1
0
        static void Redirect(XSPWorkerRequest wr, string location)
        {
            string host = wr.GetKnownRequestHeader(HttpWorkerRequest.HeaderHost);

            wr.SendStatus(301, "Moved Permanently");
            wr.SendUnknownResponseHeader("Connection", "close");
            wr.SendUnknownResponseHeader("Date", DateTime.Now.ToUniversalTime().ToString("r"));
            wr.SendUnknownResponseHeader("Location", String.Format("http://{0}{1}", host, location));
            Encoding enc = Encoding.ASCII;

            wr.SendUnknownResponseHeader("Content-Type", "text/html; charset=" + enc.WebName);
            string content = String.Format(content301, host, location);

            byte [] contentBytes = enc.GetBytes(content);
            wr.SendUnknownResponseHeader("Content-Length", contentBytes.Length.ToString());
            wr.SendResponseFromMemory(contentBytes, contentBytes.Length);
            wr.FlushResponse(true);
            wr.CloseConnection();
        }
All Usage Examples Of Mono.WebServer.XSPWorkerRequest::SendResponseFromMemory