public static bool IsAvailable() { try { ScriptXmlHttpRequest request = new ScriptXmlHttpRequest(); return(null != request); } catch (WebException) { return(false); } }
public override void Abort() { this.aborted = true; if (this.underlyingRequest != null) { this.underlyingRequest.Abort(); this.underlyingRequest.Dispose(); this.underlyingRequest = null; } if (this.response != null) { ((XHRHttpWebResponse)this.response).InternalRequest = null; this.response = null; } this.Close(); }
private void InvokeRequest() { if (this.aborted) { throw CreateAbortException(); } if (this.invoked) { throw new InvalidOperationException( System.Data.Services.Client.Strings.HttpWeb_Internal("HttpWebRequest.InvokeRequest")); } this.invoked = true; this.underlyingRequest = new ScriptXmlHttpRequest(); this.underlyingRequest.Open(this.uri.AbsoluteUri, this.Method, (Action)this.ReadyStateChanged); if ((this.headers != null) && (this.headers.Count != 0)) { foreach (string header in this.headers.AllKeys) { string value = this.headers[header]; this.underlyingRequest.SetRequestHeader(header, value); } } string content = null; if (this.contentStream != null) { byte[] buf = this.contentStream.GetBuffer(); if (buf != null) { int bufferSize = checked ((int)this.contentStream.Position); content = Encoding.UTF8.GetString(buf, 0, bufferSize); this.underlyingRequest.SetRequestHeader("content-length", bufferSize.ToString(CultureInfo.InvariantCulture)); } } this.underlyingRequest.Send(content); }
private void InvokeRequest() { if (this.aborted) { throw CreateAbortException(); } if (this.invoked) { throw new InvalidOperationException( System.Data.Services.Client.Strings.HttpWeb_Internal("HttpWebRequest.InvokeRequest")); } this.invoked = true; this.underlyingRequest = new ScriptXmlHttpRequest(); this.underlyingRequest.Open(this.uri.AbsoluteUri, this.Method, (Action)this.ReadyStateChanged); if ((this.headers != null) && (this.headers.Count != 0)) { foreach (string header in this.headers.AllKeys) { string value = this.headers[header]; this.underlyingRequest.SetRequestHeader(header, value); } } string content = null; if (this.contentStream != null) { byte[] buf = this.contentStream.GetBuffer(); if (buf != null) { int bufferSize = checked((int)this.contentStream.Position); content = Encoding.UTF8.GetString(buf, 0, bufferSize); this.underlyingRequest.SetRequestHeader("content-length", bufferSize.ToString(CultureInfo.InvariantCulture)); } } this.underlyingRequest.Send(content); }
public override void Abort() { this.aborted = true; if (this.underlyingRequest != null) { this.underlyingRequest.Abort(); this.underlyingRequest.Dispose(); this.underlyingRequest = null; } if (this.response != null) { ((XHRHttpWebResponse)this.response).InternalRequest = null; this.response = null; } this.Close(); }
public static bool IsAvailable() { try { ScriptXmlHttpRequest request = new ScriptXmlHttpRequest(); return (null != request); } catch (WebException) { return false; } }