zoukankan      html  css  js  c++  java
  • httpwebresponse 异步: request.BeginGetRequestStream 报错! 无法发送具有此谓词类型的内容正文。

    request.BeginGetRequestStream 报错! 无法发送具有此谓词类型的内容正文。


    注意此方法:

     //////request.Method = "GET";   //若不为异步,则调用此方法。


     request.Method = "POST";  //若为异步,则调用此方法。


     
    try
                {
                    request = WebRequest.Create(string.Format(getUri, webURI, betInfor.Row.PlayID, uID, pType, gNum)) as HttpWebRequest;

                    //////request.Method = "GET";   //若不为异步,则调用此方法。


                    request.Method = "POST";  //若为异步,则调用此方法。
                    request.KeepAlive = true;
                    request.Timeout = 400;
                    if (betInfor.PlayMode == PlayMode.走)
                        request.Referer = string.Format("{0}app/member/BK_browse/body_browse.php?uid={1}&rtype=re&langx=zh-cn&mtype=3&delay=", webURI, uID);
                    else if (betInfor.PlayMode == PlayMode.单)
                        request.Referer = string.Format("{0}app/member/BK_browse/body_browse.php?uid={1}&rtype=r&langx=zh-cn&mtype=3&delay=", webURI, uID);
                    request.UserAgent = "MSIE 6.0";

                    //******************************************异步调用
                    request.BeginGetRequestStream(new AsyncCallback(RequestCallBack), request);
                    allDone.WaitOne();


                    response = (HttpWebResponse)request.GetResponse();
                    stream = response.GetResponseStream();
                    Thread.Sleep(1);
                    StreamReader streamRead = new StreamReader(stream, big5);
                    result = streamRead.ReadToEnd();
                    stream.Close();
                    streamRead.Close();               
                    //**********************************************************
                    //////response = request.GetResponse() as HttpWebResponse;
                    //////stream = response.GetResponseStream();
                    //////StreamReader sr = null;
                    //////sr = new StreamReader(stream, big5);
                    //////while ((count = sr.Read(leftBuffer, 0, leftBuffer.Length)) > 0)
                    //////{
                    //////    String str = new String(leftBuffer, 0, count);
                    //////    leftSb.Append(str);
                    //////}
                    //////sr.Close();

                    #region 提取数据
                    //////result = leftSb.ToString();
                    if (result.IndexOf("中") != -1 || betInfor.PlayMode == PlayMode.单)
                    {
                        
                    }
                    #endregion
                }
                catch (Exception e) { throw new Exception("获取左边出现异常" + result + e.Message + "," + e.TargetSite + "," + e.InnerException); }
                finally
                {
                    if (response != null) response.Close();
                    if (request != null) request.Abort();
                   
                    leftSb.Remove(0, leftSb.Length);
                }
                if (!string.IsNullOrEmpty(gmin_single) && ((int)((betInfor.Odds + 0.0001) * 1000)) % 10 == 0)//小数第3位有数字为会取消的单
                {
                  
                }
                else betInfor.Odds = 0;
                time2 = Environment.TickCount;
                betInfor.GetTime = time2 - time1;
                return result;

  • 相关阅读:
    慎重使用MySQL auto_increment
    Java Tread多线程(0)一个简单的多线程实例
    Nubia Z5S 官方4.4 201内測版 内核版本号信息
    “cvSnakeImage”: 找不到标识符
    raid5什么意思?怎样做raid5?raid5 几块硬盘?
    Quartz CronTrigger运用
    php zip文件内容比較类
    UVA 1069
    Eclipse启动Tomcat时,45秒超时解决方案
    簡單SQL存儲過程實例
  • 原文地址:https://www.cnblogs.com/Fooo/p/1328630.html
Copyright © 2011-2022 走看看