开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

楼主: 鱼刺
收起左侧

[讨论] 【调查帖】你对<鱼刺多线程模块>和多线程方面有疑问吗

    [复制链接]
回帖奖励 10 枚 精币 回复本帖可获得 1 枚 精币奖励! 每人限 1 次
结帖率:100% (5/5)
发表于 2017-9-23 12:42:28 | 显示全部楼层   山西省晋中市

回帖奖励 +1 枚 精币

有一种爱叫无私奉献!
回复 支持 反对

使用道具 举报

结帖率:100% (26/26)
发表于 2017-9-16 10:29:41 | 显示全部楼层   湖南省怀化市

回帖奖励 +1 枚 精币

有一种爱叫无私奉献!
回复 支持 反对

使用道具 举报

结帖率:80% (28/35)

签到天数: 3 天

发表于 2017-8-29 20:37:24 | 显示全部楼层   福建省宁德市

回帖奖励 +1 枚 精币

好多问题想问,好想看教程例子
回复 支持 反对

使用道具 举报

发表于 2017-8-27 22:20:42 | 显示全部楼层   广东省广州市
好多问题想问,好想看教程例子
回复 支持 反对

使用道具 举报

发表于 2017-8-27 22:20:22 | 显示全部楼层   广东省广州市

回帖奖励 +1 枚 精币

好多问题想问,好想看教程例子
回复 支持 反对

使用道具 举报

结帖率:78% (18/23)
发表于 2017-8-2 17:34:01 | 显示全部楼层   河南省商丘市

回帖奖励 +1 枚 精币

鱼刺例子有公布吗?
回复 支持 反对

使用道具 举报

结帖率:67% (2/3)

签到天数: 1 天

发表于 2017-8-1 20:32:28 | 显示全部楼层   河北省石家庄市

回帖奖励 +1 枚 精币

