Update1: Would appreciate reciews of a header element parsing/modification prototype
slink at schokola.de
Sun Sep 28 20:25:18 CEST 2014
Update after txt constification (my fault :P)
iow this patch is based upon e40edceffff77d0578237a85cf5109cd0d069599
On 22/09/14 09:37, Poul-Henning Kamp wrote:
> I would do it something like this instead:
> did = 0
> Reserve workspace
> loop over tokens in src-header
> if token != target
> copy token to workspace
> did = 1
> if (did):
> release unused workspace
> return all reserved workspace
> return (did)
> That would largely be a duplication of http_GetHdrToken() just a few
> lines longer.
I actually have done an implementation along these lines, but I did not like it
at all, it got really lengthy, lacked generality etc etc.
With the idea in mind that we could have general header element editing
facilities (no matter in a vmod or core/vcl), I have written a more generic
prototype around the suggested http_RemoveHdrToken function following the design
example of struct http and the HTTP_* functions.
For the protoype I have worked in cache_http.c, the source structure and the
question of which functions to declare static are things I'd like to think about
struct httphdr holds two txt arrays for the parse of a header line - one for
names and one for values (think "max-age=200")
HTTPHDR_estimate and HTTPHDR_create closely follow the HTTP_ examples.
HTTPHDR_Tokenize dissects a header line into element keys and values. The
seperating characters are to be generalized later.
HTTPHDR_Join constructs a header line from a struct httphdr on some buffer provided.
HTTPHDR_SameToken compares two header elemnts passed as (c)txt structs either
case sensitively for the quoted or case insensitively for the unquoted case.
HTTPHDR_RemoveToken nulls all instances of a token name in a struct httphdr
http_RemoveHdrToken (and the corresponding VRT) is the PoC implementation. It
builds the struct httphdr parse on the stack and only leaves a finalized header
on the workspace.
bin/varnishtest/tests/removehdrtoken.vtc is a working test for the remove header
I'd very much appreciate feedback on this.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 14017 bytes
Desc: not available
More information about the varnish-dev