Code Monkey home page Code Monkey logo

libvmod-querystring's Introduction

vmod_querystring

Varnish QueryString Module

Author

Dridi Boukelmoune

Date

2012-06-18

Version

0.3

Manual section

3

SYNOPSIS

import querystring;

DESCRIPTION

Varnish multipurpose vmod for URI query-string manipulation. Can be used to normalize for instance request URLs or Location response headers in various ways. It is recommended to at least clean incoming request URLs (removing empty parameters or query-strings), all other functions do the cleaning.

FUNCTIONS

clean

Prototype

STRING clean(STRING url)

Description

Returns the given URI without empty parameters. The query-string is removed if empty (either before or after the removal of empty parameters).

Example

set req.url = querystring.clean(req.url);

remove

Prototype

STRING remove(STRING url)

Description

Returns the given URI with its query-string removed

Example

set req.url = querystring.remove(req.url);

sort

Prototype

STRING sort(STRING url)

Description

Returns the given URI with its query-string sorted

Example

set req.url = querystring.sort(req.url);

filtersep

Prototype

STRING filtersep()

Description

Returns the separator needed by the filter and filter_except functions

filter

Prototype

STRING filter(STRING url, STRING_LIST parameter_names)

Description

Returns the given URI without the listed parameters

Example
set req.url = querystring.filter(req.url,

"utm_source" + querystring.filtersep() + "utm_medium" + querystring.filtersep() + "utm_campaign");

filter_except

Prototype

STRING filter_except(STRING url, STRING_LIST parameter_names)

Description

Returns the given URI but only keeps the listed parameters

Example
set req.url = querystring.filter_except(req.url,

"q" + querystring.filtersep() + "p");

regfilter

Prototype

STRING regfilter(STRING url, STRING parameter_names_regex)

Description

Returns the given URI without the parameters matching a regular expression

Example

set req.url = querystring.regfilter(req.url, "utm_.*");

regfilter_except

Prototype

STRING regfilter_except(STRING url, STRING parameter_names_regex)

Description

Returns the given URI but only keeps the parameters matching a regular expression

Example

set req.url = querystring.regfilter_except(req.url, "^(q|p)$");

EXAMPLES

In your VCL you could then use this vmod along the following lines:

import querystring;

sub vcl_hash {
   # sort the URL before the request hashing
   set req.url = querystring.sort(req.url);
}

ACKNOWLEDGMENT

The sort algorithm is a mix of Jason Mooberry's Skwurly and my own QuerySort with regards for the Varnish workspace memory model of the worker threads.

This document is licensed under the same license as the libvmod-querystring project. See LICENSE for details.

  • Copyright (c) 2012-2014 Dridi Boukelmoune

libvmod-querystring's People

Contributors

db-pj avatar dridi avatar gandikun avatar rwoverdijk avatar tjakobsson avatar zmousm avatar

Watchers

 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.