View Javadoc

1   /*
2    * ====================================================================
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   * ====================================================================
20   *
21   * This software consists of voluntary contributions made by many
22   * individuals on behalf of the Apache Software Foundation.  For more
23   * information on the Apache Software Foundation, please see
24   * <http://www.apache.org/>.
25   *
26   */
27  package org.apache.http.client.protocol;
28  
29  import java.util.Date;
30  
31  import org.apache.http.Header;
32  import org.apache.http.HttpHost;
33  import org.apache.http.HttpRequest;
34  import org.apache.http.HttpRequestInterceptor;
35  import org.apache.http.client.CookieStore;
36  import org.apache.http.client.config.CookieSpecs;
37  import org.apache.http.client.config.RequestConfig;
38  import org.apache.http.config.Lookup;
39  import org.apache.http.config.RegistryBuilder;
40  import org.apache.http.conn.routing.HttpRoute;
41  import org.apache.http.conn.routing.RouteInfo.LayerType;
42  import org.apache.http.conn.routing.RouteInfo.TunnelType;
43  import org.apache.http.cookie.CookieOrigin;
44  import org.apache.http.cookie.CookieSpec;
45  import org.apache.http.cookie.CookieSpecProvider;
46  import org.apache.http.cookie.SM;
47  import org.apache.http.impl.client.BasicCookieStore;
48  import org.apache.http.impl.cookie.BasicClientCookie;
49  import org.apache.http.impl.cookie.BasicClientCookie2;
50  import org.apache.http.impl.cookie.DefaultCookieSpecProvider;
51  import org.apache.http.impl.cookie.IgnoreSpecProvider;
52  import org.apache.http.impl.cookie.NetscapeDraftSpec;
53  import org.apache.http.impl.cookie.NetscapeDraftSpecProvider;
54  import org.apache.http.impl.cookie.RFC2965SpecProvider;
55  import org.apache.http.message.BasicHttpRequest;
56  import org.apache.http.protocol.HttpCoreContext;
57  import org.junit.Assert;
58  import org.junit.Before;
59  import org.junit.Test;
60  
61  public class TestRequestAddCookies {
62  
63      private HttpHost target;
64      private CookieStore cookieStore;
65      private Lookup<CookieSpecProvider> cookieSpecRegistry;
66  
67      @Before
68      public void setUp() {
69          this.target = new HttpHost("localhost.local", 80);
70          this.cookieStore = new BasicCookieStore();
71          final BasicClientCookie2 cookie1 = new BasicClientCookie2("name1", "value1");
72          cookie1.setVersion(1);
73          cookie1.setDomain("localhost.local");
74          cookie1.setPath("/");
75          this.cookieStore.addCookie(cookie1);
76          final BasicClientCookie2 cookie2 = new BasicClientCookie2("name2", "value2");
77          cookie2.setVersion(1);
78          cookie2.setDomain("localhost.local");
79          cookie2.setPath("/");
80          this.cookieStore.addCookie(cookie2);
81  
82          this.cookieSpecRegistry = RegistryBuilder.<CookieSpecProvider>create()
83              .register(CookieSpecs.DEFAULT, new DefaultCookieSpecProvider())
84              .register(CookieSpecs.STANDARD, new RFC2965SpecProvider())
85              .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecProvider())
86              .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecProvider())
87              .build();
88      }
89  
90      @Test(expected=IllegalArgumentException.class)
91      public void testRequestParameterCheck() throws Exception {
92          final HttpClientContext context = HttpClientContext.create();
93          final HttpRequestInterceptor interceptor = new RequestAddCookies();
94          interceptor.process(null, context);
95      }
96  
97      @Test(expected=IllegalArgumentException.class)
98      public void testContextParameterCheck() throws Exception {
99          final HttpRequest request = new BasicHttpRequest("GET", "/");
100         final HttpRequestInterceptor interceptor = new RequestAddCookies();
101         interceptor.process(request, null);
102     }
103 
104     @Test
105     public void testAddCookies() throws Exception {
106         final HttpRequest request = new BasicHttpRequest("GET", "/");
107 
108         final HttpRoute route = new HttpRoute(this.target, null, false);
109 
110         final HttpClientContext context = HttpClientContext.create();
111         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
112         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
113         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
114         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
115 
116         final HttpRequestInterceptor interceptor = new RequestAddCookies();
117         interceptor.process(request, context);
118 
119         final Header[] headers1 = request.getHeaders(SM.COOKIE);
120         Assert.assertNotNull(headers1);
121         Assert.assertEquals(2, headers1.length);
122         Assert.assertEquals("$Version=1; name1=\"value1\"", headers1[0].getValue());
123         Assert.assertEquals("$Version=1; name2=\"value2\"", headers1[1].getValue());
124         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
125         Assert.assertNotNull(headers2);
126         Assert.assertEquals(0, headers2.length);
127 
128         final CookieOrigin cookieOrigin = context.getCookieOrigin();
129         Assert.assertNotNull(cookieOrigin);
130         Assert.assertEquals(this.target.getHostName(), cookieOrigin.getHost());
131         Assert.assertEquals(this.target.getPort(), cookieOrigin.getPort());
132         Assert.assertEquals("/", cookieOrigin.getPath());
133         Assert.assertFalse(cookieOrigin.isSecure());
134     }
135 
136     @Test
137     public void testCookiesForConnectRequest() throws Exception {
138         final HttpRequest request = new BasicHttpRequest("CONNECT", "www.somedomain.com");
139 
140         final HttpRoute route = new HttpRoute(this.target, null, false);
141 
142         final HttpClientContext context = HttpClientContext.create();
143         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
144         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
145         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
146         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
147 
148         final HttpRequestInterceptor interceptor = new RequestAddCookies();
149         interceptor.process(request, context);
150 
151         final Header[] headers1 = request.getHeaders(SM.COOKIE);
152         Assert.assertNotNull(headers1);
153         Assert.assertEquals(0, headers1.length);
154         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
155         Assert.assertNotNull(headers2);
156         Assert.assertEquals(0, headers2.length);
157     }
158 
159     @Test
160     public void testNoCookieStore() throws Exception {
161         final HttpRequest request = new BasicHttpRequest("GET", "/");
162 
163         final HttpRoute route = new HttpRoute(this.target, null, false);
164 
165         final HttpClientContext context = HttpClientContext.create();
166         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
167         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
168         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
169         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
170 
171         final HttpRequestInterceptor interceptor = new RequestAddCookies();
172         interceptor.process(request, context);
173 
174         final Header[] headers1 = request.getHeaders(SM.COOKIE);
175         Assert.assertNotNull(headers1);
176         Assert.assertEquals(0, headers1.length);
177         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
178         Assert.assertNotNull(headers2);
179         Assert.assertEquals(0, headers2.length);
180     }
181 
182     @Test
183     public void testNoCookieSpecRegistry() throws Exception {
184         final HttpRequest request = new BasicHttpRequest("GET", "/");
185 
186         final HttpRoute route = new HttpRoute(this.target, null, false);
187 
188         final HttpClientContext context = HttpClientContext.create();
189         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
190         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
191         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
192         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, null);
193 
194         final HttpRequestInterceptor interceptor = new RequestAddCookies();
195         interceptor.process(request, context);
196 
197         final Header[] headers1 = request.getHeaders(SM.COOKIE);
198         Assert.assertNotNull(headers1);
199         Assert.assertEquals(0, headers1.length);
200         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
201         Assert.assertNotNull(headers2);
202         Assert.assertEquals(0, headers2.length);
203     }
204 
205     @Test
206     public void testNoTargetHost() throws Exception {
207         final HttpRequest request = new BasicHttpRequest("GET", "/");
208 
209         final HttpRoute route = new HttpRoute(this.target, null, false);
210 
211         final HttpClientContext context = HttpClientContext.create();
212         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, null);
213         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
214         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
215         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
216 
217         final HttpRequestInterceptor interceptor = new RequestAddCookies();
218         interceptor.process(request, context);
219 
220         final Header[] headers1 = request.getHeaders(SM.COOKIE);
221         Assert.assertNotNull(headers1);
222         Assert.assertEquals(0, headers1.length);
223         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
224         Assert.assertNotNull(headers2);
225         Assert.assertEquals(0, headers2.length);
226     }
227 
228     @Test
229     public void testNoHttpConnection() throws Exception {
230         final HttpRequest request = new BasicHttpRequest("GET", "/");
231 
232         final HttpClientContext context = HttpClientContext.create();
233         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
234         context.setAttribute(HttpCoreContext.HTTP_CONNECTION, null);
235         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
236         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
237 
238         final HttpRequestInterceptor interceptor = new RequestAddCookies();
239         interceptor.process(request, context);
240 
241         final Header[] headers1 = request.getHeaders(SM.COOKIE);
242         Assert.assertNotNull(headers1);
243         Assert.assertEquals(0, headers1.length);
244         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
245         Assert.assertNotNull(headers2);
246         Assert.assertEquals(0, headers2.length);
247     }
248 
249     @Test
250     public void testAddCookiesUsingExplicitCookieSpec() throws Exception {
251         final HttpRequest request = new BasicHttpRequest("GET", "/");
252         final RequestConfig config = RequestConfig.custom()
253             .setCookieSpec(CookieSpecs.NETSCAPE).build();
254         final HttpRoute route = new HttpRoute(this.target, null, false);
255 
256         final HttpClientContext context = HttpClientContext.create();
257         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
258         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
259         context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
260         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
261         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
262 
263         final HttpRequestInterceptor interceptor = new RequestAddCookies();
264         interceptor.process(request, context);
265 
266         final CookieSpec cookieSpec = context.getCookieSpec();
267         Assert.assertTrue(cookieSpec instanceof NetscapeDraftSpec);
268 
269         final Header[] headers1 = request.getHeaders(SM.COOKIE);
270         Assert.assertNotNull(headers1);
271         Assert.assertEquals(1, headers1.length);
272         Assert.assertEquals("name1=value1; name2=value2", headers1[0].getValue());
273     }
274 
275     @Test
276     public void testAuthScopeInvalidRequestURI() throws Exception {
277         final HttpRequest request = new BasicHttpRequest("GET", "crap:");
278 
279         final HttpRoute route = new HttpRoute(this.target, null, false);
280 
281         final HttpClientContext context = HttpClientContext.create();
282         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
283         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
284         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
285         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
286 
287         final HttpRequestInterceptor interceptor = new RequestAddCookies();
288         interceptor.process(request, context);
289     }
290 
291     @Test
292     public void testAuthScopeRemotePortWhenDirect() throws Exception {
293         final HttpRequest request = new BasicHttpRequest("GET", "/stuff");
294 
295         this.target = new HttpHost("localhost.local");
296         final HttpRoute route = new HttpRoute(new HttpHost("localhost.local", 1234), null, false);
297 
298         final HttpClientContext context = HttpClientContext.create();
299         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
300         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
301         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
302         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
303 
304         final HttpRequestInterceptor interceptor = new RequestAddCookies();
305         interceptor.process(request, context);
306 
307         final CookieOrigin cookieOrigin = context.getCookieOrigin();
308         Assert.assertNotNull(cookieOrigin);
309         Assert.assertEquals(this.target.getHostName(), cookieOrigin.getHost());
310         Assert.assertEquals(1234, cookieOrigin.getPort());
311         Assert.assertEquals("/stuff", cookieOrigin.getPath());
312         Assert.assertFalse(cookieOrigin.isSecure());
313     }
314 
315     @Test
316     public void testAuthDefaultHttpPortWhenProxy() throws Exception {
317         final HttpRequest request = new BasicHttpRequest("GET", "/stuff");
318 
319         this.target = new HttpHost("localhost.local");
320         final HttpRoute route = new HttpRoute(
321                 new HttpHost("localhost.local", 80), null, new HttpHost("localhost", 8888), false);
322 
323         final HttpClientContext context = HttpClientContext.create();
324         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
325         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
326         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
327         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
328 
329         final HttpRequestInterceptor interceptor = new RequestAddCookies();
330         interceptor.process(request, context);
331 
332         final CookieOrigin cookieOrigin = context.getCookieOrigin();
333         Assert.assertNotNull(cookieOrigin);
334         Assert.assertEquals(this.target.getHostName(), cookieOrigin.getHost());
335         Assert.assertEquals(80, cookieOrigin.getPort());
336         Assert.assertEquals("/stuff", cookieOrigin.getPath());
337         Assert.assertFalse(cookieOrigin.isSecure());
338     }
339 
340     @Test
341     public void testAuthDefaultHttpsPortWhenProxy() throws Exception {
342         final HttpRequest request = new BasicHttpRequest("GET", "/stuff");
343 
344         this.target = new HttpHost("localhost", -1, "https");
345         final HttpRoute route = new HttpRoute(
346                 new HttpHost("localhost", 443, "https"), null,
347                 new HttpHost("localhost", 8888), true, TunnelType.TUNNELLED, LayerType.LAYERED);
348 
349         final HttpClientContext context = HttpClientContext.create();
350         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
351         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
352         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
353         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
354 
355         final HttpRequestInterceptor interceptor = new RequestAddCookies();
356         interceptor.process(request, context);
357 
358         final CookieOrigin cookieOrigin = context.getCookieOrigin();
359         Assert.assertNotNull(cookieOrigin);
360         Assert.assertEquals(this.target.getHostName(), cookieOrigin.getHost());
361         Assert.assertEquals(443, cookieOrigin.getPort());
362         Assert.assertEquals("/stuff", cookieOrigin.getPath());
363         Assert.assertTrue(cookieOrigin.isSecure());
364     }
365 
366     @Test
367     public void testExcludeExpiredCookies() throws Exception {
368         final HttpRequest request = new BasicHttpRequest("GET", "/");
369 
370         final BasicClientCookie2 cookie3 = new BasicClientCookie2("name3", "value3");
371         cookie3.setVersion(1);
372         cookie3.setDomain("localhost.local");
373         cookie3.setPath("/");
374         cookie3.setExpiryDate(new Date(System.currentTimeMillis() - (24 * 60 * 60 * 1000)));
375 
376         this.cookieStore.addCookie(cookie3);
377 
378         final HttpRoute route = new HttpRoute(this.target, null, false);
379 
380         final HttpClientContext context = HttpClientContext.create();
381         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
382         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
383         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
384         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
385 
386         final HttpRequestInterceptor interceptor = new RequestAddCookies();
387         interceptor.process(request, context);
388 
389         final Header[] headers1 = request.getHeaders(SM.COOKIE);
390         Assert.assertNotNull(headers1);
391         Assert.assertEquals(2, headers1.length);
392         Assert.assertEquals("$Version=1; name1=\"value1\"", headers1[0].getValue());
393         Assert.assertEquals("$Version=1; name2=\"value2\"", headers1[1].getValue());
394         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
395         Assert.assertNotNull(headers2);
396         Assert.assertEquals(0, headers2.length);
397     }
398 
399     @Test
400     public void testNoMatchingCookies() throws Exception {
401         final HttpRequest request = new BasicHttpRequest("GET", "/");
402 
403         this.cookieStore.clear();
404         final BasicClientCookie cookie3 = new BasicClientCookie("name3", "value3");
405         cookie3.setDomain("www.somedomain.com");
406         cookie3.setPath("/");
407         this.cookieStore.addCookie(cookie3);
408 
409         final HttpRoute route = new HttpRoute(this.target, null, false);
410 
411         final HttpClientContext context = HttpClientContext.create();
412         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
413         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
414         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
415         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
416 
417         final HttpRequestInterceptor interceptor = new RequestAddCookies();
418         interceptor.process(request, context);
419 
420         final Header[] headers1 = request.getHeaders(SM.COOKIE);
421         Assert.assertNotNull(headers1);
422         Assert.assertEquals(0, headers1.length);
423         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
424         Assert.assertNotNull(headers2);
425         Assert.assertEquals(0, headers2.length);
426     }
427 
428     // Helper method
429     private BasicClientCookie makeCookie(final String name, final String value, final String domain, final String path) {
430         final BasicClientCookie cookie = new BasicClientCookie(name, value);
431         cookie.setDomain(domain);
432         cookie.setPath(path);
433         return cookie;
434     }
435 
436     @Test
437     // Test for ordering adapted from test in Commons HC 3.1
438     public void testCookieOrder() throws Exception {
439         final HttpRequest request = new BasicHttpRequest("GET", "/foobar/yada/yada");
440 
441         this.cookieStore.clear();
442 
443         cookieStore.addCookie(makeCookie("nomatch", "value", "localhost.local", "/noway"));
444         cookieStore.addCookie(makeCookie("name2",   "value", "localhost.local", "/foobar/yada"));
445         cookieStore.addCookie(makeCookie("name3",   "value", "localhost.local", "/foobar"));
446         cookieStore.addCookie(makeCookie("name1",   "value", "localhost.local", "/foobar/yada/yada"));
447 
448         final HttpRoute route = new HttpRoute(this.target, null, false);
449 
450         final HttpClientContext context = HttpClientContext.create();
451         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
452         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
453         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
454         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
455 
456         final HttpRequestInterceptor interceptor = new RequestAddCookies();
457         interceptor.process(request, context);
458 
459         final Header[] headers1 = request.getHeaders(SM.COOKIE);
460         Assert.assertNotNull(headers1);
461         Assert.assertEquals(1, headers1.length);
462 
463         Assert.assertEquals("name1=value; name2=value; name3=value", headers1[0].getValue());
464     }
465 
466     @Test
467     public void testAddSpecVersionHeader() throws Exception {
468         final HttpRequest request = new BasicHttpRequest("GET", "/");
469 
470         this.cookieStore.clear();
471         final BasicClientCookie cookie1 = new BasicClientCookie("name1", "value1");
472         cookie1.setVersion(0);
473         cookie1.setDomain("localhost.local");
474         cookie1.setPath("/");
475         this.cookieStore.addCookie(cookie1);
476         final BasicClientCookie cookie2 = new BasicClientCookie("name2", "value2");
477         cookie2.setVersion(0);
478         cookie2.setDomain("localhost.local");
479         cookie2.setPath("/");
480         this.cookieStore.addCookie(cookie2);
481 
482         final HttpRoute route = new HttpRoute(this.target, null, false);
483 
484         final HttpClientContext context = HttpClientContext.create();
485         context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, this.target);
486         context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
487         context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
488         context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
489 
490         final HttpRequestInterceptor interceptor = new RequestAddCookies();
491         interceptor.process(request, context);
492 
493         final Header[] headers1 = request.getHeaders(SM.COOKIE);
494         Assert.assertNotNull(headers1);
495         Assert.assertEquals(1, headers1.length);
496         Assert.assertEquals("name1=value1; name2=value2", headers1[0].getValue());
497         final Header[] headers2 = request.getHeaders(SM.COOKIE2);
498         Assert.assertNotNull(headers2);
499         Assert.assertEquals(1, headers2.length);
500         Assert.assertEquals("$Version=1", headers2[0].getValue());
501     }
502 
503 }