proposal part 1 - VCL: edit header tokens/entities

Geoff Simmons geoff at uplex.de
Tue Sep 2 08:33:51 CEST 2014


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 9/1/14 7:01 PM, Nils Goroll wrote:
> 
> According to http://tools.ietf.org/html/rfc7230#section-3.2 we
> cannot assume some "special" character not to be contained in a
> header token/entity name or value.

Maybe so, but in practice this sort of example is extremely unusual;
it would be OK if the syntax necessary for it is cumbersome.

> Foo: g[oo]g\l"e=watching

> The best suggestion for a syntax I could think of so far is to use
> the existing string notation, so
> 
> set beresp.http.Foo.{"g[oo]g\l"e"} = "watching";
> 
> would yield the same result.

It looks like this would work technically, but consider that VCL
strives for syntax that is familiar from other familiar languages. I
personally have never seen anything like that; "that looks weird"
might be a common user feedback.

Suggestion: stay with the quoted strings, but enclose them in square
brackets rather than use the dot notation. Then it looks the syntax
for associative arrays used by shells, Perl, Ruby, PHP and so forth.

set req.http.Accept["q"] = 3.14;
unset req.http.Accept["*/*"];
if (beresp.http.Surrogate-Control["max-age"] ~ "\d+")
if (beresp.http.Surrogate-Control["max-age"]) // boolean context

It gets a little repetitive with brackets when the string includes
quotation marks, then we'd have something like [{"..."}], but I think
that's OK.

I'm not a big fan of:

> Accept: text/plain; q=0.5, text/x-dvi, */*
> 
> set req.http.Accept."text/plain"."q" = 3.14;
> 
> -> Accept: text/plain; q=3.14, text/x-dvi, */*

I had to look at that several times to realize what's going on -- the
operation adds 'text/plain; q=3.14' to a comma-separated list. At
first glance it looked like the set operation was doing two things at
once, adding both 'text/plain', which is not set to anything, and 'q',
which is set to the right-hand side.

You'd think it should actually be (my notation suggestion this time):

set req.http.Accept["text/plain; q"] = 3.14:

Or of:

> set req.http.Accept.{""quoted"/printable"};
> 
> -> Accept: text/plain; q=3.14, text/x-dvi, */*, "quoted"/printable
> 
> Vary: Accept-Language
> 
> set beresp.http.Vary."Accept-Encoding";
> 
> -> Vary: Accept-Language, Accept-Encoding

I think we should have different operations, other than set and unset,
for comma-separated lists of scalar values that aren't of the form
x=y. Something like add and remove for lists. The VMOD header actually
comes very close to providing something like that (but not quite).

'set LHS;' without a RHS looks like one of those gotcha tests for C
programmers ("what does 'x;' do? did you know that it's even possible?").

These admittedly do look intuitive.

> -> Vary: Accept-Language, Accept-Encoding
> 
> unset beresp.http.Vary."Accept-Language";
> 
> -> Vary: Accept-Encoding
> 
> unset beresp.http.Vary."Accept-Encoding";
> 
> -> (void) - header removed


Best,
Geoff
- -- 
UPLEX Systemoptimierung
Scheffelstraße 32
22301 Hamburg
http://uplex.de/
Mob: +49-176-63690917
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.14 (Darwin)

iQIcBAEBCAAGBQJUBWTOAAoJEOUwvh9pJNURXwMP/011D8XsoMzQ+CFFhkA1upQu
Cfd9uNePBvI3oDibJ+NDNH5f9vyXMcmrCnk6yvvRGO66X0B82PHANlzdXY5oG3gs
vBUHOfOvX9UBQjO6iWuHeogUoj7xD4wjCGVZFRgqE95F7c+hLCtY5UUoAn5J4lpf
UtoWsM046vAdiliiGjBX2QbFBoJ+li0s7Y2suLp1/fVaK8c+tRtV20ODKUwkDFFp
GsTihox6jZzdqVyYQeQOjlEk1FF01Y8FgYYETp3Rf9KXzKWbRSy3QCYIkyUzm0Dp
pseHrUdfNEUmRjsPKctmrsLG6mkqdV92LKzqhrgY28eE5miCX8PHqYaXLeaB7nTi
r9xnNkazSecBUmTkPwJkKjxflVhw1byG6xpHhsEC+JKmixxeQKhPP8Ug8vUA5XGx
2kDfduqudMaZ5rjd058Bjd/PVnzdvHKw7TxMSFeg82Hx+Uww6sg4TaJkgu8giCg/
P7ddbeOLsVF4OkESxXjcrJuSoVYXKKGZg2CnjLwmsgIYOl5d6nktmrhb8t/vs77w
Gk+SI5kFJ4+QJiE9KrNiWHl/J5TTCeku7sFwB94VWKU6iQ7SSPkqGoZ+G26Md/pg
ZKyEq1ueIphcKmnI+ZL/MsmOgkM0DaRBfHH0bFQI1B/j9FDaGLHfNsBkAS8dETWx
3JOtFUmT7SP2w+0+f5/R
=+NzM
-----END PGP SIGNATURE-----



More information about the varnish-dev mailing list