Exemple #1
0
 protected void InitSetting(HttpSettings settings)
 {
     this.mBuilder = new ComParamBuilder();
     this.mBuilder.BaseCharset = settings.CharsetString;
     this.mSettings = settings;
     this.mTimer = new System.Timers.Timer();
     this.mTimer.Elapsed += new ElapsedEventHandler(this.TimeoutCallback);
     this.mTimer.Interval = this.mSettings.SendTimeout * 0x3e8;
     this.mTimer.AutoReset = false;
     this.Status = HttpStatus.Idle;
     this.TraceSet();
     if (this.mSettings.UseHttps)
     {
         this.mTracekind = NetTrace.Tracekind.HTTPS;
     }
 }
Exemple #2
0
 public HttpClient()
 {
     this.mBuilder = new ComParamBuilder();
     this.mBuilder.BaseCharset = "UTF-8";
     this.mTrace = new NetTrace();
 }
Exemple #3
0
        private void GetResponseCallback(IAsyncResult asynchronousResult)
        {
            //chống lỗi ssl
            System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

            HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;

            // End the operation
            HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
            Stream streamResponse = response.GetResponseStream();

            StreamReader streamRead = new StreamReader(streamResponse);

            ComParamBuilder mBuilder = new ComParamBuilder();
            mBuilder.BaseCharset = "UTF-8";

            MemoryStream sMIMEmessage = mBuilder.ReadToMemory(streamResponse);
            returnParameter = mBuilder.ToTextComParameter(sMIMEmessage, "UTF-8");

            string responseString = streamRead.ReadToEnd();
            Console.WriteLine(responseString);
            //lblMSG.Text = responseString;
            //Literal1.Text = responseString;

            // Close the stream object
            streamResponse.Close();
            streamRead.Close();

            // Release the HttpWebResponse
            response.Close();
            allDone.Set();
        }