File: group__apreq__xs__apr__request__cookie.html

package info (click to toggle)
libapreq2 2.17-3~bpo12%2B1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-backports
  • size: 5,108 kB
  • sloc: ansic: 8,263; perl: 5,451; sh: 4,627; cpp: 380; makefile: 270; javascript: 186
file content (349 lines) | stat: -rw-r--r-- 10,583 bytes parent folder | download | duplicates (2)
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<html>
<head>
  <link rel="stylesheet" type="text/css" href="dox.css" />
  <title>libapreq2-2.17: APR::Request::Cookie</title> 
</head>
<body>
<div id="page-header">
<p class="menu">
   <a href="http://www.apache.org/">Apache Software Foundation</a> &gt; <a href="http://httpd.apache.org">HTTP Server Project</a> &gt;
<a href="http://httpd.apache.org/apreq/">Request Library Subproject</a></p>
<p class="apache">Apache HTTP Server Request Library</p>
<img alt="" src="feather.gif" /></div>
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','Search');
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">APR::Request::Cookie<div class="ingroups"><a class="el" href="group__apreq__lang.html">Language Bindings</a> &raquo; <a class="el" href="group__apreq__xs.html">Perl</a></div></div>  </div>
</div><!--header-->
<div class="contents">




<ul id="index">
  <li><a href="#NAME">NAME</a></li>
  <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
  <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
  <li><a href="#OVERLOADS">OVERLOADS</a>
    <ul>
      <li><a href="#">&quot;&quot;</a></li>
    </ul>
  </li>
  <li><a href="#METHODS">METHODS</a>
    <ul>
      <li><a href="#new">new</a></li>
      <li><a href="#freeze">freeze</a></li>
      <li><a href="#thaw">thaw</a></li>
      <li><a href="#name">name</a></li>
      <li><a href="#value">value</a></li>
      <li><a href="#secure1">secure</a></li>
      <li><a href="#httponly1">httponly</a></li>
      <li><a href="#version1">version</a></li>
      <li><a href="#path1">path</a></li>
      <li><a href="#domain1">domain</a></li>
      <li><a href="#port1">port</a></li>
      <li><a href="#comment1">comment</a></li>
      <li><a href="#commentURL1">commentURL</a></li>
      <li><a href="#is_tainted">is_tainted</a></li>
      <li><a href="#make">make</a></li>
      <li><a href="#as_string">as_string</a></li>
    </ul>
  </li>
  <li><a href="#SUBROUTINES">SUBROUTINES</a>
    <ul>
      <li><a href="#expires1">expires</a></li>
    </ul>
  </li>
  <li><a href="#SEE-ALSO">SEE ALSO</a></li>
  <li><a href="#COPYRIGHT">COPYRIGHT</a></li>
</ul>

<h1 id="NAME">NAME</h1>

<p>APR::Request::Cookie - wrapper for libapreq2&#39;s cookie API.</p>

<h1 id="SYNOPSIS">SYNOPSIS</h1>

<pre><code>use APR::Request::Cookie;

# fetch inbound cookie
$jar = $req-&gt;jar;
$cookie1 = $jar-&gt;get(&quot;cookie1&quot;);

# generate new cookie
$cookie = APR::Request::Cookie-&gt;new($req-&gt;pool,
                                    name =&gt; &quot;foo&quot;,
                                   value =&gt; &quot;bar&quot;,
                                  domain =&gt; &quot;capricorn.com&quot;);
print &quot;$cookie&quot;; # prints &quot;bar&quot;

$cookie-&gt;domain(&quot;example.com&quot;); # change domains
$cookie-&gt;version(1); # upgrade it to conform with RFC 2109/2965.

# send a response header
print sprintf &quot;Set-Cookie: %s\n&quot;, $cookie-&gt;as_string;</code></pre>

<h1 id="DESCRIPTION">DESCRIPTION</h1>

<p>The APR::Request::Cookie module provides base methods for interfacing with libapreq2&#39;s cookie API. It also provides a few utility functions and constants.</p>

<p>This manpage documents version 2.17 of the APR::Request::Cookie package.</p>

