TestHttpResponse.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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.IO;
  29. using System.Net;
  30. using System.Text;
  31. using HttpServer;
  32. namespace OpenSim.Tests.Common
  33. {
  34. /*
  35. public class TestHttpResponse: IHttpResponse
  36. {
  37. public Stream Body
  38. {
  39. get { return _body; }
  40. set { _body = value; }
  41. }
  42. private Stream _body;
  43. public string ProtocolVersion
  44. {
  45. get { return _protocolVersion; }
  46. set { _protocolVersion = value; }
  47. }
  48. private string _protocolVersion;
  49. public bool Chunked
  50. {
  51. get { return _chunked; }
  52. set { _chunked = value; }
  53. }
  54. private bool _chunked;
  55. public ConnectionType Connection
  56. {
  57. get { return _connection; }
  58. set { _connection = value; }
  59. }
  60. private ConnectionType _connection;
  61. public Encoding Encoding
  62. {
  63. get { return _encoding; }
  64. set { _encoding = value; }
  65. }
  66. private Encoding _encoding;
  67. public int KeepAlive
  68. {
  69. get { return _keepAlive; }
  70. set { _keepAlive = value; }
  71. }
  72. private int _keepAlive;
  73. public HttpStatusCode Status
  74. {
  75. get { return _status; }
  76. set { _status = value; }
  77. }
  78. private HttpStatusCode _status;
  79. public string Reason
  80. {
  81. get { return _reason; }
  82. set { _reason = value; }
  83. }
  84. private string _reason;
  85. public long ContentLength
  86. {
  87. get { return _contentLength; }
  88. set { _contentLength = value; }
  89. }
  90. private long _contentLength;
  91. public string ContentType
  92. {
  93. get { return _contentType; }
  94. set { _contentType = value; }
  95. }
  96. private string _contentType;
  97. public bool HeadersSent
  98. {
  99. get { return _headersSent; }
  100. }
  101. private bool _headersSent;
  102. public bool Sent
  103. {
  104. get { return _sent; }
  105. }
  106. private bool _sent;
  107. public ResponseCookies Cookies
  108. {
  109. get { return _cookies; }
  110. }
  111. private ResponseCookies _cookies = null;
  112. public TestHttpResponse()
  113. {
  114. _headersSent = false;
  115. _sent = false;
  116. }
  117. public void AddHeader(string name, string value) {}
  118. public void Send()
  119. {
  120. if (!_headersSent) SendHeaders();
  121. if (_sent) throw new InvalidOperationException("stuff already sent");
  122. _sent = true;
  123. }
  124. public void SendBody(byte[] buffer, int offset, int count)
  125. {
  126. if (!_headersSent) SendHeaders();
  127. _sent = true;
  128. }
  129. public void SendBody(byte[] buffer)
  130. {
  131. if (!_headersSent) SendHeaders();
  132. _sent = true;
  133. }
  134. public void SendHeaders()
  135. {
  136. if (_headersSent) throw new InvalidOperationException("headers already sent");
  137. _headersSent = true;
  138. }
  139. public void Redirect(Uri uri) {}
  140. public void Redirect(string url) {}
  141. }
  142. */
  143. }