aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Net/Response.cs
blob: a119198cb3025acded6ebc31369c10bcd4cae445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace MediaBrowser.Controller.Net
{
    public class Response
    {
        protected RequestContext RequestContext { get; private set; }
        
        public Response(RequestContext ctx)
        {
            RequestContext = ctx;
            
            WriteStream = s => { };
            StatusCode = 200;
            Headers = new Dictionary<string, string>();
            CacheDuration = TimeSpan.FromTicks(0);
            ContentType = "text/html";
        }

        public int StatusCode { get; set; }
        public string ContentType { get; set; }
        public IDictionary<string, string> Headers { get; set; }
        public TimeSpan CacheDuration { 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))
        {
        }
    }*/
}