root/trunk/src/openbastard/OpenBastard.TestRunner/Environments/WebRequestResponse.cs @ 427

Revision 427, 1.8 KB (checked in by serialseb, 7 months ago)

trunk changes pre-RC

Line 
1using System.Collections.Generic;
2using System.IO;
3using System.Net;
4using OpenRasta;
5using OpenRasta.Codecs;
6using OpenRasta.Web;
7using OpenRasta.Web.Headers;
8
9namespace OpenBastard.Environments
10{
11    public class WebRequestResponse : IResponse, IHttpEntity
12    {
13        readonly HttpWebResponse _response;
14
15        public WebRequestResponse(HttpWebResponse response)
16        {
17            _response = response;
18            if (!string.IsNullOrEmpty(response.ContentType))
19                ContentType = new MediaType(response.ContentType);
20
21            ContentLength = response.ContentLength;
22            Headers = new HttpHeaderDictionary();
23            foreach (string headerName in response.Headers.AllKeys)
24                Headers[headerName] = response.Headers[headerName];
25        }
26
27        public ICodec Codec
28        {
29            get { return null; }
30            set { }
31        }
32
33        public long? ContentLength { get; set; }
34        public MediaType ContentType { get; set; }
35
36        public IHttpEntity Entity
37        {
38            get { return this; }
39        }
40
41        public IList<Error> Errors
42        {
43            get { return new Error[0]; }
44        }
45
46        public HttpHeaderDictionary Headers { get; private set; }
47
48        public bool HeadersSent
49        {
50            get { return true; }
51        }
52
53        public object Instance
54        {
55            get { return null; }
56            set { }
57        }
58
59        public int StatusCode
60        {
61            get { return (int)_response.StatusCode; }
62            set { }
63        }
64
65        public Stream Stream
66        {
67            get { return _response.GetResponseStream(); }
68        }
69
70        public void WriteHeaders()
71        {
72        }
73    }
74}
Note: See TracBrowser for help on using the browser.