GithubHelp home page GithubHelp logo

simonvik / libvmod-bodyaccess Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aondio/libvmod-bodyaccess

0.0 2.0 0.0 96 KB

Branches 4.0 && 4.1 are not in maintenance. Bug:https://github.com/varnishcache/varnish-cache/issues/1927

License: Other

Makefile 13.51% Shell 8.76% M4 21.83% VCL 20.94% C 34.96%

libvmod-bodyaccess's Introduction

vmod_bodyaccess

Travis CI badge

Varnish Bodyaccess Module

Author

Arianna Aondio

Date

2015-06-18

Version

1.0

SYNOPSIS

import bodyaccess;

DESCRIPTION

Varnish vmod that lets you access the request body.

FUNCTIONS

len_req_body

Prototype
len_req_body()
Return value

INT

Description

Returns the request body length or -1 if an error occurs.

Note that the request body must be buffered.

Example
| std.cache_req_body(1KB);
set req.http.x-len = bodyaccess.len_req_body();

hash_req_body

Prototype
hash_req_body()
Return value

VOID

Description

Adds available request body bytes to the lookup hash key.

Note that this function can only be used in vcl_hash and

the request body must be buffered.

Example
| sub vcl_recv {
    std.cache_req_body(1KB);
}

sub vcl_hash{
    bodyaccess.hash_req_body();
}

rematch_req_body

Prototype
rematch_req_body(PRIV_CALL, STRING re)
Return value

INT

Description

Returns -1 if an error occurrs.

Returns 0 if the request body doesn't contain the string re.

Returns 1 if the request body contains the string re.

Note that the comparison is case sensitive and the request body must be buffered.

Example
| std.cache_req_body(1KB);

if (bodyaccess.rematch_req_body("FOO") == 1) {
   std.log("is true");
}

Find more example in example.vcl.

N.B. The request body must be retrieved before doing any operations on it. It can be buffered using the cache_req_body() function from libvmod_std.

These functions applies only to standard REST methods. Caching is not allowed on PUT requests.

INSTALLATION

The source tree is based on autotools to configure the building, and does also have the necessary bits in place to do functional unit tests using the varnishtest tool.

Building requires the Varnish header files and uses pkg-config to find the necessary paths.

Usage:

./autogen.sh
./configure

If you have installed Varnish to a non-standard directory, call autogen.sh and configure with PKG_CONFIG_PATH pointing to the appropriate path. For example, when varnishd configure was called with --prefix=$PREFIX, use

PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig export PKG_CONFIG_PATH

Make targets:

  • make - builds the vmod.
  • make install - installs your vmod.
  • make check - runs the unit tests in src/tests/*.vtc
  • make distcheck - run check and prepare a tarball of the vmod.

COMMON PROBLEMS

  • configure: error: Need varnish.m4 -- see README.rst

    Check if PKG_CONFIG_PATH has been set correctly before calling autogen.sh and configure

libvmod-bodyaccess's People

Contributors

aondio avatar daghf avatar dridi avatar kristianlyng avatar mbgrydeland avatar nigoroll avatar perbu avatar rodricels avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.