jellyfin-server/MediaBrowser.Common/Net/Response.cs

77 lines
1.7 KiB
C#
Raw Normal View History

2012-07-12 06:55:27 +00:00
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
2012-07-12 06:55:27 +00:00
using System.IO;
namespace MediaBrowser.Common.Net
2012-07-12 06:55:27 +00:00
{
public abstract class Response
2012-07-12 06:55:27 +00:00
{
protected RequestContext RequestContext { get; private set; }
protected NameValueCollection QueryString
{
get
{
return RequestContext.Request.QueryString;
}
}
2012-07-12 06:55:27 +00:00
public Response(RequestContext ctx)
{
RequestContext = ctx;
2012-07-12 06:55:27 +00:00
WriteStream = s => { };
Headers = new Dictionary<string, string>();
}
public abstract string ContentType { get; }
public virtual int StatusCode
{
get
{
return 200;
}
}
public virtual TimeSpan CacheDuration
{
get
{
return TimeSpan.FromTicks(0);
}
}
public virtual DateTime? LastDateModified
{
get
{
return null;
}
}
2012-07-12 06:55:27 +00:00
public IDictionary<string, string> Headers { get; set; }
public Action<Stream> WriteStream { get; set; }
}
/*public class ByteResponse : Response
{
public ByteResponse(byte[] bytes)
{
WriteStream = async s =>
{
await s.WriteAsync(bytes, 0, bytes.Length);
s.Close();
};
}
}
public class StringResponse : ByteResponse
{
public StringResponse(string message)
: base(Encoding.UTF8.GetBytes(message))
{
}
}*/
}