diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | 99 |
1 files changed, 50 insertions, 49 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs index 47a0b9c..f83b771 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceHttpRequest.cs | |||
@@ -85,7 +85,13 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
85 | Request.Body.Dispose(); | 85 | Request.Body.Dispose(); |
86 | 86 | ||
87 | OSHttpResponse response | 87 | OSHttpResponse response |
88 | = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext); | 88 | = new OSHttpResponse(new HttpResponse(HttpContext, Request)); |
89 | |||
90 | if (responsedata == null) | ||
91 | { | ||
92 | SendNoContentError(response); | ||
93 | return; | ||
94 | } | ||
89 | 95 | ||
90 | int responsecode = 200; | 96 | int responsecode = 200; |
91 | string responseString = String.Empty; | 97 | string responseString = String.Empty; |
@@ -94,61 +100,44 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
94 | int rangeStart = 0; | 100 | int rangeStart = 0; |
95 | int rangeLen = -1; | 101 | int rangeLen = -1; |
96 | 102 | ||
97 | if (responsedata == null) | 103 | try |
98 | { | ||
99 | responsecode = 500; | ||
100 | responseString = "No response could be obtained"; | ||
101 | contentType = "text/plain"; | ||
102 | responsedata = new Hashtable(); | ||
103 | } | ||
104 | else | ||
105 | { | 104 | { |
106 | try | 105 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); |
107 | { | 106 | if(responsedata["int_response_code"] != null) |
108 | //m_log.Info("[BASE HTTP SERVER]: Doing HTTP Grunt work with response"); | 107 | responsecode = (int)responsedata["int_response_code"]; |
109 | if(responsedata["int_response_code"] != null) | 108 | |
110 | responsecode = (int)responsedata["int_response_code"]; | 109 | if (responsedata["bin_response_data"] != null) |
111 | |||
112 | if (responsedata["bin_response_data"] != null) | ||
113 | { | ||
114 | buffer = (byte[])responsedata["bin_response_data"]; | ||
115 | responsedata["bin_response_data"] = null; | ||
116 | |||
117 | if (responsedata["bin_start"] != null) | ||
118 | rangeStart = (int)responsedata["bin_start"]; | ||
119 | |||
120 | if (responsedata["int_bytes"] != null) | ||
121 | rangeLen = (int)responsedata["int_bytes"]; | ||
122 | } | ||
123 | else | ||
124 | responseString = (string)responsedata["str_response_string"]; | ||
125 | |||
126 | contentType = (string)responsedata["content_type"]; | ||
127 | if (responseString == null) | ||
128 | responseString = String.Empty; | ||
129 | } | ||
130 | catch | ||
131 | { | 110 | { |
132 | responsecode = 500; | 111 | buffer = (byte[])responsedata["bin_response_data"]; |
133 | responseString = "No response could be obtained"; | 112 | responsedata["bin_response_data"] = null; |
134 | contentType = "text/plain"; | 113 | |
135 | responsedata = new Hashtable(); | 114 | if (responsedata["bin_start"] != null) |
115 | rangeStart = (int)responsedata["bin_start"]; | ||
116 | |||
117 | if (responsedata["int_bytes"] != null) | ||
118 | rangeLen = (int)responsedata["int_bytes"]; | ||
136 | } | 119 | } |
120 | else | ||
121 | responseString = (string)responsedata["str_response_string"]; | ||
122 | |||
123 | contentType = (string)responsedata["content_type"]; | ||
124 | if (responseString == null) | ||
125 | responseString = String.Empty; | ||
126 | } | ||
127 | catch | ||
128 | { | ||
129 | SendNoContentError(response); | ||
130 | return; | ||
137 | } | 131 | } |
138 | 132 | ||
139 | if (responsedata.ContainsKey("error_status_text")) | 133 | if (responsedata.ContainsKey("error_status_text")) |
140 | { | ||
141 | response.StatusDescription = (string)responsedata["error_status_text"]; | 134 | response.StatusDescription = (string)responsedata["error_status_text"]; |
142 | } | 135 | |
143 | if (responsedata.ContainsKey("http_protocol_version")) | 136 | if (responsedata.ContainsKey("http_protocol_version")) |
144 | { | ||
145 | response.ProtocolVersion = (string)responsedata["http_protocol_version"]; | 137 | response.ProtocolVersion = (string)responsedata["http_protocol_version"]; |
146 | } | 138 | |
147 | if (responsedata.ContainsKey("keepalive")) | 139 | if (responsedata.ContainsKey("keepalive")) |
148 | { | 140 | response.KeepAlive = (bool)responsedata["keepalive"]; |
149 | bool keepalive = (bool)responsedata["keepalive"]; | ||
150 | response.KeepAlive = keepalive; | ||
151 | } | ||
152 | 141 | ||
153 | // Cross-Origin Resource Sharing with simple requests | 142 | // Cross-Origin Resource Sharing with simple requests |
154 | if (responsedata.ContainsKey("access_control_allow_origin")) | 143 | if (responsedata.ContainsKey("access_control_allow_origin")) |
@@ -200,7 +189,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
200 | else if (rangeLen + rangeStart > buffer.Length) | 189 | else if (rangeLen + rangeStart > buffer.Length) |
201 | rangeLen = buffer.Length - rangeStart; | 190 | rangeLen = buffer.Length - rangeStart; |
202 | 191 | ||
203 | response.SendChunked = false; | ||
204 | response.ContentLength64 = rangeLen; | 192 | response.ContentLength64 = rangeLen; |
205 | 193 | ||
206 | try | 194 | try |
@@ -233,10 +221,24 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
233 | PollServiceArgs.RequestsHandled++; | 221 | PollServiceArgs.RequestsHandled++; |
234 | } | 222 | } |
235 | 223 | ||
224 | internal void SendNoContentError(OSHttpResponse response) | ||
225 | { | ||
226 | response.ContentLength64 = 0; | ||
227 | response.ContentEncoding = Encoding.UTF8; | ||
228 | response.StatusCode = 500; | ||
229 | |||
230 | try | ||
231 | { | ||
232 | response.Send(); | ||
233 | } | ||
234 | catch { } | ||
235 | return; | ||
236 | } | ||
237 | |||
236 | internal void DoHTTPstop() | 238 | internal void DoHTTPstop() |
237 | { | 239 | { |
238 | OSHttpResponse response | 240 | OSHttpResponse response |
239 | = new OSHttpResponse(new HttpResponse(HttpContext, Request), HttpContext); | 241 | = new OSHttpResponse(new HttpResponse(HttpContext, Request)); |
240 | 242 | ||
241 | if(Request.Body.CanRead) | 243 | if(Request.Body.CanRead) |
242 | Request.Body.Dispose(); | 244 | Request.Body.Dispose(); |
@@ -244,7 +246,6 @@ namespace OpenSim.Framework.Servers.HttpServer | |||
244 | response.ContentLength64 = 0; | 246 | response.ContentLength64 = 0; |
245 | response.ContentEncoding = Encoding.UTF8; | 247 | response.ContentEncoding = Encoding.UTF8; |
246 | response.KeepAlive = false; | 248 | response.KeepAlive = false; |
247 | response.SendChunked = false; | ||
248 | response.StatusCode = 503; | 249 | response.StatusCode = 503; |
249 | 250 | ||
250 | try | 251 | try |