-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStreamWithResponse.cs
More file actions
77 lines (65 loc) · 2.24 KB
/
Copy pathStreamWithResponse.cs
File metadata and controls
77 lines (65 loc) · 2.24 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System.Collections.Generic;
using System.IO;
using Nancy.Rest.Module.Interfaces;
namespace Nancy.Rest.Module
{
public class StreamWithResponse : Stream, IStreamWithResponse
{
public Stream Stream { get; set; }
public string ContentType { get; set; }
public HttpStatusCode ResponseStatus { get; set; }
public string ResponseDescription { get; set; }
public Dictionary<string,string> Headers { get; } = new Dictionary<string, string>();
public long ContentLength { get; set; }
public bool HasContent => Stream!=null;
public StreamWithResponse(Stream stream, string contentType)
{
Stream = stream;
ContentType = contentType;
ResponseStatus = HttpStatusCode.OK;
}
public StreamWithResponse(Stream stream, string contentType, HttpStatusCode responseStatus)
{
Stream = stream;
ContentType = contentType;
ResponseStatus = responseStatus;
}
public StreamWithResponse(HttpStatusCode responseStatus, string description=null)
{
ResponseStatus = responseStatus;
ResponseDescription = description;
}
public StreamWithResponse()
{
}
public override void Flush()
{
Stream.Flush();
}
public override long Seek(long offset, SeekOrigin origin)
{
return Stream.Seek(offset, origin);
}
public override void SetLength(long value)
{
Stream.SetLength(value);
}
public override int Read(byte[] buffer, int offset, int count)
{
return Stream.Read(buffer, offset, count);
}
public override void Write(byte[] buffer, int offset, int count)
{
Stream.Write(buffer, offset, count);
}
public override bool CanRead => Stream.CanRead;
public override bool CanSeek => Stream.CanSeek;
public override bool CanWrite => Stream.CanWrite;
public override long Length => Stream.Length;
public override long Position
{
get { return Stream.Position; }
set { Stream.Position = value; }
}
}
}