Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
date: Tue, 09 Oct 2007 09:20:18 -0700,    group: microsoft.public.inetsdk.programming.urlmonikers        back       


IInternetProtocol and empty cookies, again   
Hi all.

I read a lot of messages about cookies and Asynchronous Pluggable
Protocol but it still doesnt work.
When i wrote "myprotocol://D:/Test/WriteCookies.html" - it's doesn't
see cookies. Maybe i something forgot?

I wrote in the method IInternetProtocol:Start
{
        HRESULT hr = S_OK;
	ATLTRACE(_T("CDataPluggableProtocol::Start ()\n"));

	if (grfSTI & PI_PARSE_URL)
		return S_FALSE;

	// Verify arguments
	if ((szUrl == NULL) || (pIProtSink == NULL))
		return E_INVALIDARG;

	DWORD bflags;
	BINDINFO bi;
	bi.cbSize = sizeof(BINDINFO);
	pIBindInfo->AddRef();


	hr = pIBindInfo->GetBindInfo(&bflags, &bi);

	if (!SUCCEEDED(hr))
		return S_FALSE;

	if (bi.dwBindVerb == BINDVERB_POST)
	{
		...
	}

	DWORD dwSize;
	LPOLESTR cookiesData = NULL;
	hr = pIBindInfo->GetBindString(BINDSTRING_POST_COOKIE, &cookiesData,
1, &dwSize);
		//dwSize - it's always 0
		//cookiesData - it's always NULL



	m_spSink = pIProtSink;


	//get connection to database
	if (FAILED(LoadDataToIStream(szUrl)))
		return S_FALSE;

	// Report download progress

	m_spSink->ReportProgress(BINDSTATUS_FINDINGRESOURCE, szUrl);
	m_spSink->ReportProgress(BINDSTATUS_SENDINGREQUEST, szUrl);
	m_spSink->ReportProgress(BINDSTATUS_CACHEFILENAMEAVAILABLE, szUrl);
	m_spSink->ReportProgress(BINDSTATUS_MIMETYPEAVAILABLE, szUrl);


	m_spSink->ReportData(BSCF_FIRSTDATANOTIFICATION, 0, m_lSize);

	pIBindInfo->Release();
	return hr;
}

and method for read file:

HRESULT CDataPluggableProtocol::LoadDataToIStream(LPCWSTR wstrUrl)
{
	CString strUrl = wstrUrl;
	CString strFileName;

	// parse URL
	int pos = strUrl.Find(_T("//"), 0);
	strFileName = strUrl.Right(strUrl.GetLength() - (pos + 2));

	// open file
	HANDLE hFile = CreateFile(strFileName, GENERIC_READ, 0, NULL,
OPEN_EXISTING, 0, NULL);
	if (INVALID_HANDLE_VALUE == hFile)
	{
		return S_FALSE;
	}

	// get file size
	DWORD dwFileSize = GetFileSize(hFile, NULL);
	_ASSERTE(-1 != dwFileSize);

	LPVOID pvData = NULL;
	// alloc memory based on file size
	HGLOBAL hGlobal = GlobalAlloc(GMEM_MOVEABLE, dwFileSize);
	_ASSERTE(NULL != hGlobal);

	pvData = GlobalLock(hGlobal);
	_ASSERTE(NULL != pvData);

	DWORD dwBytesRead = 0;
	// read file and store in global memory
	BOOL bRead = ReadFile(hFile, pvData, dwFileSize, &dwBytesRead, NULL);
	_ASSERTE(FALSE != bRead);
	GlobalUnlock(hGlobal);
	CloseHandle(hFile);

	// create IStream* from global memory
	m_pIStream.Release();
	HRESULT hr = CreateStreamOnHGlobal(hGlobal, TRUE, &m_pIStream);
	_ASSERTE(SUCCEEDED(hr) && m_pIStream);
	if(FAILED(hr))
		return hr;

	ULARGE_INTEGER nLen;
	LARGE_INTEGER nLen1;
	nLen1.QuadPart = 0;
	if(FAILED(m_pIStream->Seek(nLen1, STREAM_SEEK_END, &nLen)))
		return E_FAIL;
	m_lSize = nLen.LowPart;
	m_lPosition = 0;
	return S_OK;
}

