示例#1
0
 public static bool IsAvailable()
 {
     try
     {
         ScriptXmlHttpRequest request = new ScriptXmlHttpRequest();
         return(null != request);
     }
     catch (WebException)
     {
         return(false);
     }
 }
示例#2
0
        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();
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
       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();
        }
示例#6
0
 public static bool IsAvailable()
 {
     try
     {
         ScriptXmlHttpRequest request = new ScriptXmlHttpRequest();
         return (null != request);
     }
     catch (WebException)
     {
         return false;
     }
 }