有关于微软的IWebBrowser2::Navigate2/Navigate方法收藏
来源:互联网 发布:官方免费炒股软件下载 编辑:程序博客网 时间:2024/05/21 14:03
有关于微软的IWebBrowser2::Navigate2/Navigate方法收藏
新一篇: 说说BES | 旧一篇: 有关于JAVA与后端C应用UTF8字符的通信
我曾经的要求很简单,只是要在我内置BROWSER发请求在在头里加入COOKIE值,
但试来试去都不成,但有趣的是的,我在头里加入其它东西是可行的,如:
User-Agent: NetMe
请求时加上了,可如果是:Cookie:aa=bb,就加不上,找了好多地方,想找到答案,
最后在GOOGLE论坛里有人做了“解释”:
它问了微软的人,用该控件无法加COOKIE,FT!!!
http://groups.google.com/group/microsoft.public.windows.inetexplorer.ie5.programming.components.webbrowser_ctl/browse_thread/thread/72f156bc95dfbe34/f3078180122c5529%23f3078180122c5529?sa=X&oi=groupsr&start=2&num=3
code:
CString str="";
//this->m_editurl.GetWindowText(str);
//this->m_editurl.GetWindowText("http://localhost:8080/angel");
VARIANT varProject;
const char *pszMsg = "http://127.0.0.1:8080";
//const char *pszMsg1 = "User-Agent: NetAnts";
const char *pszMsg1 = "Cookie: JSESSIONID=0112BF7D0C9FD914716EE17AD2AD7913";
VARIANT p1;
VARIANT p2;
VARIANT p3;
VariantInit(&varProject);
VariantInit(&p1);
VariantInit(&p2);
VariantInit(&p3);
p2.vt = VT_BSTR;
p2.bstrVal = SysAllocString(A2BSTR(pszMsg));//_bstr_t("http://127.0.0.1:8080/angel");
CString *s = new CString(p2.bstrVal);
//AfxMessageBox((LPCTSTR)s);
varProject.vt = VT_BSTR;
p1.vt = VT_BSTR;
p1.bstrVal= SysAllocString(A2BSTR(pszMsg));
//CComBSTR bstrXml ;
//bstrXml.Attach(SysAllocStringLen(p,47));
//varProject.bstrVal = bstrXml;
varProject.bstrVal = SysAllocString(A2BSTR(pszMsg1));
this->m_ie.Navigate2(&p2,0,0,0,&varProject);
I'd like to add cookies when I call IWebBrowser2::Navigate.
For example:
SHDocVw::IWebBrowser2Ptr spBrowser;//already created
_variant_t vtEmpty;
_bstr_t bstrURL;// already set to valid URL;
_variant_t vCookie(_bstr_t("Cookie: foo = bar"));
spBrowser->Navigate
(
bstrURL,
&vtEmpty/*flags*/,
&vtEmpty/*frame*/,
&vtEmpty/*post data*/,
&vCookie/*headers*/
);
The cookie I set does not appear on the server. I assume that the
syntax I'm passing to the 'headers' argument of Navigate is incorrect,
but I see no documentation about exactly how to set 'headers'.
When I monitor the IE event BeforeNavigate2, it shows the 'header'
argument, which includes some garbled version of the characters I
put in vCookie.
Any help will be appreciated.
Thanks,
Paul Bradford
See RFC 2109. The óookie header is rather complex:
cookie = "Cookie:" cookie-version
1*((";" | ",") cookie-value)
cookie-value = NAME "=" VALUE [";" path] [";" domain]
cookie-version = "$Version" "=" value
NAME = attr
VALUE = value
path = "$Path" "=" value
domain = "$Domain" "=" value
For example:
Cookie: $Version="1"; Customer="WILE_E_COYOTE"; $Path="/acme"
$Version parameter is mandatory-- With best wishes, Igor Tandetnik
news:9d9iud$sf9$1@bob.news.rcn.net...
some of the characters from the 'headers' parameter in my call to
IWebBrowser::Navigate, but it's all garbled. There is something
about my 'headers' parameter to Navigate that is not correct, but
I don't know what.
What exactly should the 'headers' argument to IWebBrowser2::Navigate
look like?
In case anybody is interested, I went through Microsoft support
to find out more about this. Their answer: what I want to do is
not supported. The 'headers' argument to Navigate/Navigate2
CANNOT be used to set cookies. There is no way to set cookies
for an IWebBrowser2 object.
I consider this a bug, but what I think is unlikely to change anything :)
We solved my problem in a completely different way.
发表于 @ 2005年11月03日 15:57:00|评论(0)|编辑
新一篇: 说说BES | 旧一篇: 有关于JAVA与后端C应用UTF8字符的通信
- 有关于微软的IWebBrowser2::Navigate2/Navigate方法收藏
- 有关于微软的IWebBrowser2::Navigate2/Navigate方法
- 利用IWebBrowser2接口的Navigate2方法实现Http POST传输
- 利用IWebBrowser2接口的Navigate2方法实现Http POST传输
- 利用IWebBrowser2接口的Navigate2方法实现Http POST传输
- 通过IWebBrowser2的Navigate2来打开网页,怎样判断网页是否全部加载完毕
- 通过IWebBrowser2的Navigate2来打开网页,怎样判断网页是否全部加载完毕
- 【VBA研究】方法quit作用于IWebBrowser2失败怎么办
- 获取IWebBrowser2指针的方法(一)
- 获取IWebBrowser2指针的方法(二)
- 获取IWebBrowser2指针的方法(一)
- 获取IWebBrowser2指针的方法(二)
- 获取IWebBrowser2指针的方法(一)
- 获取IWebBrowser2指针的方法(二)
- 获取IWebBrowser2指针的方法(二)
- IWebBrowser2的Get及Post方法
- 获取IWebBrowser2指针的方法(一)
- 获取IWebBrowser2指针的方法(二)
- Weblogic一个晚上解决一个接口问题
- 关于 未能启用约束。一行或多行中包含违反非空、唯一或外键约束的值 的解决办法
- DetailsView应用之雕虫小技
- 最近竟然要整java了。。。j2ee
- Dan Kaminsky DNS Vulnerability
- 有关于微软的IWebBrowser2::Navigate2/Navigate方法收藏
- 写程序启动项时如何过卡巴与360安全卫士等软件的方法收藏
- windows2008下如何删除程序自身收藏
- one plus one is not always only equal two
- 个人感触--终于峰回路转。
- 余世维博士:赢在执行-执行没有借口
- DLL与LIB的区别和联系
- 项目管理者必须具有的观念
- 如何使用ADO.net