diff options
author | Dr Scofield | 2008-05-19 11:38:35 +0000 |
---|---|---|
committer | Dr Scofield | 2008-05-19 11:38:35 +0000 |
commit | d725d1208bfbeae02f181cc6731f5a98dc7fce6d (patch) | |
tree | fd27fe08b43c7ef5d15ee0e829947f06d97e8375 /OpenSim/Framework/Servers/OSHttpResponse.cs | |
parent | Rework some of the animation logic in an attempt to resolve #1318 (diff) | |
download | opensim-SC-d725d1208bfbeae02f181cc6731f5a98dc7fce6d.zip opensim-SC-d725d1208bfbeae02f181cc6731f5a98dc7fce6d.tar.gz opensim-SC-d725d1208bfbeae02f181cc6731f5a98dc7fce6d.tar.bz2 opensim-SC-d725d1208bfbeae02f181cc6731f5a98dc7fce6d.tar.xz |
adding OSHttpRequest and OSHttpResponse which wrap HttpListenerRequest and HttpListenerResponse respectively.
enhancing IStreamHandler and IStreamedHandler interfaces so that OSHttp{Request,Response} get passed in,
allowing RestHandlers to set response status code, redirections, etc.
Diffstat (limited to 'OpenSim/Framework/Servers/OSHttpResponse.cs')
-rw-r--r-- | OpenSim/Framework/Servers/OSHttpResponse.cs | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/OpenSim/Framework/Servers/OSHttpResponse.cs b/OpenSim/Framework/Servers/OSHttpResponse.cs new file mode 100644 index 0000000..28d513a --- /dev/null +++ b/OpenSim/Framework/Servers/OSHttpResponse.cs | |||
@@ -0,0 +1,165 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Collections; | ||
29 | using System.IO; | ||
30 | using System.Net; | ||
31 | using System.Text; | ||
32 | |||
33 | namespace OpenSim.Framework.Servers | ||
34 | { | ||
35 | public class OSHttpResponse | ||
36 | { | ||
37 | private string _contentType; | ||
38 | private bool _contentTypeSet; | ||
39 | public string ContentType | ||
40 | { | ||
41 | get { return _contentType; } | ||
42 | set | ||
43 | { | ||
44 | _contentType = value; | ||
45 | _contentTypeSet = true; | ||
46 | } | ||
47 | } | ||
48 | public bool IsContentTypeSet | ||
49 | { | ||
50 | get { return _contentTypeSet; } | ||
51 | } | ||
52 | |||
53 | private long _contentLength64; | ||
54 | public long ContentLength64 | ||
55 | { | ||
56 | get { return _contentLength64; } | ||
57 | set | ||
58 | { | ||
59 | _contentLength64 = value; | ||
60 | if (null != _resp) _resp.ContentLength64 = value; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | private Encoding _contentEncoding; | ||
65 | public Encoding ContentEncoding | ||
66 | { | ||
67 | get { return _contentEncoding; } | ||
68 | set | ||
69 | { | ||
70 | _contentEncoding = value; | ||
71 | if (null != _resp) _resp.ContentEncoding = value; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public WebHeaderCollection Headers; | ||
76 | public CookieCollection Cookies; | ||
77 | |||
78 | private bool _keepAlive; | ||
79 | public bool KeepAlive | ||
80 | { | ||
81 | get { return _keepAlive; } | ||
82 | set | ||
83 | { | ||
84 | _keepAlive = value; | ||
85 | if (null != _resp) _resp.KeepAlive = value; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public Stream OutputStream; | ||
90 | |||
91 | private string _redirectLocation; | ||
92 | public string RedirectLocation | ||
93 | { | ||
94 | get { return _redirectLocation; } | ||
95 | set | ||
96 | { | ||
97 | _redirectLocation = value; | ||
98 | if (null != _resp) _resp.RedirectLocation = value; | ||
99 | } | ||
100 | } | ||
101 | |||
102 | private bool _sendChunked; | ||
103 | public bool SendChunked | ||
104 | { | ||
105 | get { return _sendChunked; } | ||
106 | set | ||
107 | { | ||
108 | _sendChunked = value; | ||
109 | if (null != _resp) _resp.SendChunked = value; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | private int _statusCode; | ||
114 | public int StatusCode | ||
115 | { | ||
116 | get { return _statusCode; } | ||
117 | set | ||
118 | { | ||
119 | _statusCode = value; | ||
120 | if (null != _resp) _resp.StatusCode = value; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | private string _statusDescription; | ||
125 | public string StatusDescription | ||
126 | { | ||
127 | get { return _statusDescription; } | ||
128 | set | ||
129 | { | ||
130 | _statusDescription = value; | ||
131 | if (null != _resp) _resp.StatusDescription = value; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | private HttpListenerResponse _resp; | ||
136 | |||
137 | public OSHttpResponse() | ||
138 | { | ||
139 | } | ||
140 | |||
141 | public OSHttpResponse(HttpListenerResponse resp) | ||
142 | { | ||
143 | ContentEncoding = resp.ContentEncoding; | ||
144 | ContentLength64 = resp.ContentLength64; | ||
145 | _contentType = resp.ContentType; | ||
146 | Headers = resp.Headers; | ||
147 | Cookies = resp.Cookies; | ||
148 | KeepAlive = resp.KeepAlive; | ||
149 | OutputStream = resp.OutputStream; | ||
150 | RedirectLocation = resp.RedirectLocation; | ||
151 | SendChunked = resp.SendChunked; | ||
152 | StatusCode = resp.StatusCode; | ||
153 | StatusDescription = resp.StatusDescription; | ||
154 | |||
155 | _contentTypeSet = false; | ||
156 | |||
157 | _resp = resp; | ||
158 | } | ||
159 | |||
160 | public void AddHeader(string key, string value) | ||
161 | { | ||
162 | Headers.Add(key, value); | ||
163 | } | ||
164 | } | ||
165 | } | ||