1
0

TestHttpRequest.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. using System;
  28. using System.Collections.Specialized;
  29. using System.IO;
  30. using OSHttpServer;
  31. namespace OpenSim.Tests.Common
  32. {
  33. /*
  34. public class TestHttpRequest: IHttpRequest
  35. {
  36. private string _uriPath;
  37. public bool BodyIsComplete
  38. {
  39. get { return true; }
  40. }
  41. public string[] AcceptTypes
  42. {
  43. get {return _acceptTypes; }
  44. }
  45. private string[] _acceptTypes;
  46. public Stream Body
  47. {
  48. get { return _body; }
  49. set { _body = value;}
  50. }
  51. private Stream _body;
  52. public ConnectionType Connection
  53. {
  54. get { return _connection; }
  55. set { _connection = value; }
  56. }
  57. private ConnectionType _connection;
  58. public int ContentLength
  59. {
  60. get { return _contentLength; }
  61. set { _contentLength = value; }
  62. }
  63. private int _contentLength;
  64. public NameValueCollection Headers
  65. {
  66. get { return _headers; }
  67. }
  68. private NameValueCollection _headers = new NameValueCollection();
  69. public string HttpVersion { get; set; }
  70. public string Method
  71. {
  72. get { return _method; }
  73. set { _method = value; }
  74. }
  75. private string _method = null;
  76. public HttpInput QueryString
  77. {
  78. get { return _queryString; }
  79. }
  80. private HttpInput _queryString = null;
  81. public Uri Uri
  82. {
  83. get { return _uri; }
  84. set { _uri = value; }
  85. }
  86. private Uri _uri = null;
  87. public string[] UriParts
  88. {
  89. get { return _uri.Segments; }
  90. }
  91. public HttpParam Param
  92. {
  93. get { return null; }
  94. }
  95. public HttpForm Form
  96. {
  97. get { return null; }
  98. }
  99. public bool IsAjax
  100. {
  101. get { return false; }
  102. }
  103. public RequestCookies Cookies
  104. {
  105. get { return null; }
  106. }
  107. public TestHttpRequest()
  108. {
  109. HttpVersion = "HTTP/1.1";
  110. }
  111. public TestHttpRequest(string contentEncoding, string contentType, string userAgent,
  112. string remoteAddr, string remotePort, string[] acceptTypes,
  113. ConnectionType connectionType, int contentLength, Uri uri) : base()
  114. {
  115. _headers["content-encoding"] = contentEncoding;
  116. _headers["content-type"] = contentType;
  117. _headers["user-agent"] = userAgent;
  118. _headers["remote_addr"] = remoteAddr;
  119. _headers["remote_port"] = remotePort;
  120. _acceptTypes = acceptTypes;
  121. _connection = connectionType;
  122. _contentLength = contentLength;
  123. _uri = uri;
  124. }
  125. public void DecodeBody(FormDecoderProvider providers) {}
  126. public void SetCookies(RequestCookies cookies) {}
  127. public void AddHeader(string name, string value)
  128. {
  129. _headers.Add(name, value);
  130. }
  131. public int AddToBody(byte[] bytes, int offset, int length)
  132. {
  133. return 0;
  134. }
  135. public void Clear() {}
  136. public object Clone()
  137. {
  138. TestHttpRequest clone = new TestHttpRequest();
  139. clone._acceptTypes = _acceptTypes;
  140. clone._connection = _connection;
  141. clone._contentLength = _contentLength;
  142. clone._uri = _uri;
  143. clone._headers = new NameValueCollection(_headers);
  144. return clone;
  145. }
  146. public IHttpResponse CreateResponse(IHttpClientContext context)
  147. {
  148. return new HttpResponse(context, this);
  149. }
  150. /// <summary>
  151. /// Path and query (will be merged with the host header) and put in Uri
  152. /// </summary>
  153. /// <see cref="Uri"/>
  154. public string UriPath
  155. {
  156. get { return _uriPath; }
  157. set
  158. {
  159. _uriPath = value;
  160. }
  161. }
  162. }
  163. */
  164. }