Any ideas?

Best regards, Elena
date: Tue, 09 Oct 2007 09:20:18 -0700   author:   unknown

Re: IInternetProtocol and empty cookies, again   
pprivet@tut.by wrote:
> I read a lot of messages about cookies and Asynchronous Pluggable
> Protocol but it still doesnt work.
> When i wrote "myprotocol://D:/Test/WriteCookies.html" - it's doesn't
> see cookies. Maybe i something forgot?

I'm not sure how you expect to "see" cookies in an APP. Cookies are 
handled by WinInet below the APP level, and are only supported for HTTP 
and HTTPS protocols.

> DWORD dwSize;
> LPOLESTR cookiesData = NULL;
> hr = pIBindInfo->GetBindString(BINDSTRING_POST_COOKIE, &cookiesData,
> 1, &dwSize);
> //dwSize - it's always 0
> //cookiesData - it's always NULL

BINDSTRING_POST_COOKIE has nothing whatsoever to do with HTTP cookies. 
When posting a form, browser prepares a hash of all form
fields and reports it in this string. The built-in HTTP APP uses it in 
InternetSetOption(INTERNET_OPTION_SECONDARY_CACHE_KEY): this way, 
multiple responses to the same form (with different fields) may be 
stored in the cache even though they all have the same URL.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Tue, 9 Oct 2007 13:01:33 -0400   author:   Igor Tandetnik

Re: IInternetProtocol and empty cookies, again   
On 9    , 20:01, "Igor Tandetnik"  wrote:
>
>
> BINDSTRING_POST_COOKIE has nothing whatsoever to do with HTTP cookies.
> When posting a form, browser prepares a hash of all form
> fields and reports it in this string. The built-in HTTP APP uses it in
> InternetSetOption(INTERNET_OPTION_SECONDARY_CACHE_KEY): this way,
> multiple responses to the same form (with different fields) may be
> stored in the cache even though they all have the same URL.
>


But how to know that  page ("myprotocol://D:/Test/WriteCookies.html" )
try to write or read cookies?

Best regards, Elena
date: Wed, 10 Oct 2007 07:52:39 -0700   author:   Elena

Re: IInternetProtocol and empty cookies, again   
Elena  wrote:
> On 9    , 20:01, "Igor Tandetnik"  wrote:
>>
>>
>> BINDSTRING_POST_COOKIE has nothing whatsoever to do with HTTP
>> cookies. When posting a form, browser prepares a hash of all form
>> fields and reports it in this string. The built-in HTTP APP uses it
>> in InternetSetOption(INTERNET_OPTION_SECONDARY_CACHE_KEY): this way,
>> multiple responses to the same form (with different fields) may be
>> stored in the cache even though they all have the same URL.
>>
>
>
> But how to know that  page ("myprotocol://D:/Test/WriteCookies.html" )
> try to write or read cookies?

I'm not sure what you mean by "page tries to read cookies". Cookies are 
unrelated and independent of the page content, but are artifacts of HTTP 
protocol, sent back and forth in HTTP headers. Your page is not 
retrieved by HTTP, so there are no cookies.

If you mean the script on the page might try to work with the cookies 
programmatically, via document.cookie, then I'm afraid you are sadly out 
of luck. I don't know of any way to make document.cookie work for a page 
retrieved from a URL not starting with http:// or https://
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Wed, 10 Oct 2007 11:45:13 -0400   author:   Igor Tandetnik

Re: IInternetProtocol and empty cookies, again   
Thanks for your help.


Best regards,
Elena
date: Thu, 11 Oct 2007 03:47:51 -0700   author:   Elena

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us