1 | |
---|
2 | /* |
---|
3 | XML-RPC.NET library |
---|
4 | Copyright (c) 2001-2007, Charles Cook <charlescook@cookcomputing.com> |
---|
5 | |
---|
6 | Permission is hereby granted, free of charge, to any person |
---|
7 | obtaining a copy of this software and associated documentation |
---|
8 | files (the "Software"), to deal in the Software without restriction, |
---|
9 | including without limitation the rights to use, copy, modify, merge, |
---|
10 | publish, distribute, sublicense, and/or sell copies of the Software, |
---|
11 | and to permit persons to whom the Software is furnished to do so, |
---|
12 | subject to the following conditions: |
---|
13 | |
---|
14 | The above copyright notice and this permission notice shall be |
---|
15 | included in all copies or substantial portions of the Software. |
---|
16 | |
---|
17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
---|
18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
---|
19 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
---|
20 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
---|
21 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
---|
22 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
---|
23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
24 | DEALINGS IN THE SOFTWARE. |
---|
25 | */ |
---|
26 | |
---|
27 | #if !FX1_0 |
---|
28 | |
---|
29 | namespace CookComputing.XmlRpc |
---|
30 | { |
---|
31 | using System; |
---|
32 | using System.Net; |
---|
33 | |
---|
34 | public abstract class XmlRpcListenerService : XmlRpcHttpServerProtocol |
---|
35 | { |
---|
36 | bool _sendChunked = false; |
---|
37 | |
---|
38 | public virtual void ProcessRequest(HttpListenerContext RequestContext) |
---|
39 | { |
---|
40 | try |
---|
41 | { |
---|
42 | IHttpRequest req = new XmlRpcListenerRequest(RequestContext.Request); |
---|
43 | IHttpResponse resp = new XmlRpcListenerResponse(RequestContext.Response); |
---|
44 | resp.SendChunked = _sendChunked; |
---|
45 | HandleHttpRequest(req, resp); |
---|
46 | } |
---|
47 | catch (Exception ex) |
---|
48 | { |
---|
49 | // "Internal server error" |
---|
50 | RequestContext.Response.StatusCode = 500; |
---|
51 | RequestContext.Response.StatusDescription = ex.Message; |
---|
52 | } |
---|
53 | finally |
---|
54 | { |
---|
55 | RequestContext.Response.OutputStream.Close(); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | public bool SendChunked |
---|
60 | { |
---|
61 | get { return _sendChunked; } |
---|
62 | set { _sendChunked = value; } |
---|
63 | } |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | #endif |
---|