<h1 id="OVERLOADS">OVERLOADS</h1>

<p>APR::Request::Cookie</p>

<h2 id="">&quot;&quot;</h2>

<pre><code>&quot;$cookie&quot;</code></pre>

<p>The double-quote interpolation operator maps to <code>APR::Request::Cookie::value()</code>.</p>

<pre><code>ok &quot;$cookie&quot; eq $cookie-&gt;value;</code></pre>

<h1 id="METHODS">METHODS</h1>

<p>APR::Request::Cookie</p>

<h2 id="new">new</h2>

<pre><code>APR::Request::Cookie-&gt;new($pool,
                           name =&gt; $name,
                          value =&gt; $value,
                          %args)</code></pre>

<p>Creates a new cookie. Here <code>$pool</code> is an APR::Pool object, and <code>$name</code> is the cookie&#39;s name. The <code>$value</code> is transformed into the cookie&#39;s raw value through the class&#39; <code>freeze()</code> method. The remaining arguments are optional:</p>

<dl>

<dt id="secure">-secure</dt>
<dd>

</dd>
<dt id="httponly">-httponly</dt>
<dd>

</dd>
<dt id="version">-version</dt>
<dd>

</dd>
<dt id="path">-path</dt>
<dd>

</dd>
<dt id="domain">-domain</dt>
<dd>

</dd>
<dt id="port">-port</dt>
<dd>

</dd>
<dt id="expires">-expires</dt>
<dd>

</dd>
<dt id="comment">-comment</dt>
<dd>

</dd>
<dt id="commentURL">-commentURL</dt>
<dd>

</dd>
</dl>

<p>For details on these arguments, please consult the corresponding method&#39;s documentation.</p>

<h2 id="freeze">freeze</h2>

<pre><code>APR::Request::Cookie-&gt;freeze($value)</code></pre>

<p>Class method representing the default serializer; here it returns $value unmodified.</p>

<pre><code>ok &quot;foo&quot; eq APR::Request::Cookie-&gt;freeze(&quot;foo&quot;);</code></pre>

<h2 id="thaw">thaw</h2>

<pre><code>$cookie-&gt;thaw()</code></pre>

<p>Reverses <code>freeze()</code>; here it simply returns $cookie-&gt;value since freeze() is a noop.</p>

<pre><code>ok $cookie-&gt;thaw eq $cookie-&gt;value;</code></pre>

<h2 id="name">name</h2>

<pre><code>$cookie-&gt;name()</code></pre>

<p>Fetch the cookie&#39;s name. This attribute cannot be modified and is never serialized; ie freeze() and thaw() do not act on the cookie&#39;s name.</p>

<h2 id="value">value</h2>

<pre><code>$cookie-&gt;value()</code></pre>

<p>Fetch the cookie&#39;s raw (frozen) value. This attribute cannot be modified.</p>

<h2 id="secure1">secure</h2>

<pre><code>$cookie-&gt;secure()
$cookie-&gt;secure($set)</code></pre>

<p>Get/set the cookie&#39;s secure flag.</p>

<pre><code>$cookie-&gt;secure(1);
ok $cookie-&gt;secure == 1;</code></pre>

<h2 id="httponly1">httponly</h2>

<pre><code>$cookie-&gt;httponly()
$cookie-&gt;httponly($set)</code></pre>

<p>Get/set the cookie&#39;s HttpOnly flag.</p>

<pre><code>$cookie-&gt;httponly(1);
ok $cookie-&gt;httponly == 1;</code></pre>

<h2 id="version1">version</h2>

<pre><code>$cookie-&gt;version()
$cookie-&gt;version($set)</code></pre>

<p>Get/set the cookie&#39;s version number. Version 0 cookies conform to the Netscape spec; Version 1 cookies conform to either RFC 2109 or RFC 2965.</p>

<pre><code>$version = $cookie-&gt;version;
$cookie-&gt;version(1);
ok $cookie-&gt;version == 1;</code></pre>

<h2 id="path1">path</h2>

<pre><code>$cookie-&gt;path()
$cookie-&gt;path($set)</code></pre>

<p>Get/set the cookie&#39;s path string.</p>

