Added Header.add_multi#278
Conversation
|
Makes sense to me. It would be nice to have put the |
|
+1 from me |
|
The name is very ugly, |
|
So |
|
Personally what I read is what they refer as multiple message header fields are fields that appear more than once: by that count the signature of a potential no ? Also, shouldn't that module be called |
And thus to be pedantic the function of the PR should be called |
|
It's named Line 66 in bccaff2 _multi being for header keys that have multiple values, but this PR lets users add multiple values to a key, too. In order to keep _multi for functions that ONLY deal with multiple values per key, I think add_list is the best alternative.
Also, I stayed with the convention of having |
|
@SGrondin good point didn't know about
Also it seem to me that the signature of |
|
Multiheaders have a list of values separated by commas for a key or multiple equal keys or both. If |
|
@dsheets right, you may want to count the number of empty occurences of the same header. (Though the comma thing should actually be sorted out, if you don't keep commas when there are values you should not put one when there is no value). |
|
(This shows that these functions should actually be documented w.r.t. to these details, I can save you a lot of time). |
|
Alright, so is there any consensus between |
|
The number of empty occurrences will be the number of empty strings. A multiheader with value of comma should result in two empty occurrences. I'm not sure you understand my point about commas: if there is no value, no comma is generated; if the header is not a multiheader, a comma doesn't mean anything and is part of the value; if there is a value for a multiheader and it is only a comma, this is equivalent to two empty multiheaders. I think this behavior is fairly intuitive. There could probably be more documentation but these details should be obvious. I'm not sure where the confusion is. @SGrondin I agree with @dbuenzli's names and signatures fwiw. |
|
I implemented val add_multi : t -> string -> string list -> t
val add_list : t -> (string * string) list -> tplease review it. |
The other option being to add labels to the other params. Aesthetically, this is what I prefer but I realize it could be just better to follow the existing convention (which is t last). In any case, I think there's consensus on the names of the 2 functions and since the implementation is trivial enough I'm merging this in. |
I think it's cleaner than lines of
when adding multiple headers at once.
Discuss?