On Tue, May 20, 2014 at 04:00:16PM -0600, Sasha Pachev wrote:
> > For replace-header, I'm seeing multiple usages. The term "replace" makes
> > me think it will remove all instances and put one instead. But then, how
> > to define what the input is ?
> >
> > Maybe we could have two actions with different effects :
> >   - replace-header : iterate over all header *lines* matching the same
> >     name and apply the rule to the whole line. That will work for
> >     set-cookie for example ; This means that '^' and '$' match the
> >     beginning and end of the line.
> >
> >   - modify-header : iterate over all header *values* of all header
> >     lines, and apply the rule to the value. That will work for all
> >     other ones. This means that '^' and '$' match the beginning and
> >     end of a value, possibly delimited by commas.
> >
> > That could also make it easier to manipulate attributes present with
> > certain headers.
> >
> > Do you think that would be OK ?
> >
> > Willy
> >
> 
> Sounds like a good idea. To clarify, if we have
> 
> replace-header Foo-Header (.*) $1bar
> 
> Input:
> 
> Foo-Header: a
> Foo-Header: b
> 
> Output:
> 
> Foo-Header: abbar

No, it would not concatenate the headers, otherwise it breaks
set-cookie. For simple headers like above, you'd get the same
result with modify-header and replace-header. The difference
is visible when the header contains a comma :

Set-Cookie: A=B; expires=Wed, 21 May 2014 05:11:16 GMT
Set-Cookie: C=D; expires=Wed, 21 May 2014 05:11:16 GMT

replace-header Set-Cookie (.*) \1;bar would give :

Set-Cookie: A=B; expires=Wed, 21 May 2014 05:11:16 GMT; bar
Set-Cookie: C=D; expires=Wed, 21 May 2014 05:11:16 GMT; bar

modify-header Set-Cookie (.*) \1;bar would give :

Set-Cookie: A=B; expires=Wed; bar, 21 May 2014 05:11:16 GMT; bar
Set-Cookie: C=D; expires=Wed; bar, 21 May 2014 05:11:16 GMT; bar

Maybe the names are not the best choices, I don't know. At least I
tend to remember which one does what this way.

Willy


Reply via email to