2 // HttpTransportBindingElement.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2005 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.
29 using System.Collections.Generic;
31 using System.Net.Security;
32 using System.ServiceModel.Channels;
33 using System.ServiceModel.Description;
35 namespace System.ServiceModel.Channels
38 public class HttpTransportBindingElement : TransportBindingElement,
39 IPolicyExportExtension, IWsdlExportExtension
41 bool allow_cookies, bypass_proxy_on_local,
43 bool use_default_proxy = true, keep_alive_enabled = true;
44 int max_buffer_size = 0x10000;
45 AuthenticationSchemes auth_scheme =
46 AuthenticationSchemes.Anonymous;
47 AuthenticationSchemes proxy_auth_scheme =
48 AuthenticationSchemes.Anonymous;
49 HostNameComparisonMode host_cmp_mode;
51 string realm = String.Empty;
52 TransferMode transfer_mode;
53 IDefaultCommunicationTimeouts timeouts;
54 // If you add fields, do not forget them in copy constructor.
56 public HttpTransportBindingElement ()
60 protected HttpTransportBindingElement (
61 HttpTransportBindingElement other)
64 allow_cookies = other.allow_cookies;
65 bypass_proxy_on_local = other.bypass_proxy_on_local;
66 unsafe_ntlm_auth = other.unsafe_ntlm_auth;
67 use_default_proxy = other.use_default_proxy;
68 keep_alive_enabled = other.keep_alive_enabled;
69 max_buffer_size = other.max_buffer_size;
70 auth_scheme = other.auth_scheme;
71 proxy_auth_scheme = other.proxy_auth_scheme;
72 host_cmp_mode = other.host_cmp_mode;
73 proxy_address = other.proxy_address;
75 transfer_mode = other.transfer_mode;
76 // FIXME: it does not look safe
77 timeouts = other.timeouts;
80 public bool AllowCookies {
81 get { return allow_cookies; }
82 set { allow_cookies = value; }
85 public AuthenticationSchemes AuthenticationScheme {
86 get { return auth_scheme; }
87 set { auth_scheme = value; }
90 public bool BypassProxyOnLocal {
91 get { return bypass_proxy_on_local; }
92 set { bypass_proxy_on_local = value; }
95 public HostNameComparisonMode HostNameComparisonMode {
96 get { return host_cmp_mode; }
97 set { host_cmp_mode = value; }
100 public bool KeepAliveEnabled {
101 get { return keep_alive_enabled; }
102 set { keep_alive_enabled = value; }
105 public int MaxBufferSize {
106 get { return max_buffer_size; }
107 set { max_buffer_size = value; }
110 public Uri ProxyAddress {
111 get { return proxy_address; }
112 set { proxy_address = value; }
115 public AuthenticationSchemes ProxyAuthenticationScheme {
116 get { return proxy_auth_scheme; }
117 set { proxy_auth_scheme = value; }
120 public string Realm {
121 get { return realm; }
122 set { realm = value; }
125 public override string Scheme {
126 get { return Uri.UriSchemeHttp; }
129 public TransferMode TransferMode {
130 get { return transfer_mode; }
131 set { transfer_mode = value; }
134 public bool UnsafeConnectionNtlmAuthentication {
135 get { return unsafe_ntlm_auth; }
136 set { unsafe_ntlm_auth = value; }
139 public bool UseDefaultWebProxy {
140 get { return use_default_proxy; }
141 set { use_default_proxy = value; }
144 public override bool CanBuildChannelFactory<TChannel> (
145 BindingContext context)
147 return typeof (TChannel) == typeof (IRequestChannel);
151 public override bool CanBuildChannelListener<TChannel> (
152 BindingContext context)
154 return typeof (TChannel) == typeof (IReplyChannel);
158 public override IChannelFactory<TChannel> BuildChannelFactory<TChannel> (
159 BindingContext context)
161 // remaining contexts are ignored ... e.g. such binding
162 // element that always causes an error is ignored.
163 return new HttpChannelFactory<TChannel> (this, context);
167 public override IChannelListener<TChannel> BuildChannelListener<TChannel> (
168 BindingContext context)
170 // remaining contexts are ignored ... e.g. such binding
171 // element that always causes an error is ignored.
172 if (ServiceHostingEnvironment.InAspNet)
173 return new AspNetChannelListener<TChannel> (this, context);
175 return new HttpSimpleChannelListener<TChannel> (this, context);
179 public override BindingElement Clone ()
181 return new HttpTransportBindingElement (this);
185 public override T GetProperty<T> (BindingContext context)
187 return base.GetProperty<T> (context);
192 void IPolicyExportExtension.ExportPolicy (
193 MetadataExporter exporter,
194 PolicyConversionContext context)
196 throw new NotImplementedException ();
200 void IWsdlExportExtension.ExportContract (WsdlExporter exporter,
201 WsdlContractConversionContext context)
203 throw new NotImplementedException ();
207 void IWsdlExportExtension.ExportEndpoint (WsdlExporter exporter,
208 WsdlEndpointConversionContext context)
210 throw new NotImplementedException ();