Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

Wwwxxx.APC, wwwxxx CN2, can't locate feature.pm in @inc (@inc contains, Wwwxxx ba2, wwwxxx Bhaskar, wwwxxx Bhaskar, XxxxDup, wwwxxix Buzz, wwwxxxdbgf, ncurses font size

Links

XODOX
Impressum

#1: GetHeader command for current domain?

Posted on 2007-01-10 11:02:55 by buzz

Hi all
am trying to write a redirection filter. in c++ with MFC

here is some code ...
DWORD CRedirectorFilter::OnPreprocHeaders(CHttpFilterContext* pCtxt,
PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo)
{
if (true == ReloadIniFileNeeded())
{
if (false == LoadMap())
{
return SF_STATUS_REQ_NEXT_NOTIFICATION;
}
}
char buffer[256];
DWORD buffSize = sizeof(buffer);
BOOL bHeader = pHeaderInfo->GetHeader(pCtxt->m_pFC, "url", buffer,
&buffSize);
CString urlString(buffer);
urlString.MakeLower(); // for this exercise
CString baseUrl = GetWebRoot(urlString);
igor_map::iterator iter = domain_map.find(baseUrl);
DWORD dwRet = SF_STATUS_REQ_NEXT_NOTIFICATION;


my hosts file is set to forward all requests for

www.somewhere.com to the ip of the PC...this happens correctly

however

the problem i am having from my XP box is that when thi line of code
runs

BOOL bHeader = pHeaderInfo->GetHeader(pCtxt->m_pFC, "url", buffer,
&buffSize);

the buffer does not contain "www.somewhere.com", it just holds "/"

how can i ask IIS to tell me which domain was requested?

regards and thanks

Buzz

Report this message

#2: Re: GetHeader command for current domain?

Posted on 2007-01-11 05:25:43 by David Wang

Are you sure that the client sent "www.somewhere.com" in the URL?

I believe the client sent www.somewhere.com as the Host header, hence
you have to call GetHeader("Host:") to retrieve it.


//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//


buzz wrote:
> Hi all
> am trying to write a redirection filter. in c++ with MFC
>
> here is some code ...
> DWORD CRedirectorFilter::OnPreprocHeaders(CHttpFilterContext* pCtxt,
> PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo)
> {
> if (true == ReloadIniFileNeeded())
> {
> if (false == LoadMap())
> {
> return SF_STATUS_REQ_NEXT_NOTIFICATION;
> }
> }
> char buffer[256];
> DWORD buffSize = sizeof(buffer);
> BOOL bHeader = pHeaderInfo->GetHeader(pCtxt->m_pFC, "url", buffer,
> &buffSize);
> CString urlString(buffer);
> urlString.MakeLower(); // for this exercise
> CString baseUrl = GetWebRoot(urlString);
> igor_map::iterator iter = domain_map.find(baseUrl);
> DWORD dwRet = SF_STATUS_REQ_NEXT_NOTIFICATION;
>
>
> my hosts file is set to forward all requests for
>
> www.somewhere.com to the ip of the PC...this happens correctly
>
> however
>
> the problem i am having from my XP box is that when thi line of code
> runs
>
> BOOL bHeader = pHeaderInfo->GetHeader(pCtxt->m_pFC, "url", buffer,
> &buffSize);
>
> the buffer does not contain "www.somewhere.com", it just holds "/"
>
> how can i ask IIS to tell me which domain was requested?
>
> regards and thanks
>
> Buzz

Report this message

#3: Re: GetHeader command for current domain?

Posted on 2007-01-14 03:49:42 by buzz

David Wang wrote:
> Are you sure that the client sent "www.somewhere.com" in the URL?
>
> I believe the client sent www.somewhere.com as the Host header, hence
> you have to call GetHeader("Host:") to retrieve it.
>
>

thanks David

I tried GetHeader("Host:") as you suggested, but i still get "/"

DWORD CRedirectorFilter::OnPreprocHeaders(CHttpFilterContext* pCtxt,
PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo)
{

char buffer[256];
DWORD buffSize = sizeof(buffer);
BOOL bHeader = pHeaderInfo->GetHeader(pCtxt->m_pFC, "Host:", buffer,
&buffSize);


The break point i have set gets hit and i can examine the variables and
so on.



am i missing something?


regards

Buzz

Report this message

#4: Re: GetHeader command for current domain?

Posted on 2007-01-15 01:27:36 by David Wang

The values you are looking can only be retrieved with the "Host:" and
"url" headers in OnPreprocHeaders. If you are not getting what you
expect, then you need to start looking at the raw bytes of the request
with tools like Network Sniffers.

Or you can use a tool like WFetch to simulate an expected request and
verify your code's behavioral correctness.

FYI: It is not possible to server-side redirect requests between IIS
websites from OnPreprocHeaders. Sending 30X client-side redirects, or
if the logical websites are all hosted within the same IIS website via
Host Headers, would work to "redirect", but I am not certain what
exactly you are trying to accomplish. Can you please describe exactly
what you want to achieve.


//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
//


buzz wrote:
> David Wang wrote:
> > Are you sure that the client sent "www.somewhere.com" in the URL?
> >
> > I believe the client sent www.somewhere.com as the Host header, hence
> > you have to call GetHeader("Host:") to retrieve it.
> >
> >
>
> thanks David
>
> I tried GetHeader("Host:") as you suggested, but i still get "/"
>
> DWORD CRedirectorFilter::OnPreprocHeaders(CHttpFilterContext* pCtxt,
> PHTTP_FILTER_PREPROC_HEADERS pHeaderInfo)
> {
>
> char buffer[256];
> DWORD buffSize = sizeof(buffer);
> BOOL bHeader = pHeaderInfo->GetHeader(pCtxt->m_pFC, "Host:", buffer,
> &buffSize);
>
>
> The break point i have set gets hit and i can examine the variables and
> so on.
>
>
>
> am i missing something?
>
>
> regards
>
> Buzz

Report this message

#5: Re: GetHeader command for current domain?

Posted on 2007-01-15 03:10:26 by buzz

thanks david, it turns out IIS was misbehaving so i uninstalled it,
deleted the remains, and reinstalled
and whatya know - the code worked :)

very happy

thanks for your help

Buzz

Report this message