apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sumeet Singh <sumeet.si...@openwave.com>
Subject Re: apr_tables
Date Fri, 16 Apr 2004 01:48:30 GMT
Hi ppl,
    Sorry, there was a slight error in the functions - realized that 
just after sending the prev. email. The new patch files are attached.

-regards,
sumeet

Sumeet Singh wrote:

> Hi,
>    In my use-case I am dealing with multiple headers with the same key 
> (e.g. Cookie), and need to modify or remove a specific header based on 
> its key and value (e.g. remove a certain cookie header while leaving 
> the rest in). There is no api in apr_tables that would allow me to 
> remove a given header instance. apr_table_unset will remove all 
> cookies. And I can't have my code remove a header from the 
> apr_array_table_t array because that will render the internal hash 
> index incorrect. Secondly, eventhough I can modify the value of a 
> specific header by iterating over the apr_array_header_t, that would 
> be inefficient because I wouldn't be able to use the internal 
> index_first and index_last values. Therefore I have written three 
> functions (patch files attached) and am hoping that the powers-that-be 
> will be willing to review and roll them into the APR codeline.
>
> 1) apr_table_set_one (apr_table_t *t, const char *key, const char 
> *oldVal, const char *newVal)
>    replaces value of header "key" and value "oldVal" with value 
> "newVal". If "oldVal" is null, then the first occurance of the header 
> is replaces (this is an optimization for situations where we know that 
> only one header exists and don't care about its current value). If the 
> header is not found, then it behaves like apr_table_add.
>
> 2) apr_table_setn_one(apr_table_t *t, const char *key, const char 
> *oldVal, const char *newVal)
>    Same as apr_table_set_one exept that it doesn't make a copy of key 
> and newVal.
>
> 3) apr_table_unset_one(apr_table_t *t, const char *key, const char 
> *oldVal, const char *newVal)
>    Unsets header "key" with value "oldVal". If "oldVal" is null, then 
> the first instance of the header (only) is unset (this is an 
> optimization for situations where we know that only one header exists 
> and don't care about its current value).
>
> -regards,
> S
>


Mime
View raw message