diff options
author | MW | 2007-06-08 16:49:24 +0000 |
---|---|---|
committer | MW | 2007-06-08 16:49:24 +0000 |
commit | a8cabbd600f2bf4e3ecd8b48d726f9c1036d9f93 (patch) | |
tree | d9c04b9241c67f892285bc2b9fb05b1e70e40576 /OpenGridServices/OpenGridServices.AssetServer/AssetHttpServer.cs | |
parent | prebuild.xml should be fixed/updated. (diff) | |
download | opensim-SC-a8cabbd600f2bf4e3ecd8b48d726f9c1036d9f93.zip opensim-SC-a8cabbd600f2bf4e3ecd8b48d726f9c1036d9f93.tar.gz opensim-SC-a8cabbd600f2bf4e3ecd8b48d726f9c1036d9f93.tar.bz2 opensim-SC-a8cabbd600f2bf4e3ecd8b48d726f9c1036d9f93.tar.xz |
Deleted OpenGridServices folder as the easiest way to reimport the latest version from trunk
Diffstat (limited to 'OpenGridServices/OpenGridServices.AssetServer/AssetHttpServer.cs')
-rw-r--r-- | OpenGridServices/OpenGridServices.AssetServer/AssetHttpServer.cs | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/OpenGridServices/OpenGridServices.AssetServer/AssetHttpServer.cs b/OpenGridServices/OpenGridServices.AssetServer/AssetHttpServer.cs deleted file mode 100644 index 8439e92..0000000 --- a/OpenGridServices/OpenGridServices.AssetServer/AssetHttpServer.cs +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Net; | ||
4 | using System.Text; | ||
5 | using System.Text.RegularExpressions; | ||
6 | using System.Threading; | ||
7 | //using OpenSim.CAPS; | ||
8 | using Nwc.XmlRpc; | ||
9 | using System.Collections; | ||
10 | using OpenSim.Framework.Console; | ||
11 | using OpenSim.Servers; | ||
12 | |||
13 | namespace OpenGridServices.AssetServer | ||
14 | { | ||
15 | public class AssetHttpServer :BaseHttpServer | ||
16 | { | ||
17 | public AssetHttpServer(int port) | ||
18 | : base(port) | ||
19 | { | ||
20 | } | ||
21 | |||
22 | public override void HandleRequest(Object stateinfo) | ||
23 | { | ||
24 | try | ||
25 | { | ||
26 | HttpListenerContext context = (HttpListenerContext)stateinfo; | ||
27 | |||
28 | HttpListenerRequest request = context.Request; | ||
29 | HttpListenerResponse response = context.Response; | ||
30 | |||
31 | response.KeepAlive = false; | ||
32 | response.SendChunked = false; | ||
33 | |||
34 | System.IO.Stream body = request.InputStream; | ||
35 | System.Text.Encoding encoding = System.Text.Encoding.UTF8; | ||
36 | System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding); | ||
37 | |||
38 | string requestBody = reader.ReadToEnd(); | ||
39 | body.Close(); | ||
40 | reader.Close(); | ||
41 | |||
42 | //Console.WriteLine(request.HttpMethod + " " + request.RawUrl + " Http/" + request.ProtocolVersion.ToString() + " content type: " + request.ContentType); | ||
43 | //Console.WriteLine(requestBody); | ||
44 | |||
45 | string responseString = ""; | ||
46 | switch (request.ContentType) | ||
47 | { | ||
48 | case "text/xml": | ||
49 | // must be XML-RPC, so pass to the XML-RPC parser | ||
50 | |||
51 | responseString = ParseXMLRPC(requestBody); | ||
52 | responseString = Regex.Replace(responseString, "utf-16", "utf-8"); | ||
53 | |||
54 | response.AddHeader("Content-type", "text/xml"); | ||
55 | break; | ||
56 | |||
57 | case "application/xml": | ||
58 | // probably LLSD we hope, otherwise it should be ignored by the parser | ||
59 | responseString = ParseLLSDXML(requestBody); | ||
60 | response.AddHeader("Content-type", "application/xml"); | ||
61 | break; | ||
62 | |||
63 | case "application/x-www-form-urlencoded": | ||
64 | // a form data POST so send to the REST parser | ||
65 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
66 | response.AddHeader("Content-type", "text/plain"); | ||
67 | break; | ||
68 | |||
69 | case null: | ||
70 | // must be REST or invalid crap, so pass to the REST parser | ||
71 | responseString = ParseREST(requestBody, request.RawUrl, request.HttpMethod); | ||
72 | response.AddHeader("Content-type", "text/plain"); | ||
73 | break; | ||
74 | |||
75 | } | ||
76 | |||
77 | Encoding Windows1252Encoding = Encoding.GetEncoding(1252); | ||
78 | byte[] buffer = Windows1252Encoding.GetBytes(responseString); | ||
79 | System.IO.Stream output = response.OutputStream; | ||
80 | response.SendChunked = false; | ||
81 | response.ContentLength64 = buffer.Length; | ||
82 | output.Write(buffer, 0, buffer.Length); | ||
83 | output.Close(); | ||
84 | } | ||
85 | catch (Exception e) | ||
86 | { | ||
87 | Console.WriteLine(e.ToString()); | ||
88 | } | ||
89 | } | ||
90 | |||
91 | } | ||
92 | } | ||