httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Swapan Gupta" <swapan_gu...@infosys.com>
Subject RE: Problem with getting custom HTTP header in IHS 2.42.x
Date Mon, 13 Oct 2003 12:02:14 GMT

Please find the information inline.

-----Original Message-----
From: Jeff Trawick [mailto:trawick@attglobal.net] 
Sent: Monday, October 13, 2003 4:29 PM
To: Swapan Gupta
Cc: dev@httpd.apache.org
Subject: Re: Problem with getting custom HTTP header in IHS 2.42.x

Swapan Gupta wrote:

> 
>>I am facing a problem there. When I try to get the HTTP headers, on 
>>Apache2x I am getting both the Default (such as HTTP_COOKIE, 
>>HTTP_CONNECTION) and Custom HTTP headers such as HTTP_FOO. But when I 
>>test the same code on IHS, I see that I am able to only get the default 
>>HTTP headers and not my Custom HTTP headers.
> 
> 
> Where do these custom headers come from?  From the original request or 
> from the response?
> 
> [Swapan] The custom HTTP headers are generated as part of the response. 
>However I could not get the headers out of either headers_in or headers_out.

What is the name of the header field?

[Swapan] The name of the HTTP header is HTTP_FOO. I am trying to extract it using the string
"FOO"

What generates this header field?  A CGI or a module?

[Swapan] This header is generated by another module.

If a module:
   In which phase does the module set the header? 
[Swapan] Access Phase

   Which table does the module put the header? 
[Swapan] request_rec->headers_in



In which phase is your module looking for the header field?

[Swapan] In my module, I look for the header in the Access phase itself.

Which table does your module look in -- headers_out or err_headers_out?
[Swapan] My module also looks in request_rec->headers_in

What is the exact code your module uses to try to find this header field 
in the table?

[Swapan] Please find the relevant code snippet below:


**************************ApacheServer.cpp*******************
string CApacheServer::GetHeader( const char *Name ) const
{
       const char*   header = apr_table_get(m_pReqRec->headers_in, Name );
 
        if ( header == NULL )
          {
            Log( LOGLEVEL_DEBUG, "GetHeader> %s=\"\"", Name );
            return "";
          }

        Log( LOGLEVEL_DEBUG, "GetHeader> Returning %s=\"%s\"", Name, header );
        return header;
}

bool Process(CApacheServer Server)
{
	.
	.
	.
	string value = Server.GetHeader("FOO");		// PS - This does not return anything. The value
is NULL.
	.	// Other functionality
	.
	.	

}
********************************************


*************************mod_foo.cpp*************
int foo_header_processor( request_rec *pReq )
{

        config_struct *pConfig = (config_struct *) ap_get_module_config(pReq->per_dir_config,
&foo_module);


        CApacheServer Server( pReq );

        if ( !Process( Server ) )
          {
            Log(LOGLEVEL_INFO, "Returning DONE.");
            return DONE;
        }
        else
        {
            Log(LOGLEVEL_INFO, "Returning DECLINED.");
            return DECLINED;
        }

}


static void foo_register_hooks(apr_pool_t* p)
{
      ap_hook_post_config(Initializer,NULL,NULL,APR_HOOK_MIDDLE);
       	ap_hook_access_checker(foo_header_processor,NULL,NULL,APR_HOOK_MIDDLE);
}

module foo_module = {
        STANDARD20_MODULE_STUFF,                
        create_dir_config,              
        NULL,                           
        foo_create_server_config,  
        NULL,                           
        ApacheSessLink_Commands,        
        foo_register_hooks         
};


***********************************************

This code works fine when the GetHeader method is invoked passing something like "COOKIE"
or "CONNECTION" as a parameter (i.e., it returns the value of that header). However, when
this method is invoked using "FOO" or any other header that is set to by the other module,
as parameter, it does not get the Header value.

Please note that the code works in case ApacheServer 2.x setup, but does not in case of HIS
2.x setup.

Any pointers?????


Mime
View raw message