Add support for varnish 4.x

I built this patchset against libvarnishapi 2.0.6, 3.0.2 and 4.0.2, but I didn't have the opportunity to run it on production varnishes yet. As the changes are well confined inside `#ifdef` blocks, I'm pretty confident that any problem possibly introduced here would be limited to varnish 4.x.

Would fix #618