I've commited the patch to CVS. Thanks for your help. Just a small note: strnicmp() is not available on unix, it's called strncasecmp(). PHP uses a macro to wrap strncasecmp() to strncasecmp() on Windows.
Sander On Mon, Jun 17, 2002 at 02:12:17PM -0700, Michael Sisolak wrote: > Bug #16458 reports that the header() command does not correctly use the > replace parameter (i.e., a header of the same name should be replaced > if this parameter is true). The problem is that the standard > sapi_add_header_ex function assumes that the sapi being used with deal > with any header replacements. For Apache that works fine as the Apache > sapi correctly used the replace parameter. The IIS sapi, however, > defaults to the standard funtionality in sapi_add_header_ex (as does > the CGI). The default handler just calls zend_llist_add_element to add > the header to the header list thus appending even if replace was > requested. > > Attached is a suggested patch that first removes the header from the > list if it already exists if we are in replace mode. This works for > the Win32 IIS and CGI builds, but I don't have a way to test any > possible interaction this might have with the other sapi modules (or > under GCC). > > Michael Sisolak > [EMAIL PROTECTED] > > > __________________________________________________ > Do You Yahoo!? > Yahoo! - Official partner of 2002 FIFA World Cup > http://fifaworldcup.yahoo.com Content-Description: sapi.c.patch > --- sapi.c Tue May 14 16:11:31 2002 > +++ sapi.c.new Tue May 14 16:29:23 2002 > @@ -385,6 +385,11 @@ > return code; > } > > +static int sapi_find_matching_header(void *element1, void *element2) > +{ > + return strnicmp(((sapi_header_struct*)element1)->header, (char*)element2, >strlen((char*)element2)) == 0; > +} > + > /* This function expects a *duplicated* string, that was previously emalloc()'d. > * Pointers sent to this functions will be automatically freed by the framework. > */ > @@ -551,6 +556,19 @@ > zend_llist_clean(&SG(sapi_headers).headers); > } > if (retval & SAPI_HEADER_ADD) { > + /* in replace mode first remove the header if it already exists in > the headers llist */ > + if (replace) { > + colon_offset = strchr(header_line, ':'); > + if (colon_offset) { > + char sav; > + colon_offset++; > + sav = *colon_offset; > + *colon_offset = 0; > + zend_llist_del_element(&SG(sapi_headers).headers, >header_line, (int(*)(void*, void*))sapi_find_matching_header); > + *colon_offset = sav; > + } > + } > + > zend_llist_add_element(&SG(sapi_headers).headers, (void *) >&sapi_header); > } > if (free_header) { > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php