diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/UndoStack.cs | 114 | ||||
-rw-r--r-- | OpenSim/Framework/WebUtil.cs | 24 |
2 files changed, 11 insertions, 127 deletions
diff --git a/OpenSim/Framework/UndoStack.cs b/OpenSim/Framework/UndoStack.cs deleted file mode 100644 index fde63b1..0000000 --- a/OpenSim/Framework/UndoStack.cs +++ /dev/null | |||
@@ -1,114 +0,0 @@ | |||
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 OpenSimulator 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; | ||
29 | |||
30 | namespace OpenSim.Framework | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// Undo stack. Deletes entries beyond a certain capacity | ||
34 | /// </summary> | ||
35 | /// <typeparam name="T"></typeparam> | ||
36 | [Serializable] | ||
37 | public class UndoStack<T> | ||
38 | { | ||
39 | private int m_new = 1; | ||
40 | private int m_old = 0; | ||
41 | private T[] m_Undos; | ||
42 | |||
43 | public UndoStack(int capacity) | ||
44 | { | ||
45 | m_Undos = new T[capacity + 1]; | ||
46 | } | ||
47 | |||
48 | public bool IsFull | ||
49 | { | ||
50 | get { return m_new == m_old; } | ||
51 | } | ||
52 | |||
53 | public int Capacity | ||
54 | { | ||
55 | get { return m_Undos.Length - 1; } | ||
56 | } | ||
57 | |||
58 | public int Count | ||
59 | { | ||
60 | get | ||
61 | { | ||
62 | int count = m_new - m_old - 1; | ||
63 | if (count < 0) | ||
64 | count += m_Undos.Length; | ||
65 | return count; | ||
66 | } | ||
67 | } | ||
68 | |||
69 | public void Push(T item) | ||
70 | { | ||
71 | if (IsFull) | ||
72 | { | ||
73 | m_old++; | ||
74 | if (m_old >= m_Undos.Length) | ||
75 | m_old -= m_Undos.Length; | ||
76 | } | ||
77 | if (++m_new >= m_Undos.Length) | ||
78 | m_new -= m_Undos.Length; | ||
79 | m_Undos[m_new] = item; | ||
80 | } | ||
81 | |||
82 | public T Pop() | ||
83 | { | ||
84 | if (Count > 0) | ||
85 | { | ||
86 | T deleted = m_Undos[m_new]; | ||
87 | m_Undos[m_new--] = default(T); | ||
88 | if (m_new < 0) | ||
89 | m_new += m_Undos.Length; | ||
90 | return deleted; | ||
91 | } | ||
92 | else | ||
93 | throw new InvalidOperationException("Cannot pop from empty stack"); | ||
94 | } | ||
95 | |||
96 | public T Peek() | ||
97 | { | ||
98 | return m_Undos[m_new]; | ||
99 | } | ||
100 | |||
101 | public void Clear() | ||
102 | { | ||
103 | if (Count > 0) | ||
104 | { | ||
105 | for (int i = 0; i < m_Undos.Length; i++) | ||
106 | { | ||
107 | m_Undos[i] = default(T); | ||
108 | } | ||
109 | m_new = 1; | ||
110 | m_old = 0; | ||
111 | } | ||
112 | } | ||
113 | } | ||
114 | } | ||
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs index 147a011..be7504f 100644 --- a/OpenSim/Framework/WebUtil.cs +++ b/OpenSim/Framework/WebUtil.cs | |||
@@ -907,15 +907,6 @@ namespace OpenSim.Framework | |||
907 | } | 907 | } |
908 | } | 908 | } |
909 | 909 | ||
910 | public class SynchronousRestObjectPoster | ||
911 | { | ||
912 | [Obsolete] | ||
913 | public static TResponse BeginPostObject<TRequest, TResponse>(string verb, string requestUrl, TRequest obj) | ||
914 | { | ||
915 | return SynchronousRestObjectRequester.MakeRequest<TRequest, TResponse>(verb, requestUrl, obj); | ||
916 | } | ||
917 | } | ||
918 | |||
919 | public class SynchronousRestObjectRequester | 910 | public class SynchronousRestObjectRequester |
920 | { | 911 | { |
921 | private static readonly ILog m_log = | 912 | private static readonly ILog m_log = |
@@ -981,9 +972,6 @@ namespace OpenSim.Framework | |||
981 | { | 972 | { |
982 | using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse()) | 973 | using (HttpWebResponse resp = (HttpWebResponse)request.GetResponse()) |
983 | { | 974 | { |
984 | if (resp.StatusCode == HttpStatusCode.NotFound) | ||
985 | return deserial; | ||
986 | |||
987 | if (resp.ContentLength != 0) | 975 | if (resp.ContentLength != 0) |
988 | { | 976 | { |
989 | Stream respStream = resp.GetResponseStream(); | 977 | Stream respStream = resp.GetResponseStream(); |
@@ -993,9 +981,19 @@ namespace OpenSim.Framework | |||
993 | } | 981 | } |
994 | else | 982 | else |
995 | m_log.DebugFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb); | 983 | m_log.DebugFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb); |
996 | |||
997 | } | 984 | } |
998 | } | 985 | } |
986 | catch (WebException e) | ||
987 | { | ||
988 | HttpWebResponse hwr = (HttpWebResponse)e.Response; | ||
989 | |||
990 | if (hwr != null && hwr.StatusCode == HttpStatusCode.NotFound) | ||
991 | return deserial; | ||
992 | else | ||
993 | m_log.ErrorFormat( | ||
994 | "[SynchronousRestObjectRequester]: WebException {0} {1} {2} {3}", | ||
995 | requestUrl, typeof(TResponse).ToString(), e.Message, e.StackTrace); | ||
996 | } | ||
999 | catch (System.InvalidOperationException) | 997 | catch (System.InvalidOperationException) |
1000 | { | 998 | { |
1001 | // This is what happens when there is invalid XML | 999 | // This is what happens when there is invalid XML |