Exemple #1
0
 // Token: 0x06000084 RID: 132 RVA: 0x000036A4 File Offset: 0x000018A4
 private void GetResponseCallback(IAsyncResult ar)
 {
     HttpClient.RequestState reqs = (HttpClient.RequestState)ar.AsyncState;
     this.SafeDo(reqs, delegate
     {
         Action <AsyncResult <string> > callback = reqs.Callback;
         ApiRequest request = ((HttpClient.RequestState)ar.AsyncState).Request;
         using (HttpWebResponse httpWebResponse = (HttpWebResponse)request.HttpRequest.EndGetResponse(ar))
         {
             if (httpWebResponse.StatusCode == HttpStatusCode.OK)
             {
                 using (Stream responseStream = httpWebResponse.GetResponseStream())
                 {
                     using (StreamReader streamReader = new StreamReader(responseStream, reqs.Request.Encoder))
                     {
                         string responseText = streamReader.ReadToEnd();
                         string result       = HttpClient.ValidateResult(responseText);
                         callback(AsyncResult <string> .CreateSuccess(result));
                     }
                     goto IL_BE;
                 }
             }
             ServiceException ex = new ServiceException((int)httpWebResponse.StatusCode, httpWebResponse.StatusDescription);
             callback(AsyncResult <string> .CreateUnsuccess(ex));
             IL_BE:;
         }
     });
 }
Exemple #2
0
 // Token: 0x06000082 RID: 130 RVA: 0x00003478 File Offset: 0x00001678
 public void SendAysnc(ApiRequest request, Action <AsyncResult <string> > callback, Action aftersent = null)
 {
     lock (this)
     {
         HttpClient.RequestState state       = new HttpClient.RequestState(request, callback, aftersent);
         HttpWebRequest          httpRequest = request.HttpRequest;
         httpRequest.BeginGetRequestStream(new AsyncCallback(this.BeginGetRequestCallback), state);
     }
 }
Exemple #3
0
 // Token: 0x06000083 RID: 131 RVA: 0x0000354C File Offset: 0x0000174C
 private void BeginGetRequestCallback(IAsyncResult ar)
 {
     HttpClient.RequestState reqs = (HttpClient.RequestState)ar.AsyncState;
     this.SafeDo(reqs, delegate
     {
         reqs.EndSendRequest(ar);
         if (reqs.SentCallback != null)
         {
             reqs.SentCallback();
         }
         reqs.Request.HttpRequest.BeginGetResponse(new AsyncCallback(this.GetResponseCallback), ar.AsyncState);
     });
 }
Exemple #4
0
 // Token: 0x06000086 RID: 134 RVA: 0x0000374C File Offset: 0x0000194C
 private void SafeDo(HttpClient.RequestState reqs, Action action)
 {
     try
     {
         action();
     }
     catch (ServiceException ex)
     {
         reqs.Callback(AsyncResult <string> .CreateUnsuccess(ex));
     }
     catch (Exception ex2)
     {
         reqs.Callback(AsyncResult <string> .CreateUnsuccess(new ServiceException(ex2)));
     }
 }