日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

有关于微软的IWebBrowser2::Navigate2/Navigate方法

發(fā)布時間:2025/3/19 编程问答 61 豆豆
生活随笔 收集整理的這篇文章主要介紹了 有关于微软的IWebBrowser2::Navigate2/Navigate方法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

我曾經(jīng)的要求很簡單,只是要在我內(nèi)置BROWSER發(fā)請求在在頭里加入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

"Paul Bradford" <paulbradf...@alum.mit.edu> wrote in message

news:9d9iud$sf9$1@bob.news.rcn.net...

- Hide quoted text -- Show quoted text -

- Hide quoted text -- Show quoted text -

- Hide quoted text -- Show quoted text -

- Hide quoted text -- Show quoted text -I set a breakpoint in BeforeNavigate2 and look at Headers. It contains
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.

總結

以上是生活随笔為你收集整理的有关于微软的IWebBrowser2::Navigate2/Navigate方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。