手里有C#的HttpWebRequest里面ssl提到了x509证书协yi用鱼刺应该怎么写呢?
  1. public class HttpService
  2.     {

  3.         public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  4.         {
  5.             //直接确认,否则打不开   
  6.             return true;
  7.         }

  8.         public static string Post(string xml, string url, bool isUseCert, int timeout)
  9.         {
  10.             System.GC.Collect();//垃圾回收,回收没有正常关闭的http连接

  11.             string result = "";//返回结果

  12.             HttpWebRequest request = null;
  13.             HttpWebResponse response = null;
  14.             Stream reqStream = null;

  15.             try
  16.             {
  17.                 //设置最大连接数
  18.                 ServicePointManager.DefaultConnectionLimit = 200;
  19.                 //设置https验证方式
  20.                 if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  21.                 {
  22.                     ServicePointManager.ServerCertificateValidationCallback =
  23.                             new RemoteCertificateValidationCallback(CheckValidationResult);
  24.                 }

  25.                 /***************************************************************
  26.                 * 下面设置HttpWebRequest的相关属性
  27.                 * ************************************************************/
  28.                 request = (HttpWebRequest)WebRequest.Create(url);

  29.                 request.Method = "POST";
  30.                 request.Timeout = timeout * 1000;

  31.                 //设置代理服务器
  32.                 //WebProxy proxy = new WebProxy();                          //定义一个网关对象
  33.                 //proxy.Address = new Uri(WxPayConfig.PROXY_URL);              //网关服务器端口:端口
  34.                 //request.Proxy = proxy;

  35.                 //设置POST的数据类型和长度
  36.                 request.ContentType = "text/xml";
  37.                
  38.                 byte[] data = System.Text.Encoding.UTF8.GetBytes(xml);
  39.                 request.ContentLength = data.Length;
  40.                 Console.WriteLine(request.Headers);
  41.                 //是否使用证书
  42.                 if (isUseCert)
  43.                 {
  44.                 //    string path = HttpContext.Current.Request.PhysicalApplicationPath;
  45.                 //    X509Certificate2 cert = new X509Certificate2(path + Config.SSLCERT_PATH, Config.SSLCERT_PASSWORD);
  46.                 //    request.ClientCertificates.Add(cert);
  47.                 ////    Log.Debug("WxPayApi", "PostXml used cert");
  48.                 }

  49.                 //往服务器写入数据
  50.                 reqStream = request.GetRequestStream();
  51.                 reqStream.Write(data, 0, data.Length);
  52.                 reqStream.Close();
  53.                
  54.                 //获取服务端返回
  55.                 response = (HttpWebResponse)request.GetResponse();

  56.                 //获取服务端返回数据
  57.                 StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  58.                
  59.                 result = sr.ReadToEnd().Trim();
  60.                 sr.Close();
  61.             }
  62.             //catch (System.Threading.ThreadAbortException e)
  63.             //{
  64.             //   // Log.Error("HttpService", "Thread - caught ThreadAbortException - resetting.");
  65.             //   // Log.Error("Exception message: {0}", e.Message);
  66.             //    System.Threading.Thread.ResetAbort();
  67.             //}
  68.             //catch (WebException e)
  69.             //{
  70.             // //   Log.Error("HttpService", e.ToString());
  71.             //    if (e.Status == WebExceptionStatus.ProtocolError)
  72.             //    {
  73.             //    //    Log.Error("HttpService", "StatusCode : " + ((HttpWebResponse)e.Response).StatusCode);
  74.             //     //   Log.Error("HttpService", "StatusDescription : " + ((HttpWebResponse)e.Response).StatusDescription);
  75.             //    }
  76.             //    throw new WxPayException(e.ToString());
  77.             //}
  78.             //catch (Exception e)
  79.             //{
  80.             //   // Log.Error("HttpService", e.ToString());
  81.             //    throw new WxPayException(e.ToString());
  82.             //}
  83.             finally
  84.             {
  85.                 //关闭连接和流
  86.                 if (response != null)
  87.                 {
  88.                     response.Close();
  89.                 }
  90.                 if (request != null)
  91.                 {
  92.                     request.Abort();
  93.                 }
  94.             }
  95.             return result;
  96.         }

  97.         /// <summary>
  98.         /// 处理http GET请求,返回数据
  99.         /// </summary>
  100.         /// <param name="url">请求的url地址</param>
  101.         /// <returns>http GET成功后返回的数据,失败抛WebException异常</returns>
  102.         public static string Get(string url)
  103.         {
  104.             System.GC.Collect();
  105.             string result = "";

  106.             HttpWebRequest request = null;
  107.             HttpWebResponse response = null;

  108.             //请求url以获取数据
  109.             try
  110.             {
  111.                 //设置最大连接数
  112.                 ServicePointManager.DefaultConnectionLimit = 200;
  113.                 //设置https验证方式
  114.                 if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  115.                 {
  116.                     ServicePointManager.ServerCertificateValidationCallback =
  117.                             new RemoteCertificateValidationCallback(CheckValidationResult);
  118.                 }

  119.                 /***************************************************************
  120.                 * 下面设置HttpWebRequest的相关属性
  121.                 * ************************************************************/
  122.                 request = (HttpWebRequest)WebRequest.Create(url);

  123.                 request.Method = "GET";

  124.                 //设置代理
  125.                 //WebProxy proxy = new WebProxy();
  126.                 //proxy.Address = new Uri(WxPayConfig.PROXY_URL);
  127.                 //request.Proxy = proxy;

  128.                 //获取服务器返回
  129.                 response = (HttpWebResponse)request.GetResponse();

  130.                 //获取HTTP返回数据
  131.                 StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  132.                 result = sr.ReadToEnd().Trim();
  133.                 sr.Close();
  134.             }
  135.             //catch (System.Threading.ThreadAbortException e)
  136.             //{
  137.             //  //  Log.Error("HttpService", "Thread - caught ThreadAbortException - resetting.");
  138.             //   // Log.Error("Exception message: {0}", e.Message);
  139.             //    System.Threading.Thread.ResetAbort();
  140.             //}
  141.             //catch (WebException e)
  142.             //{
  143.             // //   Log.Error("HttpService", e.ToString());
  144.             //    if (e.Status == WebExceptionStatus.ProtocolError)
  145.             //    {
  146.             //     //   Log.Error("HttpService", "StatusCode : " + ((HttpWebResponse)e.Response).StatusCode);
  147.             //     //   Log.Error("HttpService", "StatusDescription : " + ((HttpWebResponse)e.Response).StatusDescription);
  148.             //    }
  149.             //    throw new Exception(e.ToString());
  150.             //}
  151.             //catch (Exception e)
  152.             //{
  153.             // //   Log.Error("HttpService", e.ToString());
  154.             //    throw new Exception(e.ToString());
  155.             //}
  156.             finally
  157.             {
  158.                 //关闭连接和流
  159.                 if (response != null)
  160.                 {
  161.                     response.Close();
  162.                 }
  163.                 if (request != null)
  164.                 {
  165.                     request.Abort();
  166.                 }
  167.             }
  168.             return result;
  169.         }
  170.     }
复制代码
回复 支持 反对

使用道具 举报

结帖率:100% (2/2)
发表于 2017-6-16 18:45:03 | 显示全部楼层   **

回帖奖励 +1 枚 精币

期待教程,看到原子锁什么晕了
回复 支持 反对

使用道具 举报

结帖率:36% (10/28)

签到天数: 6 天

发表于 2017-6-13 19:13:27 | 显示全部楼层   四川省内江市

回帖奖励 +1 枚 精币

什么时候出教程啊!!
回复 支持 反对

使用道具 举报

发表于 2017-6-13 13:27:01 | 显示全部楼层   浙江省宁波市

回帖奖励 +1 枚 精币

期待教程!!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表