File: vmod_std.3

package info (click to toggle)
varnish 3.0.2-2%2Bdeb7u2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 10,584 kB
  • sloc: ansic: 54,444; sh: 11,771; xml: 2,145; makefile: 987; python: 956
file content (277 lines) | stat: -rw-r--r-- 4,516 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
.\" Man page generated from reStructeredText.
.
.TH VMOD_STD 3 "2011-05-19" "1.0" ""
.SH NAME
vmod_std \- Varnish Standard Module
.
.nr rst2man-indent-level 0
.
.de1 rstReportMargin
\\$1 \\n[an-margin]
level \\n[rst2man-indent-level]
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
-
\\n[rst2man-indent0]
\\n[rst2man-indent1]
\\n[rst2man-indent2]
..
.de1 INDENT
.\" .rstReportMargin pre:
. RS \\$1
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
. nr rst2man-indent-level +1
.\" .rstReportMargin post:
..
.de UNINDENT
. RE
.\" indent \\n[an-margin]
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
.nr rst2man-indent-level -1
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
.SH SYNOPSIS
.sp
import std
.SH DESCRIPTION
.sp
The Varnish standard module contains useful, generic function that
don\(aqt quite fit in the VCL core, but are still considered very useful
to a broad audience.
.SH FUNCTIONS
.SS toupper
.INDENT 0.0
.TP
.B Prototype
.
toupper(STRING S)
.TP
.B Return value
.
String
.TP
.B Description
.
Converts the STRING S to upper case.
.TP
.B Example
.
set beresp.http.x\-scream = std.toupper("yes!");
.UNINDENT
.SS tolower
.INDENT 0.0
.TP
.B Prototype
.
tolower(STRING S)
.TP
.B Return value
.
String
.TP
.B Description
.
Converts the STRING to lower case.
.TP
.B Example
.
set beresp.http.x\-nice = std.tolower("VerY");
.UNINDENT
.SS set_up_tos
.INDENT 0.0
.TP
.B Prototype
.
set_ip_tos(INT I)
.TP
.B Return value
.
Void
.TP
.B Description
.
Sets the Type\-of\-Service flag for the current session. Please
note that the TOS flag is not removed by the end of the
request so probably want to set it on every request should you
utilize it.
.TP
.B Example
.nf
if (req.url ~ ^/slow/) {
.in +2
std.set_up_tos(0x0);
.in -2
}
.fi
.sp
.UNINDENT
.SS random
.INDENT 0.0
.TP
.B Prototype
.
random(REAL a, REAL b)
.TP
.B Return value
.
Real
.TP
.B Description
.
Returns a random REAL number between \fIa\fP and \fIb\fP.
.TP
.B Example
.
set beresp.http.x\-random\-number = std.random(1, 100);
.UNINDENT
.SS log
.INDENT 0.0
.TP
.B Prototype
.
log(STRING string)
.TP
.B Return value
.
Void
.TP
.B Description
.
Logs string to the shared memory log.
.TP
.B Example
.
std.log("Something fishy is going on with the vhost " + req.host);
.UNINDENT
.SS syslog
.INDENT 0.0
.TP
.B Prototype
.
syslog(INT priority, STRING string)
.TP
.B Return value
.
Void
.TP
.B Description
.
Logs \fIstring\fP to syslog marked with \fIpriority\fP.
.TP
.B Example
.
std.syslog( LOG_USER|LOG_ALERT, "There is serious troble");
.UNINDENT
.SS fileread
.INDENT 0.0
.TP
.B Prototype
.
fileread(STRING filename)
.TP
.B Return value
.
String
.TP
.B Description
.
Reads a file and returns a string with the content. Please
note that it is not recommended to send variables to this
function the caching in the function doesn\(aqt take this into
account. Also, files are not re\-read.
.TP
.B Example
.
set beresp.http.x\-served\-by = std.fileread("/etc/hostname");
.UNINDENT
.SS duration
.INDENT 0.0
.TP
.B Prototype
.
duration(STRING s, DURATION fallback)
.TP
.B Return value
.
Duration
.TP
.B Description
.
Converts the string s to seconds. s can be quantified with the
usual s (seconds), m (minutes), h (hours), d (days) and w
(weeks) units. If it fails to parse the string \fIfallback\fP
will be used
.TP
.B Example
.
set beresp.ttl = std.duration("1w", 3600);
.UNINDENT
.SS integer
.INDENT 0.0
.TP
.B Prototype
.
integer(STRING s, INT fallback)
.TP
.B Return value
.
Int
.TP
.B Description
.
Converts the string s to an integer.  If it fails to parse the
string \fIfallback\fP will be used
.TP
.B Example
.
if (std.integer(beresp.http.x\-foo, 0) > 5) { … }
.UNINDENT
.SS collect
.INDENT 0.0
.TP
.B Prototype
.
collect(HEADER header)
.TP
.B Return value
.
Void
.TP
.B Description
.
Collapses the header, joining the headers into one.
.TP
.B Example
.
std.collect(req.http.cookie);
This will collapse several Cookie: headers into one, long
cookie header.
.UNINDENT
.SH SEE ALSO
.INDENT 0.0
.IP \(bu 2
.
vcl(7)
.IP \(bu 2
.
varnishd(1)
.UNINDENT
.SH HISTORY
.sp
The Varnish standard module was released along with Varnish Cache 3.0.
This manual page was written by Per Buer with help from Martin Blix
Grydeland.
.SH COPYRIGHT
.sp
This document is licensed under the same licence as Varnish
itself. See LICENCE for details.
.INDENT 0.0
.IP \(bu 2
.
Copyright (c) 2011 Varnish Software
.UNINDENT
.SH AUTHOR
Per Buer
.\" Generated by docutils manpage writer.
.\" 
.