OSHttpRequest.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 OpenSim 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.Net;
  30. using System.IO;
  31. using System.Text;
  32. namespace OpenSim.Framework.Servers
  33. {
  34. public class OSHttpRequest
  35. {
  36. private string[] _acceptTypes;
  37. private Encoding _contentEncoding;
  38. private long _contentLength64;
  39. private string _contentType;
  40. private CookieCollection _cookies;
  41. private NameValueCollection _headers;
  42. private string _httpMethod;
  43. private Stream _inputStream;
  44. private bool _isSecureConnection;
  45. private bool _isAuthenticated;
  46. private bool _keepAlive;
  47. private bool _hasbody;
  48. private string _rawUrl;
  49. private Uri _url;
  50. private NameValueCollection _queryString;
  51. private string _userAgent;
  52. public string[] AcceptTypes
  53. {
  54. get { return _acceptTypes; }
  55. }
  56. public Encoding ContentEncoding
  57. {
  58. get { return _contentEncoding; }
  59. }
  60. public long ContentLength
  61. {
  62. get { return _contentLength64; }
  63. }
  64. public string ContentType
  65. {
  66. get { return _contentType; }
  67. }
  68. public CookieCollection Cookies
  69. {
  70. get { return _cookies; }
  71. }
  72. public NameValueCollection Headers
  73. {
  74. get { return _headers; }
  75. }
  76. public string HttpMethod
  77. {
  78. get { return _httpMethod; }
  79. }
  80. public Stream InputStream
  81. {
  82. get { return _inputStream; }
  83. }
  84. public bool IsSecureConnection
  85. {
  86. get { return _isSecureConnection; }
  87. }
  88. public bool IsAuthenticated
  89. {
  90. get { return _isAuthenticated; }
  91. }
  92. public bool HasEntityBody
  93. {
  94. get { return _hasbody; }
  95. }
  96. public bool KeepAlive
  97. {
  98. get { return _keepAlive; }
  99. }
  100. public string RawUrl
  101. {
  102. get { return _rawUrl; }
  103. }
  104. public Uri Url
  105. {
  106. get { return _url; }
  107. }
  108. public string UserAgent
  109. {
  110. get { return _userAgent; }
  111. }
  112. public NameValueCollection QueryString
  113. {
  114. get { return _queryString; }
  115. }
  116. public OSHttpRequest()
  117. {
  118. }
  119. public OSHttpRequest(HttpListenerRequest req)
  120. {
  121. _acceptTypes = req.AcceptTypes;
  122. _contentEncoding = req.ContentEncoding;
  123. _contentLength64 = req.ContentLength64;
  124. _contentType = req.ContentType;
  125. _cookies = req.Cookies;
  126. _headers = req.Headers;
  127. _httpMethod = req.HttpMethod;
  128. _hasbody = req.HasEntityBody;
  129. _inputStream = req.InputStream;
  130. _isSecureConnection = req.IsSecureConnection;
  131. _isAuthenticated = req.IsAuthenticated;
  132. _keepAlive = req.KeepAlive;
  133. _rawUrl = req.RawUrl;
  134. _url = req.Url;
  135. _queryString = req.QueryString;
  136. _userAgent = req.UserAgent;
  137. }
  138. }
  139. }