| 1 |
<html> |
| 2 |
<head> |
| 3 |
<link rel="stylesheet" type="text/css" href="dox.css" /> |
| 4 |
<title>libapreq2-2.17: APR::Request::Cookie</title> |
| 5 |
</head> |
| 6 |
<body> |
| 7 |
<div id="page-header"> |
| 8 |
<p class="menu"> |
| 9 |
<a href="http://www.apache.org/">Apache Software Foundation</a> > <a href="http://httpd.apache.org">HTTP Server Project</a> > |
| 10 |
<a href="http://httpd.apache.org/apreq/">Request Library Subproject</a></p> |
| 11 |
<p class="apache">Apache HTTP Server Request Library</p> |
| 12 |
<img alt="" src="feather.gif" /></div> |
| 13 |
<!-- Generated by Doxygen 1.9.1 --> |
| 14 |
<script type="text/javascript" src="menudata.js"></script> |
| 15 |
<script type="text/javascript" src="menu.js"></script> |
| 16 |
<script type="text/javascript"> |
| 17 |
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| 18 |
$(function() { |
| 19 |
initMenu('',false,false,'search.php','Search'); |
| 20 |
}); |
| 21 |
/* @license-end */</script> |
| 22 |
<div id="main-nav"></div> |
| 23 |
</div><!-- top --> |
| 24 |
<div class="header"> |
| 25 |
<div class="headertitle"> |
| 26 |
<div class="title">APR::Request::Cookie<div class="ingroups"><a class="el" href="group__apreq__lang.html">Language Bindings</a> » <a class="el" href="group__apreq__xs.html">Perl</a></div></div> </div> |
| 27 |
</div><!--header--> |
| 28 |
<div class="contents"> |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
<ul id="index"> |
| 34 |
<li><a href="#NAME">NAME</a></li> |
| 35 |
<li><a href="#SYNOPSIS">SYNOPSIS</a></li> |
| 36 |
<li><a href="#DESCRIPTION">DESCRIPTION</a></li> |
| 37 |
<li><a href="#OVERLOADS">OVERLOADS</a> |
| 38 |
<ul> |
| 39 |
<li><a href="#">""</a></li> |
| 40 |
</ul> |
| 41 |
</li> |
| 42 |
<li><a href="#METHODS">METHODS</a> |
| 43 |
<ul> |
| 44 |
<li><a href="#new">new</a></li> |
| 45 |
<li><a href="#freeze">freeze</a></li> |
| 46 |
<li><a href="#thaw">thaw</a></li> |
| 47 |
<li><a href="#name">name</a></li> |
| 48 |
<li><a href="#value">value</a></li> |
| 49 |
<li><a href="#secure1">secure</a></li> |
| 50 |
<li><a href="#httponly1">httponly</a></li> |
| 51 |
<li><a href="#version1">version</a></li> |
| 52 |
<li><a href="#path1">path</a></li> |
| 53 |
<li><a href="#domain1">domain</a></li> |
| 54 |
<li><a href="#port1">port</a></li> |
| 55 |
<li><a href="#comment1">comment</a></li> |
| 56 |
<li><a href="#commentURL1">commentURL</a></li> |
| 57 |
<li><a href="#is_tainted">is_tainted</a></li> |
| 58 |
<li><a href="#make">make</a></li> |
| 59 |
<li><a href="#as_string">as_string</a></li> |
| 60 |
</ul> |
| 61 |
</li> |
| 62 |
<li><a href="#SUBROUTINES">SUBROUTINES</a> |
| 63 |
<ul> |
| 64 |
<li><a href="#expires1">expires</a></li> |
| 65 |
</ul> |
| 66 |
</li> |
| 67 |
<li><a href="#SEE-ALSO">SEE ALSO</a></li> |
| 68 |
<li><a href="#COPYRIGHT">COPYRIGHT</a></li> |
| 69 |
</ul> |
| 70 |
|
| 71 |
<h1 id="NAME">NAME</h1> |
| 72 |
|
| 73 |
<p>APR::Request::Cookie - wrapper for libapreq2's cookie API.</p> |
| 74 |
|
| 75 |
<h1 id="SYNOPSIS">SYNOPSIS</h1> |
| 76 |
|
| 77 |
<pre><code>use APR::Request::Cookie; |
| 78 |
|
| 79 |
# fetch inbound cookie |
| 80 |
$jar = $req->jar; |
| 81 |
$cookie1 = $jar->get("cookie1"); |
| 82 |
|
| 83 |
# generate new cookie |
| 84 |
$cookie = APR::Request::Cookie->new($req->pool, |
| 85 |
name => "foo", |
| 86 |
value => "bar", |
| 87 |
domain => "capricorn.com"); |
| 88 |
print "$cookie"; # prints "bar" |
| 89 |
|
| 90 |
$cookie->domain("example.com"); # change domains |
| 91 |
$cookie->version(1); # upgrade it to conform with RFC 2109/2965. |
| 92 |
|
| 93 |
# send a response header |
| 94 |
print sprintf "Set-Cookie: %s\n", $cookie->as_string;</code></pre> |
| 95 |
|
| 96 |
<h1 id="DESCRIPTION">DESCRIPTION</h1> |
| 97 |
|
| 98 |
<p>The APR::Request::Cookie module provides base methods for interfacing with libapreq2's cookie API. It also provides a few utility functions and constants.</p> |
| 99 |
|
| 100 |
<p>This manpage documents version 2.17 of the APR::Request::Cookie package.</p> |
| 101 |
|
| 102 |
<h1 id="OVERLOADS">OVERLOADS</h1> |
| 103 |
|
| 104 |
<p>APR::Request::Cookie</p> |
| 105 |
|
| 106 |
<h2 id="">""</h2> |
| 107 |
|
| 108 |
<pre><code>"$cookie"</code></pre> |
| 109 |
|
| 110 |
<p>The double-quote interpolation operator maps to <code>APR::Request::Cookie::value()</code>.</p> |
| 111 |
|
| 112 |
<pre><code>ok "$cookie" eq $cookie->value;</code></pre> |
| 113 |
|
| 114 |
<h1 id="METHODS">METHODS</h1> |
| 115 |
|
| 116 |
<p>APR::Request::Cookie</p> |
| 117 |
|
| 118 |
<h2 id="new">new</h2> |
| 119 |
|
| 120 |
<pre><code>APR::Request::Cookie->new($pool, |
| 121 |
name => $name, |
| 122 |
value => $value, |
| 123 |
%args)</code></pre> |
| 124 |
|
| 125 |
<p>Creates a new cookie. Here <code>$pool</code> is an APR::Pool object, and <code>$name</code> is the cookie's name. The <code>$value</code> is transformed into the cookie's raw value through the class' <code>freeze()</code> method. The remaining arguments are optional:</p> |
| 126 |
|
| 127 |
<dl> |
| 128 |
|
| 129 |
<dt id="secure">-secure</dt> |
| 130 |
<dd> |
| 131 |
|
| 132 |
</dd> |
| 133 |
<dt id="httponly">-httponly</dt> |
| 134 |
<dd> |
| 135 |
|
| 136 |
</dd> |
| 137 |
<dt id="version">-version</dt> |
| 138 |
<dd> |
| 139 |
|
| 140 |
</dd> |
| 141 |
<dt id="path">-path</dt> |
| 142 |
<dd> |
| 143 |
|
| 144 |
</dd> |
| 145 |
<dt id="domain">-domain</dt> |
| 146 |
<dd> |
| 147 |
|
| 148 |
</dd> |
| 149 |
<dt id="port">-port</dt> |
| 150 |
<dd> |
| 151 |
|
| 152 |
</dd> |
| 153 |
<dt id="expires">-expires</dt> |
| 154 |
<dd> |
| 155 |
|
| 156 |
</dd> |
| 157 |
<dt id="comment">-comment</dt> |
| 158 |
<dd> |
| 159 |
|
| 160 |
</dd> |
| 161 |
<dt id="commentURL">-commentURL</dt> |
| 162 |
<dd> |
| 163 |
|
| 164 |
</dd> |
| 165 |
</dl> |
| 166 |
|
| 167 |
<p>For details on these arguments, please consult the corresponding method's documentation.</p> |
| 168 |
|
| 169 |
<h2 id="freeze">freeze</h2> |
| 170 |
|
| 171 |
<pre><code>APR::Request::Cookie->freeze($value)</code></pre> |
| 172 |
|
| 173 |
<p>Class method representing the default serializer; here it returns $value unmodified.</p> |
| 174 |
|
| 175 |
<pre><code>ok "foo" eq APR::Request::Cookie->freeze("foo");</code></pre> |
| 176 |
|
| 177 |
<h2 id="thaw">thaw</h2> |
| 178 |
|
| 179 |
<pre><code>$cookie->thaw()</code></pre> |
| 180 |
|
| 181 |
<p>Reverses <code>freeze()</code>; here it simply returns $cookie->value since freeze() is a noop.</p> |
| 182 |
|
| 183 |
<pre><code>ok $cookie->thaw eq $cookie->value;</code></pre> |
| 184 |
|
| 185 |
<h2 id="name">name</h2> |
| 186 |
|
| 187 |
<pre><code>$cookie->name()</code></pre> |
| 188 |
|
| 189 |
<p>Fetch the cookie's name. This attribute cannot be modified and is never serialized; ie freeze() and thaw() do not act on the cookie's name.</p> |
| 190 |
|
| 191 |
<h2 id="value">value</h2> |
| 192 |
|
| 193 |
<pre><code>$cookie->value()</code></pre> |
| 194 |
|
| 195 |
<p>Fetch the cookie's raw (frozen) value. This attribute cannot be modified.</p> |
| 196 |
|
| 197 |
<h2 id="secure1">secure</h2> |
| 198 |
|
| 199 |
<pre><code>$cookie->secure() |
| 200 |
$cookie->secure($set)</code></pre> |
| 201 |
|
| 202 |
<p>Get/set the cookie's secure flag.</p> |
| 203 |
|
| 204 |
<pre><code>$cookie->secure(1); |
| 205 |
ok $cookie->secure == 1;</code></pre> |
| 206 |
|
| 207 |
<h2 id="httponly1">httponly</h2> |
| 208 |
|
| 209 |
<pre><code>$cookie->httponly() |
| 210 |
$cookie->httponly($set)</code></pre> |
| 211 |
|
| 212 |
<p>Get/set the cookie's HttpOnly flag.</p> |
| 213 |
|
| 214 |
<pre><code>$cookie->httponly(1); |
| 215 |
ok $cookie->httponly == 1;</code></pre> |
| 216 |
|
| 217 |
<h2 id="version1">version</h2> |
| 218 |
|
| 219 |
<pre><code>$cookie->version() |
| 220 |
$cookie->version($set)</code></pre> |
| 221 |
|
| 222 |
<p>Get/set the cookie's version number. Version 0 cookies conform to the Netscape spec; Version 1 cookies conform to either RFC 2109 or RFC 2965.</p> |
| 223 |
|
| 224 |
<pre><code>$version = $cookie->version; |
| 225 |
$cookie->version(1); |
| 226 |
ok $cookie->version == 1;</code></pre> |
| 227 |
|
| 228 |
<h2 id="path1">path</h2> |
| 229 |
|
| 230 |
<pre><code>$cookie->path() |
| 231 |
$cookie->path($set)</code></pre> |
| 232 |
|
| 233 |
<p>Get/set the cookie's path string.</p> |
| 234 |
|
| 235 |
<pre><code>$path = $cookie->path; |
| 236 |
$cookie->path("/1/2/3/4"); |
| 237 |
ok $cookie->path eq "/1/2/3/4";</code></pre> |
| 238 |
|
| 239 |
<h2 id="domain1">domain</h2> |
| 240 |
|
| 241 |
<pre><code>$cookie->domain() |
| 242 |
$cookie->domain($set)</code></pre> |
| 243 |
|
| 244 |
<p>Get/set the cookie's domain string.</p> |
| 245 |
|
| 246 |
<pre><code>$domain = $cookie->domain; |
| 247 |
$cookie->domain("apache.org"); |
| 248 |
ok $cookie->domain eq "apache.org";</code></pre> |
| 249 |
|
| 250 |
<h2 id="port1">port</h2> |
| 251 |
|
| 252 |
<pre><code>$cookie->port() |
| 253 |
$cookie->port($set)</code></pre> |
| 254 |
|
| 255 |
<p>Get/set the cookie's port string. Only valid for Version 1 cookies.</p> |
| 256 |
|
| 257 |
<pre><code>$port = $cookie->port; |
| 258 |
$cookie->port(8888); |
| 259 |
ok $cookie->port == 8888;</code></pre> |
| 260 |
|
| 261 |
<h2 id="comment1">comment</h2> |
| 262 |
|
| 263 |
<pre><code>$cookie->comment() |
| 264 |
$cookie->comment($set)</code></pre> |
| 265 |
|
| 266 |
<p>Get/set the cookie's comment string. Only valid for Version 1 cookies.</p> |
| 267 |
|
| 268 |
<pre><code>$comment = $cookie->comment; |
| 269 |
$cookie->comment("quux"); |
| 270 |
ok $cookie->comment eq "quux";</code></pre> |
| 271 |
|
| 272 |
<h2 id="commentURL1">commentURL</h2> |
| 273 |
|
| 274 |
<pre><code>$cookie->commentURL() |
| 275 |
$cookie->commentURL($set)</code></pre> |
| 276 |
|
| 277 |
<p>Get/set the cookie's commentURL string. Only valid for Version 1 cookies.</p> |
| 278 |
|
| 279 |
<pre><code>$commentURL = $cookie->commentURL; |
| 280 |
$cookie->commentURL("/foo/bar"); |
| 281 |
ok $cookie->commentURL eq "/foo/bar";</code></pre> |
| 282 |
|
| 283 |
<h2 id="is_tainted">is_tainted</h2> |
| 284 |
|
| 285 |
<pre><code>$cookie->is_tainted() |
| 286 |
$cookie->is_tainted($set)</code></pre> |
| 287 |
|
| 288 |
<p>Get/set the cookie's internal tainted flag.</p> |
| 289 |
|
| 290 |
<pre><code>$tainted = $cookie->is_tainted; |
| 291 |
$cookie->is_tainted(1); |
| 292 |
ok $cookie->is_tainted == 1;</code></pre> |
| 293 |
|
| 294 |
<h2 id="make">make</h2> |
| 295 |
|
| 296 |
<pre><code>APR::Request::Cookie->make($pool, $name, $value)</code></pre> |
| 297 |
|
| 298 |
<p>Fast XS cookie constructor invoked by <code>new()</code>. The cookie's raw name & value are taken directly from the passed in arguments; no freezing/encoding is done on the $value.</p> |
| 299 |
|
| 300 |
<h2 id="as_string">as_string</h2> |
| 301 |
|
| 302 |
<pre><code>$cookie->as_string()</code></pre> |
| 303 |
|
| 304 |
<p>String representation of the cookie, suitable for inclusion in a "Set-Cookie" header.</p> |
| 305 |
|
| 306 |
<pre><code>print "Set-Cookie: ", $cookie->as_string, "\n";</code></pre> |
| 307 |
|
| 308 |
<h1 id="SUBROUTINES">SUBROUTINES</h1> |
| 309 |
|
| 310 |
<pre><code>APR::Request::Cookie</code></pre> |
| 311 |
|
| 312 |
<h2 id="expires1">expires</h2> |
| 313 |
|
| 314 |
<pre><code>expires($date_string)</code></pre> |
| 315 |
|
| 316 |
<h1 id="SEE-ALSO">SEE ALSO</h1> |
| 317 |
|
| 318 |
<p><a>Apache2::Cookie</a>, <a>APR::Request</a>.</p> |
| 319 |
|
| 320 |
<h1 id="COPYRIGHT">COPYRIGHT</h1> |
| 321 |
|
| 322 |
<pre><code>Licensed to the Apache Software Foundation (ASF) under one or more |
| 323 |
contributor license agreements. See the NOTICE file distributed with |
| 324 |
this work for additional information regarding copyright ownership. |
| 325 |
The ASF licenses this file to You under the Apache License, Version 2.0 |
| 326 |
(the "License"); you may not use this file except in compliance with |
| 327 |
the License. You may obtain a copy of the License at |
| 328 |
|
| 329 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 330 |
|
| 331 |
Unless required by applicable law or agreed to in writing, software |
| 332 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 333 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 334 |
See the License for the specific language governing permissions and |
| 335 |
limitations under the License.</code></pre> |
| 336 |
|
| 337 |
|
| 338 |
</div><!-- contents --> |
| 339 |
<div id="footer"> |
| 340 |
<p class="apache"> |
| 341 |
Copyright © 2003-2006 <a href="http://www.apache.org">The Apache Software Foundation</a>.<br/> |
| 342 |
See <a href="apreq_license.html">LICENSE</a>.</p> |
| 343 |
<p class="menu"> |
| 344 |
<span style="color:#aaa">page generated by <a href="http://www.doxygen.org/"><code>doxygen</code></a> |
| 345 |
version 1.9.1 on Thu Aug 18 2022</span> |
| 346 |
</p> |
| 347 |
</div> |
| 348 |
</body> |
| 349 |
</html> |