{"id":1243,"date":"2010-08-10T13:42:00","date_gmt":"2010-08-10T05:42:00","guid":{"rendered":""},"modified":"2013-11-17T16:36:42","modified_gmt":"2013-11-17T08:36:42","slug":"idhttp%e4%bc%aa%e9%80%a0%e6%9d%a5%e6%ba%90%e5%9c%b0%e5%9d%80%e3%80%81cookie%e6%ac%ba%e9%aa%97%e3%80%81%e9%80%9a%e8%bf%87%e4%bb%a3%e7%90%86%e8%ae%bf%e9%97%ae","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/1243.html","title":{"rendered":"Idhttp\u4f2a\u9020\u6765\u6e90\u5730\u5740\u3001Cookie\u6b3a\u9a97\u3001\u901a\u8fc7\u4ee3\u7406\u8bbf\u95ee"},"content":{"rendered":"<p>1\u3001\u4f2a\u9020\u6765\u6e90\u5730\u5740\uff1a\u4f7f\u7528IdHttp\u53ef\u4ee5\u4f2a\u9020\u8fd9\u4e2a\u6765\u6e90\u5730\u5740\uff0c\u800c\u4e14\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u5728\u8bbf\u95ee\u67d0\u5730\u4e4b\u524d\u52a0\u4e0a\u4e00\u53e5\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nIdHttp1.Request.Referer := 'pics\/www.3464.com\/';\r\n<\/pre>\n<p>\u90a3\u4e48\u6765\u6e90\u5730\u5740\u5c31\u53d8\u6210\u4e86pics\/www.3464.com\/\u800c\u4e0d\u662f\u4f60\u5b9e\u9645\u7684\u6765\u6e90\u5730\u5740\u4e86\u3002<\/p>\n<p>2\u3001Cookie\u6b3a\u9a97\uff1a<br \/>\n\u5982\u4f55\u7528idhttp\u63d0\u4ea4\u81ea\u5df1\u6784\u9020\u8fc7\u7684Cookie<\/p>\n<p>\u6211\u4e0d\u77e5\u9053\u7684\u662f\uff1a\u5982\u679c\u628a\u81ea\u5df1\u6784\u9020\u8fc7\u7684Cookie\u4f20\u7ed9idhttp\u8ba9\u5b83\u63d0\u4ea4\u3002<\/p>\n<p>\u6bd4\u5982\u7ad9\u70b9pics\/www.aaa.com \u662f\u8981cookie\u7684\u3002\u6211\u5df2\u7ecf\u5728\u7a0b\u5e8f\u4e0a\u653e\u4e86idhttp\u548cIdCookieManager\u3002<br \/>\n\u6211getpics\/www.aaa.com \u540e\uff0cidhttp\u901a\u8fc7IdCookieManager\u5df2\u7ecf\u5f97\u5230\u5f53\u524d\u7ad9\u70b9\u7684Cookie\u4e86\u3002\u6211\u53ef\u4ee5\u7528<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nfor i := 0 to IdCookieManager1.CookieCollection.Count - 1 do\r\nmemo1.Lines.Add(IdCookieManager1.CookieCollection.Items&#x5B;i].CookieText);\r\n<\/pre>\n<p>\u5f97\u5230\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u5982\u679c\u6211\u60f3\u66f4\u6539\u8fd9\u4e2acookie\uff0c\u6216\u8005\u8bf4\u6211\u60f3\u6309\u8fd9\u4e2aCookie\u7684\u683c\u5f0f\u91cd\u65b0\u5199\u4e00\u4e2a\uff0c\u518d\u7528idhttp\u8fdb\u884cpost\u3002\u6211\u5e94\u8be5\u600e\u4e48\u505a\uff1f<br \/>\n\u7528\u9014\u662fCookie\u6b3a\u9a97\u7b49\u3002<br \/>\n\u5982\uff1a<br \/>\n\u5f97\u5230\u7684Cookie\u4e3a\uff1askin=2; ASPSESSIONIDSQTSABQD=IEMKPIDBKKMEEKEHLLOIJJON; UserCode=3CA001D63984E6115FE55681%2E95<br \/>\n\u6211\u66f4\u6539\u4e3a\uff1askin=123; ASPSESSIONIDSQTSABQD=IEMKPIDBKKMEEKEHLLOIJJON; UserCode=3CA001D63984E6115FE55681%2E95<br \/>\n\u6211\u518dpost<\/p>\n<p>\u5728Idhttp\u4e2d\uff0c\u8981\u60f3\u4fee\u6539Cookie\u7684\u4ee3\u7801\uff0c\u5c31\u8981\u7528\u5230Request\u7684RawHeaders\u4e2d\u7684Values\u503c\u3002<br \/>\n\u8fd9\u4e2a\u503c\u600e\u4e48\u7528\u5462\uff1f<br \/>\nValues\u63a5\u53d7\u4e00\u4e2astring\u7684\u503c\uff0c\u8be5\u503c\u6307\u5b9a\u4e86\u6240\u8bbf\u95ee\u7684\u53d8\u91cf\u3002<br \/>\n\u5982HTTP\u5934\u662f\u8fd9\u6837\u5b9a\u4e49\u7684(\u5176\u4e2d\u4e00\u4e9b)\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nAccept-Language: zh-cn\r\nContent-Type: application\/x-www-form-urlencoded\r\nAccept-Encoding: gzip, deflate\r\nUser-Agent: Mozilla\/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;\r\nCookie: JSESSIONID=aoOYvjM-IKzh\r\n<\/pre>\n<p>\u800cValues\u7684\u503c\u5c31\u53ef\u4ee5\u662fCookie\uff0cUser-Agent\uff0cAccept-Encoding\u2026\u2026\u7b49\u7b49\u3002<\/p>\n<p>RawHeaders\u5fc5\u987b\u521d\u59cb\u5316\u540e\u624d\u53ef\u7528\u3002<\/p>\n<p>\u6b63\u786e\u7684\u4ee3\u7801\u5e94\u8be5\u662f\u8fd9\u6837\uff1a<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\ntry\r\nidhttp1.Request.SetHeaders;\/\/\u6700\u91cd\u8981\u7684\u521d\u59cb\u5316\u3002idhttp1.Request.RawHeaders.Values&#x5B;'Cookie'] := '\u8fd9\u91cc\u662fcookie\u7684\u503c';\r\nidhttp1.Post('\/webmail\/login.jsp',data1,data2);\r\nexcept\r\nidhttp1.Get(idhttp1.Response.Location, data1);\r\nend;\r\n\r\nhttp.Request.SetHeaders;\/\/\u5fc5\u987b\u52a0\u4e0a\uff0c\u624d\u80fd\u5b8c\u6210\u4e0b\u9762\u7684\u5de5\u4f5c\r\n\/\/http.Request.RawHeaders.Values&#x5B;'Cookie']:=_SESSION;\/\/\u81ea\u5b9a\u4e49Cookie\r\n\/\/http.Request.CustomHeaders.Values&#x5B;'Cookie']:=Cookie; \/\/\u4e5f\u5f97\u52a0\u4e0a\uff0c\u4e0d\u7136Cookie\u6ca1\u6709\u610f\u4e49\uff0c\u7814\u7a76\u4e86\u5f88\u591a\r\nhttp.Http.Request.CustomHeaders.Text:='Cookie: '+Cookie;\/\/\u6700\u5f3a\u608d\u7684\u4e00\u4e2a\uff0c\u4e0a\u9762\u4e24\u79cd\u65b9\u5f0f\u6709\u65f6\u5019\u5c31\u662f\u4e0d\u884c\r\nhttp.HandleRedirects:= true;\r\nhttp.Request.UserAgent := 'OS\/1.0';\/\/\u81ea\u5b9a\u4e49\u5ba2\u6237\u7aef\u7684\u7b7e\u540d\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\r\nhttp.request.ContentType:='application\/x-www-form-urlencoded';\/\/\u4f7f\u7528POST\u65b9\u5f0f\u63d0\u4ea4\u65f6\u5019\uff0c\u5fc5\u987b\u52a0\u4e0a\r\nhttp.Request.Referer :='pics\/www.4936.cn\/index.php';\r\nhttp.Request.Host:=www.test.cn;\r\n<\/pre>\n<p>3\u3001\u4ee3\u7406\u670d\u52a1\u5668\uff1a<\/p>\n<p>\u4f7f\u7528idhttp\u63a7\u4ef6\uff0c\u8c03\u6574\u4ee3\u7406\u670d\u52a1\u5668\u53c2\u6570\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u901a\u8fc7\u4ee3\u7406\u670d\u52a1\u5668\u8bbf\u95ee\u3002<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nidhttp1.ProxyParams.ProxyServer :=proxyip.Text ;\/\/\u4ee3\u7406\u5730\u5740idhttp1.ProxyParams.ProxyPort :=StrToInt(port.text);\/\/\u7aef\u53e3\/\/\u5982\u679c\u4ee3\u7406\u9700\u8981\u9a8c\u8bc1idhttp1.ProxyParams.ProxyUsername:=uname.Text ;\/\/\u7528\u6237\u540didhttp1.ProxyParams.ProxyPassword:=pw.Text ;\/\/\u5bc6\u7801\r\n<\/pre>\n<p>\u5982\u679c\u662f\u5728\u5c40\u57df\u7f51\u5185\uff0c\u4ee3\u7406\u4e0d\u6210\u529f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4f2a\u9020\u6765\u6e90\u5730\u5740\uff1a\u4f7f\u7528IdHttp\u53ef\u4ee5\u4f2a\u9020\u8fd9\u4e2a\u6765\u6e90\u5730\u5740\uff0c\u800c\u4e14\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u5728\u8bbf\u95ee\u67d0\u5730\u4e4b\u524d\u52a0\u4e0a\u4e00\u53e5\uff1a IdHttp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1243","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=1243"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1243\/revisions"}],"predecessor-version":[{"id":4693,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1243\/revisions\/4693"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=1243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=1243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=1243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}