예제 #1
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();
 }
예제 #2
0
 public static bool IsAvailable()
 {
     try
     {
         ScriptXmlHttpRequest request = new ScriptXmlHttpRequest();
         return (null != request);
     }
     catch (WebException)
     {
         return false;
     }
 }
예제 #3
0
 private void InvokeRequest()
 {
     if (this.aborted)
     {
         throw CreateAbortException();
     }
     if (this.invoked)
     {
         throw new InvalidOperationException("HttpWebRequest.InvokeRequest");
     }
     this.invoked = true;
     this.underlyingRequest = new ScriptXmlHttpRequest();
     this.underlyingRequest.Open(this.uri.AbsoluteUri, this.Method, new System.Action(ReadyStateChanged));
     if ((this.headers != null) && (this.headers.Count != 0))
     {
         foreach (string str in this.headers.AllKeys)
         {
             string str2 = this.headers[str];
             this.underlyingRequest.SetRequestHeader(str, str2);
         }
     }
     string content = null;
     if (this.contentStream != null)
     {
         byte[] bytes = this.contentStream.GetBuffer();
         if (bytes != null)
         {
             int position = (int)this.contentStream.Position;
             content = Encoding.UTF8.GetString(bytes, 0, position);
             this.underlyingRequest.SetRequestHeader("content-length", position.ToString(CultureInfo.InvariantCulture));
         }
     }
     this.underlyingRequest.Send(content);
 }