Hi,

On Friday 28 November 2008 18:24:38 Uwe Schindler wrote:
> Just one question here:
> When implementing this into NSAPI, I found the following problem:
> 
> NSAPI does not directly allows to remove all headers, you can only do this
> step by step. So there are three possibilities to ship around this problem:
> 
> a) when SAPI_HEADER_DELETE_ALL is given, in header_handler, do the following
> (using the sapi_header_struct given as last parameter):
> 
> zend_llist_apply(sapi_headers->headers, (llist_apply_func_t)
> php_nsapi_remove_header TSRMLS_CC);
> 
> with:
> static int php_nsapi_remove_header(sapi_header_struct *sapi_header
> TSRMLS_DC)
> {
>       char *header_name, *p;
>       nsapi_request_context *rc = (nsapi_request_context
> *)SG(server_context);
>       
>       header_name = nsapi_strdup(sapi_header->header);
>       if (p = strchr(header_name, ':')) *p = 0;
> 
>       ...
> 
>       param_free(pblock_remove(header_name, rc->rq->srvhdrs));
>       nsapi_free(header_name);
>       
>       return ZEND_HASH_APPLY_KEEP;
> }
> 
> This would remove all headers, set by PHP. Headers embedded by the server
> itself would not be deleted (e.g. "Server:"  etc.)
> 
> b) Use some "hack" to get rid of all headers from the server's hashtable
> (like apr_table_clear()). This would remove all headers and also some
> important headers set by the server itself (like Server:, Chunked response
> headers, etc). I am not sure if this would be good, in my opinion
> SAPI_HEADER_DELETE_ALL should only remove headers set by PHP itself! What
> does the other SAPI developers think, is it safe to remove apaches default
> headers????? I am not sure and tend to say: NO!
> 
> c) Completely ignore sapi_header_handler like in CGI and set the headers
> later in sapi_send_headers() using the given struct with zend_llist_apply().
> Then I do not have to take care of adding/removing headers, I set them to
> Sun Webserver shortly before starting the response. Why the difference
> between header_handler and send_headers? Is it ok to remove header_handler
> (like in CGI) and simply feed all headers in send_headers? This would make
> life for SAPI developers easier (also maybe in Apache). What is the idea to
> respond after each header change?

I believe that Apache does sets its headers just before sending them, so when 
PHP deletes all headers in Apache's hashtable this does not removes "Server", 
"Date", etc. If this is not the case for NSAPI, solution a) seems good, but 
also allows to remove "Date" by setting it before ;)

One reason for having header_handler() and send_headers() is for example that 
flush() does not sends headers explicitly, but lets the server send them based 
on what header_handler() has set.

Regards,

Arnaud


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to