HttpTransportBindingElement.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. //
  2. // HttpTransportBindingElement.cs
  3. //
  4. // Author:
  5. // Atsushi Enomoto <[email protected]>
  6. //
  7. // Copyright (C) 2005 Novell, Inc. http://www.novell.com
  8. //
  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:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  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.
  27. //
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Net.Security;
  32. using System.ServiceModel.Channels;
  33. using System.ServiceModel.Description;
  34. namespace System.ServiceModel.Channels
  35. {
  36. [MonoTODO]
  37. public class HttpTransportBindingElement : TransportBindingElement,
  38. IPolicyExportExtension, IWsdlExportExtension
  39. {
  40. bool allow_cookies, bypass_proxy_on_local,
  41. unsafe_ntlm_auth;
  42. bool use_default_proxy = true, keep_alive_enabled = true;
  43. int max_buffer_size = 0x10000;
  44. AuthenticationSchemes auth_scheme =
  45. AuthenticationSchemes.Anonymous;
  46. AuthenticationSchemes proxy_auth_scheme =
  47. AuthenticationSchemes.Anonymous;
  48. HostNameComparisonMode host_cmp_mode;
  49. Uri proxy_address;
  50. string realm = String.Empty;
  51. TransferMode transfer_mode;
  52. IDefaultCommunicationTimeouts timeouts;
  53. // If you add fields, do not forget them in copy constructor.
  54. public HttpTransportBindingElement ()
  55. {
  56. }
  57. protected HttpTransportBindingElement (
  58. HttpTransportBindingElement other)
  59. : base (other)
  60. {
  61. allow_cookies = other.allow_cookies;
  62. bypass_proxy_on_local = other.bypass_proxy_on_local;
  63. unsafe_ntlm_auth = other.unsafe_ntlm_auth;
  64. use_default_proxy = other.use_default_proxy;
  65. keep_alive_enabled = other.keep_alive_enabled;
  66. max_buffer_size = other.max_buffer_size;
  67. auth_scheme = other.auth_scheme;
  68. proxy_auth_scheme = other.proxy_auth_scheme;
  69. host_cmp_mode = other.host_cmp_mode;
  70. proxy_address = other.proxy_address;
  71. realm = other.realm;
  72. transfer_mode = other.transfer_mode;
  73. // FIXME: it does not look safe
  74. timeouts = other.timeouts;
  75. }
  76. public bool AllowCookies {
  77. get { return allow_cookies; }
  78. set { allow_cookies = value; }
  79. }
  80. public AuthenticationSchemes AuthenticationScheme {
  81. get { return auth_scheme; }
  82. set { auth_scheme = value; }
  83. }
  84. public bool BypassProxyOnLocal {
  85. get { return bypass_proxy_on_local; }
  86. set { bypass_proxy_on_local = value; }
  87. }
  88. public HostNameComparisonMode HostNameComparisonMode {
  89. get { return host_cmp_mode; }
  90. set { host_cmp_mode = value; }
  91. }
  92. public bool KeepAliveEnabled {
  93. get { return keep_alive_enabled; }
  94. set { keep_alive_enabled = value; }
  95. }
  96. public int MaxBufferSize {
  97. get { return max_buffer_size; }
  98. set { max_buffer_size = value; }
  99. }
  100. public Uri ProxyAddress {
  101. get { return proxy_address; }
  102. set { proxy_address = value; }
  103. }
  104. public AuthenticationSchemes ProxyAuthenticationScheme {
  105. get { return proxy_auth_scheme; }
  106. set { proxy_auth_scheme = value; }
  107. }
  108. public string Realm {
  109. get { return realm; }
  110. set { realm = value; }
  111. }
  112. public override string Scheme {
  113. get { return Uri.UriSchemeHttp; }
  114. }
  115. public TransferMode TransferMode {
  116. get { return transfer_mode; }
  117. set { transfer_mode = value; }
  118. }
  119. public bool UnsafeConnectionNtlmAuthentication {
  120. get { return unsafe_ntlm_auth; }
  121. set { unsafe_ntlm_auth = value; }
  122. }
  123. public bool UseDefaultWebProxy {
  124. get { return use_default_proxy; }
  125. set { use_default_proxy = value; }
  126. }
  127. public override bool CanBuildChannelFactory<TChannel> (
  128. BindingContext context)
  129. {
  130. return typeof (TChannel) == typeof (IRequestChannel);
  131. }
  132. #if !NET_2_1
  133. public override bool CanBuildChannelListener<TChannel> (
  134. BindingContext context)
  135. {
  136. return typeof (TChannel) == typeof (IReplyChannel);
  137. }
  138. #endif
  139. public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
  140. BindingContext context)
  141. {
  142. // remaining contexts are ignored ... e.g. such binding
  143. // element that always causes an error is ignored.
  144. return new HttpChannelFactory<TChannel> (this, context);
  145. }
  146. #if !NET_2_1
  147. public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
  148. BindingContext context)
  149. {
  150. // remaining contexts are ignored ... e.g. such binding
  151. // element that always causes an error is ignored.
  152. return new HttpChannelListener<TChannel> (this, context);
  153. }
  154. #endif
  155. public override BindingElement Clone ()
  156. {
  157. return new HttpTransportBindingElement (this);
  158. }
  159. [MonoTODO]
  160. public override T GetProperty<T> (BindingContext context)
  161. {
  162. return base.GetProperty<T> (context);
  163. }
  164. #if !NET_2_1
  165. [MonoTODO]
  166. void IPolicyExportExtension.ExportPolicy (
  167. MetadataExporter exporter,
  168. PolicyConversionContext context)
  169. {
  170. throw new NotImplementedException ();
  171. }
  172. [MonoTODO]
  173. void IWsdlExportExtension.ExportContract (WsdlExporter exporter,
  174. WsdlContractConversionContext context)
  175. {
  176. throw new NotImplementedException ();
  177. }
  178. [MonoTODO]
  179. void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter,
  180. WsdlEndpointConversionContext context)
  181. {
  182. throw new NotImplementedException ();
  183. }
  184. #endif
  185. }
  186. }