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
41 const string appPath = "/";
43 public Hashtable KnownResponseHeaders;
44 public Hashtable UnknownResponseHeaders;
45 public int return_kind;
47 public FakeHttpWorkerRequest ()
51 AppDomain.CurrentDomain.SetData (".appVPath", appPath);
54 public FakeHttpWorkerRequest (int re)
56 KnownResponseHeaders = CollectionsUtil.CreateCaseInsensitiveHashtable ();
57 UnknownResponseHeaders = CollectionsUtil.CreateCaseInsensitiveHashtable ();
59 queryString = String.Empty;
62 public override string GetUriPath ()
67 public override string GetFilePath ()
72 public override string GetQueryString ()
77 public void SetQueryString (string queryString)
79 this.queryString = queryString;
82 public override string GetRawUrl ()
87 public override string GetHttpVerbName ()
92 public override string GetHttpVersion ()
100 public override string GetRemoteAddress ()
102 return "__GetRemoteAddress";
105 public override int GetRemotePort ()
110 public override string GetLocalAddress ()
112 return "GetLocalAddress";
115 public override string GetAppPath ()
120 public override int GetLocalPort ()
125 public override string MapPath (string virtualPath)
128 return "c:\\fakefile";
134 public bool status_sent;
135 public int status_code;
136 public string status_string;
138 public override void SendStatus (int s, string x)
145 void AddHeader (Hashtable table, string header_name, object header)
147 object o = table[header_name];
149 table.Add (header_name, header);
151 ArrayList al = o as ArrayList;
153 al = new ArrayList ();
155 table[header_name] = al;
164 public override void SendKnownResponseHeader (int x, string j)
166 string header_name = HttpWorkerRequest.GetKnownRequestHeaderName (x);
167 AddHeader (KnownResponseHeaders, header_name, new KnownResponseHeader (x, j));
171 public override void SendUnknownResponseHeader (string a, string b)
173 AddHeader (UnknownResponseHeaders, a, new UnknownResponseHeader (a, b));
180 public int total = 0;
182 public override void SendResponseFromMemory (byte[] arr, int x)
186 for (int i = 0; i < x; i++)
192 public override void SendResponseFromFile (string a, long b, long c)
197 public override void SendResponseFromFile (IntPtr a, long b, long c)
202 public override void FlushResponse (bool x)
206 public override void EndOfRequest ()
210 public override string GetKnownRequestHeader (int index)
215 public bool OutputProduced
219 return headers_sent || data_sent;