<pre><code>$path = $cookie-&gt;path;
$cookie-&gt;path(&quot;/1/2/3/4&quot;);
ok $cookie-&gt;path eq &quot;/1/2/3/4&quot;;</code></pre>

<h2 id="domain1">domain</h2>

<pre><code>$cookie-&gt;domain()
$cookie-&gt;domain($set)</code></pre>

<p>Get/set the cookie&#39;s domain string.</p>

<pre><code>$domain = $cookie-&gt;domain;
$cookie-&gt;domain(&quot;apache.org&quot;);
ok $cookie-&gt;domain eq &quot;apache.org&quot;;</code></pre>

<h2 id="port1">port</h2>

<pre><code>$cookie-&gt;port()
$cookie-&gt;port($set)</code></pre>

<p>Get/set the cookie&#39;s port string. Only valid for Version 1 cookies.</p>

<pre><code>$port = $cookie-&gt;port;
$cookie-&gt;port(8888);
ok $cookie-&gt;port == 8888;</code></pre>

<h2 id="comment1">comment</h2>

<pre><code>$cookie-&gt;comment()
$cookie-&gt;comment($set)</code></pre>

<p>Get/set the cookie&#39;s comment string. Only valid for Version 1 cookies.</p>

<pre><code>$comment = $cookie-&gt;comment;
$cookie-&gt;comment(&quot;quux&quot;);
ok $cookie-&gt;comment eq &quot;quux&quot;;</code></pre>

<h2 id="commentURL1">commentURL</h2>

<pre><code>$cookie-&gt;commentURL()
$cookie-&gt;commentURL($set)</code></pre>

<p>Get/set the cookie&#39;s commentURL string. Only valid for Version 1 cookies.</p>

<pre><code>$commentURL = $cookie-&gt;commentURL;
$cookie-&gt;commentURL(&quot;/foo/bar&quot;);
ok $cookie-&gt;commentURL eq &quot;/foo/bar&quot;;</code></pre>

<h2 id="is_tainted">is_tainted</h2>

<pre><code>$cookie-&gt;is_tainted()
$cookie-&gt;is_tainted($set)</code></pre>

<p>Get/set the cookie&#39;s internal tainted flag.</p>

<pre><code>$tainted = $cookie-&gt;is_tainted;
$cookie-&gt;is_tainted(1);
ok $cookie-&gt;is_tainted == 1;</code></pre>

<h2 id="make">make</h2>

<pre><code>APR::Request::Cookie-&gt;make($pool, $name, $value)</code></pre>

<p>Fast XS cookie constructor invoked by <code>new()</code>. The cookie&#39;s raw name &amp; value are taken directly from the passed in arguments; no freezing/encoding is done on the $value.</p>

<h2 id="as_string">as_string</h2>

<pre><code>$cookie-&gt;as_string()</code></pre>

<p>String representation of the cookie, suitable for inclusion in a &quot;Set-Cookie&quot; header.</p>

<pre><code>print &quot;Set-Cookie: &quot;, $cookie-&gt;as_string, &quot;\n&quot;;</code></pre>

<h1 id="SUBROUTINES">SUBROUTINES</h1>

<pre><code>APR::Request::Cookie</code></pre>

<h2 id="expires1">expires</h2>

<pre><code>expires($date_string)</code></pre>

<h1 id="SEE-ALSO">SEE ALSO</h1>

<p><a>Apache2::Cookie</a>, <a>APR::Request</a>.</p>

<h1 id="COPYRIGHT">COPYRIGHT</h1>

<pre><code>Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements.  See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the &quot;License&quot;); you may not use this file except in compliance with
the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</code></pre>


 </div><!-- contents -->
<div id="footer">
<p class="apache">
Copyright &copy; 2003-2006 <a href="http://www.apache.org">The Apache Software Foundation</a>.<br/>
See <a href="apreq_license.html">LICENSE</a>.</p>
<p class="menu">
<span style="color:#aaa">page generated by <a href="http://www.doxygen.org/"><code>doxygen</code></a>
version 1.9.1 on Thu Aug 18 2022</span>
</p>
</div>
</body>
</html>