本帖最后由 peachp 于 2015-9-9 14:16 编辑
站长苏飞 发表于 2015-9-9 09:55
错误提示是什么,
HTTP/1.1 这个要设置版本的mw_shl_code=csharp,true] ProtocolVersion = System.Net. ...[/mw_shl_code]
系统返回:[JavaScript] 纯文本查看 复制代码 13:57:57 {"ok":6000,"msg":"permission denied"}
根据实验应该是centent-length和实际的数据长度对不上。
正常应该返回:
[JavaScript] 纯文本查看 复制代码 {"ok":-1,"msg":"illegal request"}
根据实际测试结果:
[C#] 纯文本查看 复制代码
string txtToPost = "code=" + c + "×tr=" + getTimeStamp().ToString() + "&sign=" + makeSign("code=" + c + "×tr=" + getTimeStamp() + "&", Sid);
HttpItem checkin_post = new HttpItem()
{
URL = "http://tao.117go.com/ajax/eventMemberScoreApi/doCheckIn",
Method = "POST",//URL 可选项 默认为Get
Postdata = txtToPost,
//Postdata = "code=-2×tr=1441731656124&sign=ac96a6bcf87496b73467f47243f7ce5a167e33d9",
Accept = "*/*",
ContentType = "application/x-www-form-urlencoded;charset=UTF-8",//返回类型 可选项有默认值
UserAgent = "Mozilla/5.0 (Linux; Android 4.4.2; HUAWEI MT7-TL00 Build/HuaweiMT7-TL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36 taoontheroad-a3.1.1",
Referer = "http://tao.117go.com/event/member-score?token=" + Token + "&v=ta3.1.1&vc=117&vd=511dc319e3863c64&isontheroadinstalled=0&lat=39.882198&lng=116.471846&curLat=39.882198&curLng=116.471846&curDest=15&vts=798ef8a01c9b43cff19e0b34069e05f2",
Host = "tao.117go.com",
Cookie = Cookies,
//ProtocolVersion = System.Net.HttpVersion.Version10
//AutoRedirectCookie = true,
//Allowautoredirect = true
//KeepAlive = false
};
以上代码中,Postdata 用string类型变量赋值就会出问题,如果用按常量赋值就没问题。
从抓包结果来看,POST请求被分成了2个TCP数据包来发送,如下图所示。
第一个TCP包:
[C#] 纯文本查看 复制代码 POST /ajax/eventMemberScoreApi/doCheckIn HTTP/1.1
Pragma: no-cache
Cache-Control: no-cache
Origin: [url=http://tao.117go.com]http://tao.117go.com[/url]
x-wap-profile: [url=http://wap1.huawei.com/uaprof/HUAWEI_MT7-TL00_UAProfile.xml]http://wap1.huawei.com/uaprof/HUAWEI_MT7-TL00_UAProfile.xml[/url]
Accept-Encoding: gzip,deflate
Accept-Language: zh-CN,en-US;q=0.8
X-Requested-With: XMLHttpRequest
Accept: */*
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
User-Agent: Mozilla/5.0 (Linux; Android 4.4.2; HUAWEI MT7-TL00 Build/HuaweiMT7-TL00) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36 taoontheroad-a3.1.1
Cookie: PHPSESSID=d6bc370c580481acd22014f56182721e;CNZZDATA1255628874=1243882827-1441460930-%7C1441460930;TZLSUID=6eddc69b284166648c1998ce4e06c78f;TZLSAPPVER=ta3.1.1;SERVERID=9d857f84e99e75ac6960a257bea59050|1441731642|1441731642
Referer: [url=http://tao.117go.com/event/member-score?token=b91149bdf2bbb976f36fb1f4cc7b9d32&v=ta3.1.1&vc=117&vd=511dc319e3863c64&isontheroadinstalled=0&lat=39.882198&lng=116.471846&curLat=39.882198&curLng=116.471846&curDest=15&vts=798ef8a01c9b43cff19e0b34069e05f2]http://tao.117go.com/event/membe ... 3cff19e0b34069e05f2[/url]
Host: tao.117go.com
Content-Length: 75
Expect: 100-continue
Connection: Close
第二个TCP包:
[C#] 纯文本查看 复制代码 code=-2×tr=1441731656124&sign=ac96a6bcf87496b73467f47243f7ce5a167e33d9
从现象看应该是服务器收到第一个包以后发现content和content-length不符,直接就返回出错信息了。
站长啊,这个咋解决?
|