2 // System.Web.HttpResponseTest.cs - Unit tests for System.Web.HttpResponse
5 // Miguel de Icaza <miguel@ximian.com>
7 // Copyright (C) 2005-2009 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Collections;
33 using System.Collections.Specialized;
34 using NUnit.Framework;
36 namespace MonoTests.Common
39 public class FakeHttpWorkerRequest : HttpWorkerRequest
42 public Hashtable KnownResponseHeaders;
43 public Hashtable UnknownResponseHeaders;
44 public int return_kind;
46 public FakeHttpWorkerRequest ()
51 public FakeHttpWorkerRequest (int re)
53 KnownResponseHeaders = CollectionsUtil.CreateCaseInsensitiveHashtable ();
54 UnknownResponseHeaders = CollectionsUtil.CreateCaseInsensitiveHashtable ();
56 queryString = String.Empty;
59 public override string GetUriPath ()
64 public override string GetQueryString ()
69 public void SetQueryString (string queryString)
71 this.queryString = queryString;
74 public override string GetRawUrl ()
79 public override string GetHttpVerbName ()
84 public override string GetHttpVersion ()
92 public override string GetRemoteAddress ()
94 return "__GetRemoteAddress";
97 public override int GetRemotePort ()
102 public override string GetLocalAddress ()
104 return "GetLocalAddress";
107 public override string GetAppPath ()
112 public override int GetLocalPort ()
117 public bool status_sent;
118 public int status_code;
119 public string status_string;
121 public override void SendStatus (int s, string x)
128 void AddHeader (Hashtable table, string header_name, object header)
130 object o = table[header_name];
132 table.Add (header_name, header);
134 ArrayList al = o as ArrayList;
136 al = new ArrayList ();
138 table[header_name] = al;
147 public override void SendKnownResponseHeader (int x, string j)
149 string header_name = HttpWorkerRequest.GetKnownRequestHeaderName (x);
150 AddHeader (KnownResponseHeaders, header_name, new KnownResponseHeader (x, j));
154 public override void SendUnknownResponseHeader (string a, string b)
156 AddHeader (UnknownResponseHeaders, a, new UnknownResponseHeader (a, b));
163 public int total = 0;
165 public override void SendResponseFromMemory (byte[] arr, int x)
169 for (int i = 0; i < x; i++)
175 public override void SendResponseFromFile (string a, long b, long c)
180 public override void SendResponseFromFile (IntPtr a, long b, long c)
185 public override void FlushResponse (bool x)
189 public override void EndOfRequest ()
193 public override string GetKnownRequestHeader (int index)
198 public bool OutputProduced
202 return headers_sent || data_sent;