There is a iwebbrowser2::navigate2/navigate approach to Microsoft

Source: Internet
Author: User

My request was simple, just to add a cookie value to my browser request in my head,

But it's not going to work, but it's funny, yes, it's possible for me to add something else in my head, such as:

User-agent:netme

When the request was added, but if it is: COOKIE:AA=BB, you can not add, find a lot of places, want to find the answer,

Finally, someone in the Google Forum did an "explanation":

It asked Microsoft's people, with the control can not add 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 are incorrect,
But I 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 would be appreciated.

Hi,

Paul Bradford

The 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

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 into BeforeNavigate2 and look at Headers. It contains
Some of the characters from the ' headers ' parameter in I call to
Iwebbrowser::navigate, but it ' s all garbled. There is something
About my ' headers ' parameter to Navigate this 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 the more about this. Their answer:what I want to does 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 am am unlikely to change anything:)

We solved my problem in a completely different way.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.