5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2008 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.ServiceModel.Channels;
33 namespace System.ServiceModel
35 public class WebHttpBinding
39 : Binding, IBindingRuntimePreferences
42 public WebHttpBinding ()
43 : this (WebHttpSecurityMode.None)
47 public WebHttpBinding (WebHttpSecurityMode mode)
50 // MSDN says that this security mode can be set only
51 // at .ctor(), so there is no problem on depending on
53 t = mode == WebHttpSecurityMode.Transport ? new HttpsTransportBindingElement () : new HttpTransportBindingElement ();
54 t.ManualAddressing = true;
58 public WebHttpBinding (string configurationName)
60 throw new NotImplementedException ();
63 WebHttpSecurity security = new WebHttpSecurity ();
64 HttpTransportBindingElement t;
65 // This can be changed only using <synchronousReceive> configuration element.
66 bool receive_synchronously;
67 WebMessageEncodingBindingElement msgenc = new WebMessageEncodingBindingElement ();
69 public EnvelopeVersion EnvelopeVersion {
70 get { return EnvelopeVersion.None; }
74 public bool AllowCookies {
75 get { return t.AllowCookies; }
76 set { t.AllowCookies = value; }
79 public bool BypassProxyOnLocal {
80 get { return t.BypassProxyOnLocal; }
81 set { t.BypassProxyOnLocal = value; }
86 public bool CrossDomainScriptAccessEnabled { get; set; }
88 public WebContentTypeMapper ContentTypeMapper {
89 get { return msgenc.ContentTypeMapper; }
90 set { msgenc.ContentTypeMapper = value; }
94 public HostNameComparisonMode HostNameComparisonMode {
95 get { return t.HostNameComparisonMode; }
96 set { t.HostNameComparisonMode = value; }
99 public long MaxBufferPoolSize {
100 get { return t.MaxBufferPoolSize; }
101 set { t.MaxBufferPoolSize = value; }
104 public TransferMode TransferMode {
105 get { return t.TransferMode; }
106 set { t.TransferMode = value; }
109 public bool UseDefaultWebProxy {
110 get { return t.UseDefaultWebProxy; }
111 set { t.UseDefaultWebProxy = value; }
114 public Uri ProxyAddress {
115 get { return t.ProxyAddress; }
116 set { t.ProxyAddress = value; }
120 public int MaxBufferSize {
121 get { return t.MaxBufferSize; }
122 set { t.MaxBufferSize = value; }
125 public long MaxReceivedMessageSize {
126 get { return t.MaxReceivedMessageSize; }
127 set { t.MaxReceivedMessageSize = value; }
131 public XmlDictionaryReaderQuotas ReaderQuotas {
132 get { return msgenc.ReaderQuotas; }
133 set { msgenc.ReaderQuotas = value; }
137 public override string Scheme {
138 get { return Security.Mode != WebHttpSecurityMode.None ? Uri.UriSchemeHttps : Uri.UriSchemeHttp; }
141 public WebHttpSecurity Security {
142 get { return security; }
145 public Encoding WriteEncoding {
146 get { return msgenc.WriteEncoding; }
149 throw new ArgumentNullException ("value");
150 msgenc.WriteEncoding = value;
154 public override BindingElementCollection CreateBindingElements ()
156 return new BindingElementCollection (new BindingElement [] { msgenc, t.Clone () });
160 bool IBindingRuntimePreferences.ReceiveSynchronously {
161 get { return receive_synchronously; }