On Sep 5, 2008, at 7:23 PM, Gisle Aas wrote:
True; and in this case we need to define what happens when fields are
modified with 'push', 'set' or 'init' and 'remove' as that's the API
that modify stuff.  Let me suggest the following definition of the
behaviour:

- 'push' always append the field at the end of all headers.  multiple
occurrences of a field name do not have to be consecutive.

- 'init' either does nothing or it works like 'push'.

- 'remove' will always remove all concurrences of a field.

- 'set' will work like 'push' if no other occurrence of the field exists.

- 'set' will update the first occurrence if the field exists (and
remove all other occurrences).  if multiple field values is provided
with 'set' they are basically all injected at the location of the
first existing value.


On Sep 6, 2008 at 2:57 AM, Gisle Aas wrong:
I think it makes sense to be able to enable them separately.
Suggested interface:

 $h->scan(\&cb, original_order => 1, original_case => 1);
 $h->as_string(eol => "\n", original_order => 1, original_case => 1);'

The attached patch uses the interface above and works towards the behavior outlined in the first message. Due to the headers being stored as a hash, pushing does not currently preserve previous values, second and subsequent pushes of the same header will overwrite the previous value. Supporting this would require a change in how the headers are stored within the module. Your thoughts? The most obvious solution to me would be storing headers and their values as a hashref in an arrayref

Server: Fool/1.0
content-encoding: gzip
Content-Type: text/plain; charset="UTF-8"
Content-Encoding: base64
Date: Fri Sep  5 10:24:37 CEST 2008

Would be stored as (assuming push_header):

$self->{_headers} = [
        { server => 'Fool/1.0' },
        { content-encoding => 'gzip'},
        { content-type => 'text/plain; charset="UTF-8"},
        { content-encoding => 'base64' },
        { date => 'Fri Sep  5 10:24:37 CEST 2008' }
];

This would negate the need for $self->{_original_order}. $self- >{_header} (or some such) could be a hashref with header fields as the keys and the header's index(s) in _headers as their value to speed and simplify direct access to an individual header's value.

--
Michael Greb
Linode.com
609-593-7103 ext 1205


Attachment: 0001-preservation-of-original-header-order-and-case.patch
Description: Binary data

Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to