change response m_body send (currently not in use)
parent
f1761a5b6c
commit
50b8c90b42
|
@ -89,7 +89,6 @@ namespace OSHttpServer
|
||||||
m_body = new MemoryStream();
|
m_body = new MemoryStream();
|
||||||
return m_body;
|
return m_body;
|
||||||
}
|
}
|
||||||
set { m_body = value; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -298,7 +297,6 @@ namespace OSHttpServer
|
||||||
|
|
||||||
if(m_body != null && m_body.Length > 0)
|
if(m_body != null && m_body.Length > 0)
|
||||||
{
|
{
|
||||||
m_body.Flush();
|
|
||||||
m_body.Seek(0, SeekOrigin.Begin);
|
m_body.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
var buffer = new byte[8192];
|
var buffer = new byte[8192];
|
||||||
|
@ -592,12 +590,12 @@ namespace OSHttpServer
|
||||||
|
|
||||||
if (m_body != null && m_body.Length != 0)
|
if (m_body != null && m_body.Length != 0)
|
||||||
{
|
{
|
||||||
m_body.Flush();
|
MemoryStream mb = m_body as MemoryStream;
|
||||||
m_body.Seek(0, SeekOrigin.Begin);
|
RawBuffer = mb.GetBuffer();
|
||||||
|
RawBufferStart = 0; // must be a internal buffer, or starting at 0
|
||||||
RawBuffer = new byte[m_body.Length];
|
RawBufferLen = (int)mb.Length;
|
||||||
RawBufferLen = m_body.Read(RawBuffer, 0, (int)m_body.Length);
|
mb.Dispose();
|
||||||
m_body.Dispose();
|
m_body = null;
|
||||||
|
|
||||||
if(RawBufferLen > 0)
|
if(RawBufferLen > 0)
|
||||||
{
|
{
|
||||||
|
@ -634,32 +632,6 @@ namespace OSHttpServer
|
||||||
m_context.ReqResponseSent(requestID, Connection);
|
m_context.ReqResponseSent(requestID, Connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Redirect client to somewhere else using the 302 status code.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="uri">Destination of the redirect</param>
|
|
||||||
/// <exception cref="InvalidOperationException">If headers already been sent.</exception>
|
|
||||||
/// <remarks>You can not do anything more with the request when a redirect have been done. This should be your last
|
|
||||||
/// action.</remarks>
|
|
||||||
public void Redirect(Uri uri)
|
|
||||||
{
|
|
||||||
Status = HttpStatusCode.Redirect;
|
|
||||||
m_headers["location"] = uri.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// redirect to somewhere
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="url">where the redirect should go</param>
|
|
||||||
/// <remarks>
|
|
||||||
/// No body are allowed when doing redirects.
|
|
||||||
/// </remarks>
|
|
||||||
public void Redirect(string url)
|
|
||||||
{
|
|
||||||
Status = HttpStatusCode.Redirect;
|
|
||||||
m_headers["location"] = url;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
if(Body != null && Body.CanRead)
|
if(Body != null && Body.CanRead)
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace OSHttpServer
|
||||||
/// before sending everything to the client. It's the simplest
|
/// before sending everything to the client. It's the simplest
|
||||||
/// way to serve documents.
|
/// way to serve documents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Stream Body { get; set; }
|
Stream Body { get; }
|
||||||
byte[] RawBuffer { get; set; }
|
byte[] RawBuffer { get; set; }
|
||||||
int RawBufferStart { get; set; }
|
int RawBufferStart { get; set; }
|
||||||
int RawBufferLen { get; set; }
|
int RawBufferLen { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue