@@ -12,33 +12,33 @@ use HTTP::Response;
12
12
# http://curl.haxx.se/rfc/cookie_spec.html
13
13
14
14
# Client requests a document, and receives in the response:
15
- #
15
+ #
16
16
# Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/; expires=Wednesday, 09-Nov-99 23:12:40 GMT
17
- #
17
+ #
18
18
# When client requests a URL in path "/" on this server, it sends:
19
- #
19
+ #
20
20
# Cookie: CUSTOMER=WILE_E_COYOTE
21
- #
21
+ #
22
22
# Client requests a document, and receives in the response:
23
- #
23
+ #
24
24
# Set-Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001; path=/
25
- #
25
+ #
26
26
# When client requests a URL in path "/" on this server, it sends:
27
- #
27
+ #
28
28
# Cookie: CUSTOMER=WILE_E_COYOTE; PART_NUMBER=ROCKET_LAUNCHER_0001
29
- #
29
+ #
30
30
# Client receives:
31
- #
31
+ #
32
32
# Set-Cookie: SHIPPING=FEDEX; path=/fo
33
- #
33
+ #
34
34
# When client requests a URL in path "/" on this server, it sends:
35
- #
35
+ #
36
36
# Cookie: CUSTOMER=WILE_E_COYOTE; PART_NUMBER=ROCKET_LAUNCHER_0001
37
- #
37
+ #
38
38
# When client requests a URL in path "/foo" on this server, it sends:
39
- #
39
+ #
40
40
# Cookie: CUSTOMER=WILE_E_COYOTE; PART_NUMBER=ROCKET_LAUNCHER_0001; SHIPPING=FEDEX
41
- #
41
+ #
42
42
# The last Cookie is buggy, because both specifications says that the
43
43
# most specific cookie must be sent first. SHIPPING=FEDEX is the
44
44
# most specific and should thus be first.
@@ -98,27 +98,27 @@ print $c->as_string;
98
98
99
99
100
100
# Second Example transaction sequence:
101
- #
101
+ #
102
102
# Assume all mappings from above have been cleared.
103
- #
103
+ #
104
104
# Client receives:
105
- #
105
+ #
106
106
# Set-Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001; path=/
107
- #
107
+ #
108
108
# When client requests a URL in path "/" on this server, it sends:
109
- #
109
+ #
110
110
# Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001
111
- #
111
+ #
112
112
# Client receives:
113
- #
113
+ #
114
114
# Set-Cookie: PART_NUMBER=RIDING_ROCKET_0023; path=/ammo
115
- #
115
+ #
116
116
# When client requests a URL in path "/ammo" on this server, it sends:
117
- #
117
+ #
118
118
# Cookie: PART_NUMBER=RIDING_ROCKET_0023; PART_NUMBER=ROCKET_LAUNCHER_0001
119
- #
119
+ #
120
120
# NOTE: There are two name/value pairs named "PART_NUMBER" due to
121
- # the inheritance of the "/" mapping in addition to the "/ammo" mapping.
121
+ # the inheritance of the "/" mapping in addition to the "/ammo" mapping.
122
122
123
123
$c = HTTP::Cookies-> new; # clear it
124
124
@@ -164,67 +164,67 @@ ok(count_cookies($c), 0);
164
164
165
165
$c = HTTP::Cookies-> new;
166
166
167
- #
167
+ #
168
168
# 5.1 Example 1
169
- #
169
+ #
170
170
# Most detail of request and response headers has been omitted. Assume
171
171
# the user agent has no stored cookies.
172
- #
172
+ #
173
173
# 1. User Agent -> Server
174
- #
174
+ #
175
175
# POST /acme/login HTTP/1.1
176
176
# [form data]
177
- #
177
+ #
178
178
# User identifies self via a form.
179
- #
179
+ #
180
180
# 2. Server -> User Agent
181
- #
181
+ #
182
182
# HTTP/1.1 200 OK
183
183
# Set-Cookie2: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"
184
- #
184
+ #
185
185
# Cookie reflects user's identity.
186
186
187
187
$cookie = interact($c , ' http://www.acme.com/acme/login' ,
188
188
' Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"' );
189
189
ok(!$cookie );
190
190
191
- #
191
+ #
192
192
# 3. User Agent -> Server
193
- #
193
+ #
194
194
# POST /acme/pickitem HTTP/1.1
195
195
# Cookie: $Version="1"; Customer="WILE_E_COYOTE"; $Path="/acme"
196
196
# [form data]
197
- #
197
+ #
198
198
# User selects an item for ``shopping basket.''
199
- #
199
+ #
200
200
# 4. Server -> User Agent
201
- #
201
+ #
202
202
# HTTP/1.1 200 OK
203
203
# Set-Cookie2: Part_Number="Rocket_Launcher_0001"; Version="1";
204
204
# Path="/acme"
205
- #
205
+ #
206
206
# Shopping basket contains an item.
207
207
208
208
$cookie = interact($c , ' http://www.acme.com/acme/pickitem' ,
209
209
' Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"' );
210
210
ok($cookie =~ m ( ^\$ Version="?1"?; Customer="?WILE_E_COYOTE"?; \$ Path="/acme"$) ) ;
211
211
212
- #
212
+ #
213
213
# 5. User Agent -> Server
214
- #
214
+ #
215
215
# POST /acme/shipping HTTP/1.1
216
216
# Cookie: $Version="1";
217
217
# Customer="WILE_E_COYOTE"; $Path="/acme";
218
218
# Part_Number="Rocket_Launcher_0001"; $Path="/acme"
219
219
# [form data]
220
- #
220
+ #
221
221
# User selects shipping method from form.
222
- #
222
+ #
223
223
# 6. Server -> User Agent
224
- #
224
+ #
225
225
# HTTP/1.1 200 OK
226
226
# Set-Cookie2: Shipping="FedEx"; Version="1"; Path="/acme"
227
- #
227
+ #
228
228
# New cookie reflects shipping method.
229
229
230
230
$cookie = interact($c , " http://www.acme.com/acme/shipping" ,
@@ -234,30 +234,30 @@ ok($cookie =~ /^\$Version="?1"?;/);
234
234
ok($cookie =~ / Part_Number="?Rocket_Launcher_0001"?;\s *\$ Path="\/ acme"/ );
235
235
ok($cookie =~ / Customer="?WILE_E_COYOTE"?;\s *\$ Path="\/ acme"/ );
236
236
237
- #
237
+ #
238
238
# 7. User Agent -> Server
239
- #
239
+ #
240
240
# POST /acme/process HTTP/1.1
241
241
# Cookie: $Version="1";
242
242
# Customer="WILE_E_COYOTE"; $Path="/acme";
243
243
# Part_Number="Rocket_Launcher_0001"; $Path="/acme";
244
244
# Shipping="FedEx"; $Path="/acme"
245
245
# [form data]
246
- #
246
+ #
247
247
# User chooses to process order.
248
- #
248
+ #
249
249
# 8. Server -> User Agent
250
- #
250
+ #
251
251
# HTTP/1.1 200 OK
252
- #
252
+ #
253
253
# Transaction is complete.
254
254
255
255
$cookie = interact($c , " http://www.acme.com/acme/process" );
256
256
print " FINAL COOKIE: $cookie \n " ;
257
257
ok($cookie =~ / Shipping="?FedEx"?;\s *\$ Path="\/ acme"/ );
258
258
ok($cookie =~ / WILE_E_COYOTE/ );
259
259
260
- #
260
+ #
261
261
# The user agent makes a series of requests on the origin server, after
262
262
# each of which it receives a new cookie. All the cookies have the same
263
263
# Path attribute and (default) domain. Because the request URLs all have
@@ -268,7 +268,7 @@ print $c->as_string;
268
268
269
269
270
270
# 5.2 Example 2
271
- #
271
+ #
272
272
# This example illustrates the effect of the Path attribute. All detail
273
273
# of request and response headers has been omitted. Assume the user agent
274
274
# has no stored cookies.
@@ -277,12 +277,12 @@ $c = HTTP::Cookies->new;
277
277
278
278
# Imagine the user agent has received, in response to earlier requests,
279
279
# the response headers
280
- #
280
+ #
281
281
# Set-Cookie2: Part_Number="Rocket_Launcher_0001"; Version="1";
282
282
# Path="/acme"
283
- #
283
+ #
284
284
# and
285
- #
285
+ #
286
286
# Set-Cookie2: Part_Number="Riding_Rocket_0023"; Version="1";
287
287
# Path="/acme/ammo"
288
288
@@ -292,11 +292,11 @@ interact($c, "http://www.acme.com/acme/ammo/specific",
292
292
293
293
# A subsequent request by the user agent to the (same) server for URLs of
294
294
# the form /acme/ammo/... would include the following request header:
295
- #
295
+ #
296
296
# Cookie: $Version="1";
297
297
# Part_Number="Riding_Rocket_0023"; $Path="/acme/ammo";
298
298
# Part_Number="Rocket_Launcher_0001"; $Path="/acme"
299
- #
299
+ #
300
300
# Note that the NAME=VALUE pair for the cookie with the more specific Path
301
301
# attribute, /acme/ammo, comes before the one with the less specific Path
302
302
# attribute, /acme. Further note that the same cookie name appears more
@@ -307,9 +307,9 @@ ok($cookie =~ /Riding_Rocket_0023.*Rocket_Launcher_0001/);
307
307
308
308
# A subsequent request by the user agent to the (same) server for a URL of
309
309
# the form /acme/parts/ would include the following request header:
310
- #
310
+ #
311
311
# Cookie: $Version="1"; Part_Number="Rocket_Launcher_0001"; $Path="/acme"
312
- #
312
+ #
313
313
# Here, the second cookie's Path attribute /acme/ammo is not a prefix of
314
314
# the request URL, /acme/parts/, so the cookie does not get forwarded to
315
315
# the server.
0 commit comments