分享
 
 
 

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

王朝other·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

我曾经的要求很简单,只是要在我内置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

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

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

- 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.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有