You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Philippe Mouawad <ph...@gmail.com> on 2015/12/01 22:09:57 UTC

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Hello,
Any answer on this question ?
Thanks
Regards

On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hello,
> We're in the process of migrating JMeter to last HttpClient 4.5.1.
>
> We are now migrating the CookieManager to remove all deprecated code.
> To test this class, we had a JUNIT class :
>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>
> Before migration, it was still testing HC3 version.
> So we first switched to HC4.23 and noticed some failures:
>
>    -
>    https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L168
>
>
>
>    -
>    https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L280
>
> Not failing with last version
>
>    -
>    https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L367
>
> It appears matches returns true for ignorepolicy, IMHO, it should not,
> it's a change in behaviour
>
>    -
>    https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L314
>
>
> Then we migrated to HC4.5.1 and noticed an additional failure on:
>
>    -
>    https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L76
>    -
>    https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L159
>
> Are those changes related to changes in RFC6265 or are they regressions ?
>
> I think this one is a regression:
>
>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L367
>
> 2 Failures (testCookies1, testCookies2) seem to be related to multiple
> cookies parsing:
>
>    - test1=1; comment=\"how,now\", test2=2; version=1
>    - test1=1;secure, test2=2;secure
>
> Reading section http://tools.ietf.org/html/rfc6265#section-5.2, I wonder
> if multi values set cookie is allowed ?
> --
> Regards.
> Philippe M.
>

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
For info.
Thoughts ?

On Friday, December 4, 2015, Philippe Mouawad <ph...@gmail.com>
wrote:

> Thanks Oleg.
> But look at
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368,
> it concerns IGNORE_POLICY
>
> I really think there is at least one bug.
> Regards
>
> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <olegk@apache.org
> <javascript:_e(%7B%7D,'cvml','olegk@apache.org');>> wrote:
>
>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>> > Hi Oleg,
>> > Thanks for answer.
>> >
>> > Find my answers inline.
>> > Regards
>> >
>> > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <olegk@apache.org
>> <javascript:_e(%7B%7D,'cvml','olegk@apache.org');>> wrote:
>> >
>> > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>> > > > Hello,
>> > > > Any answer on this question ?
>> > > > Thanks
>> > > > Regards
>> > > >
>> > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>> > > > philippe.mouawad@gmail.com
>> <javascript:_e(%7B%7D,'cvml','philippe.mouawad@gmail.com');>> wrote:
>> > > >
>> > > > > Hello,
>> > > > > We're in the process of migrating JMeter to last HttpClient 4.5.1.
>> > > > >
>> > > > > We are now migrating the CookieManager to remove all deprecated
>> code.
>> > > > > To test this class, we had a JUNIT class :
>> > > > >
>> > > > >
>> > >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>> > > > >
>> > > > > Before migration, it was still testing HC3 version.
>> > > > > So we first switched to HC4.23 and noticed some failures:
>> > > > >
>> > >
>> > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>> >
>> >
>> > As I wrote, first we switched our JUnit tests to use HC4 Implementation
>> of
>> > CookieHandler and used 4.2.3, we got some failures compared to HC3.
>> >
>> > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures all
>> > detailed in initial mail.
>> >
>> >
>> > What policy does
>> > > CookeManager use internally?
>> > >
>> > It depends on tests, you can see in the code that depending on test
>> method
>> > we set different Policy to test them.
>> >
>>
>> You ought to be using RFC6265 policy either in strict or relaxed mode
>> and nothing else. All other policies have been marked as obsolete and
>> have already been removed in 5.0 (trunk).
>>
>> Oleg
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> <javascript:_e(%7B%7D,'cvml','httpclient-users-unsubscribe@hc.apache.org');>
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> <javascript:_e(%7B%7D,'cvml','httpclient-users-help@hc.apache.org');>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>

-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
Regarding the other failing methods:


   - testCookiePolicy2109 => Issue is in JMeter HC4 handler when we switch
   to/from org.apache.http.cookie.Cookie <=>
   org.apache.jmeter.protocol.http.control.Cookie.

There is at least an issue with not testing:

((BasicClientCookie)cookie).containsAttribute(ClientCookie.PATH_ATTR),

((BasicClientCookie)cookie).containsAttribute(ClientCookie.DOMAIN_ATTR));

But I have not found yet the problem

   - testCookies1 => Same problem probably
   - testCookies2 => It appears test is wrong as per Oleg last answer.


I think we need to fix CookieManager and upgrade to HC4.5.2 before
releasing 2.14.

Regards

On Mon, Dec 14, 2015 at 9:55 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi,
> For info, Oleg was very helpful and has updated the 3 bugs:
> TestCookieManager#testCookiePolicyIgnore =>
> https://issues.apache.org/jira/browse/HTTPCLIENT-1704 => Fixed in 4.5.2
> TestCookieManager#testCookieOrdering1 =>
> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 => I mixed up
> between testCookiePolicy2109 and testCookieOrdering1, so I closed my bug
> after he reported an issue in my test case, we'll have to submit another
> test case for testCookiePolicy2109
> TestCookieManager#testSendCookie2 =>
> https://issues.apache.org/jira/browse/HTTPCLIENT-1706 => Not a bug as per
> RFC6265 contract, as Oleg nicely pointed at
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------
>
> As the test case in question only assigns effective domain but does not
> assign the actual attribute value the RFC6265 policy rejects the coolie due
> to a requirement of section 4.1.2.3
>
> 4.1.2.3.
> ...
> If the server omits the Domain attribute, the user
> agent will return the cookie only to the origin server.
>
> WARNING: Some existing user agents treat an absent Domain
> attribute as if the Domain attribute were present and contained
> the current host name. For example, if example.com returns a Set-
> Cookie header without a Domain attribute, these user agent will
> erroneously send the cookie to www.example.com as well.
>
> The test case passes if the following line is added to the test setup
>
> cookie1.setAttribute(ClientCookie.DOMAIN_ATTR, ".apache.org");
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------
>
> Regards
>
>
>
>
>
> On Mon, Dec 14, 2015 at 9:41 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
>
>> Hello Oleg,
>> Thanks .
>>
>> Here it is:
>>
>> /*
>>  * ====================================================================
>>  * 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
>>  * "License"); 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
>>  * "AS IS" 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.
>>  * ====================================================================
>>  *
>>  * This software consists of voluntary contributions made by many
>>  * individuals on behalf of the Apache Software Foundation.  For more
>>  * information on the Apache Software Foundation, please see
>>  * <http://www.apache.org/>.
>>  *
>>  */
>> package org.apache.http.client.protocol;
>>
>> import java.util.List;
>>
>> import org.apache.http.Header;
>> import org.apache.http.HttpResponse;
>> import org.apache.http.HttpResponseInterceptor;
>> import org.apache.http.HttpVersion;
>> import org.apache.http.client.CookieStore;
>> import org.apache.http.cookie.Cookie;
>> import org.apache.http.cookie.CookieOrigin;
>> import org.apache.http.cookie.CookieSpec;
>> import org.apache.http.cookie.SM;
>> import org.apache.http.impl.client.BasicCookieStore;
>> import org.apache.http.impl.cookie.DefaultCookieSpec;
>> import org.apache.http.message.BasicHttpResponse;
>> import org.apache.http.util.Asserts;
>> import org.junit.Assert;
>> import org.junit.Before;
>> import org.junit.Test;
>>
>> public class TestResponseProcessCookies {
>>
>>     private CookieOrigin cookieOrigin;
>>     private CookieSpec cookieSpec;
>>     private CookieStore cookieStore;
>>
>>     @Before
>>     public void setUp() throws Exception {
>>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/", false);
>>         this.cookieSpec = new DefaultCookieSpec();
>>         this.cookieStore = new BasicCookieStore();
>>     }
>>
>>     @Test(expected=IllegalArgumentException.class)
>>     public void testResponseParameterCheck() throws Exception {
>>         final HttpClientContext context = HttpClientContext.create();
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(null, context);
>>     }
>>
>>     @Test(expected=IllegalArgumentException.class)
>>     public void testContextParameterCheck() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, null);
>>     }
>>
>>     @Test
>>     public void testParseMultipleCookies() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
>> test2=2; version=1");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> this.cookieOrigin);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> this.cookieSpec);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> this.cookieStore);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         Assert.assertNotNull(cookies);
>>         Assert.assertEquals(1, cookies.size());
>>         final Cookie cookie = cookies.get(0);
>>         Assert.assertEquals(0, cookie.getVersion());
>>         Assert.assertEquals("name1", cookie.getName());
>>         Assert.assertEquals("value1", cookie.getValue());
>>         Assert.assertEquals("localhost", cookie.getDomain());
>>         Assert.assertEquals("/", cookie.getPath());
>>
>>     }
>>
>>     @Test
>>     public void testParseCookies() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> this.cookieOrigin);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> this.cookieSpec);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> this.cookieStore);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>         StringBuilder sbHdr = new StringBuilder();
>>         for (Header header : lstHdr) {
>>             sbHdr.append(header.getValue());
>>         }
>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>> sbHdr.toString());
>>     }
>>     @Test
>>     public void testParseCookies2() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>> test2=2;secure");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> this.cookieOrigin);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> this.cookieSpec);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> this.cookieStore);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>         StringBuilder sbHdr = new StringBuilder();
>>         for (Header header : lstHdr) {
>>             sbHdr.append(header.getValue());
>>         }
>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>> sbHdr.toString());
>>     }
>>
>>     @Test
>>     public void testNoCookieOrigin() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> this.cookieSpec);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> this.cookieStore);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         Assert.assertNotNull(cookies);
>>         Assert.assertEquals(0, cookies.size());
>>     }
>>
>>     @Test
>>     public void testNoCookieSpec() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> this.cookieOrigin);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> this.cookieStore);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         Assert.assertNotNull(cookies);
>>         Assert.assertEquals(0, cookies.size());
>>     }
>>
>>     @Test
>>     public void testNoCookieStore() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> this.cookieOrigin);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> this.cookieSpec);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         Assert.assertNotNull(cookies);
>>         Assert.assertEquals(0, cookies.size());
>>     }
>>
>>     @Test
>>     public void testSetCookie2OverrideSetCookie() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> this.cookieOrigin);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> this.cookieSpec);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> this.cookieStore);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         Assert.assertNotNull(cookies);
>>         Assert.assertEquals(1, cookies.size());
>>         final Cookie cookie = cookies.get(0);
>>         Assert.assertEquals(1, cookie.getVersion());
>>         Assert.assertEquals("name1", cookie.getName());
>>         Assert.assertEquals("value2", cookie.getValue());
>>         Assert.assertEquals("localhost.local", cookie.getDomain());
>>         Assert.assertEquals("/", cookie.getPath());
>>     }
>>
>>     @Test
>>     public void testInvalidHeader() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> this.cookieOrigin);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> this.cookieSpec);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> this.cookieStore);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         Assert.assertNotNull(cookies);
>>         Assert.assertTrue(cookies.isEmpty());
>>     }
>>
>>     @Test
>>     public void testCookieRejected() throws Exception {
>>         final HttpResponse response = new
>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>> www.somedomain.com; Version=1");
>>
>>         final HttpClientContext context = HttpClientContext.create();
>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> this.cookieOrigin);
>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> this.cookieSpec);
>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> this.cookieStore);
>>
>>         final HttpResponseInterceptor interceptor = new
>> ResponseProcessCookies();
>>         interceptor.process(response, context);
>>
>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>         Assert.assertNotNull(cookies);
>>         Assert.assertTrue(cookies.isEmpty());
>>     }
>>
>> }
>>
>>
>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>>
>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>>> > Finally, for those  2 I am not sure  as per RFC6265, to use them , put
>>> code
>>> > in org.apache.http.client.protocol.TestResponseProcessCookies.
>>> > They worked with HC3 but it does not mean they should work with HC4,
>>> but I
>>> > would like a confirmation:
>>> >
>>>
>>> I cannot get the tests to compile due to missing instance variables
>>> cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
>>> post the complete class.
>>>
>>> Oleg
>>>
>>>
>>> >
>>> >     @Test
>>> >     public void testParseCookies() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>> >         StringBuilder sbHdr = new StringBuilder();
>>> >         for (Header header : lstHdr) {
>>> >             sbHdr.append(header.getValue());
>>> >         }
>>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>>> sbHdr.toString());
>>> >     }
>>> >     @Test
>>> >     public void testParseCookies2() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>> test2=2;secure");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>> >         StringBuilder sbHdr = new StringBuilder();
>>> >         for (Header header : lstHdr) {
>>> >             sbHdr.append(header.getValue());
>>> >         }
>>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>>> sbHdr.toString());
>>> >     }
>>> >
>>> > Thanks
>>> >
>>> > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>>> > philippe.mouawad@gmail.com> wrote:
>>> >
>>> > > Hi,
>>> > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with
>>> a Test
>>> > > case in it to show issue with Domain starting with ".".
>>> > >
>>> > >
>>> > > Regards
>>> > >
>>> > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>>> > > philippe.mouawad@gmail.com> wrote:
>>> > >
>>> > >> Hi Oleg,
>>> > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to
>>> show
>>> > >> issue with Cookie Header ordering.
>>> > >>
>>> > >> Regards
>>> > >>
>>> > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>>> > >> philippe.mouawad@gmail.com> wrote:
>>> > >>
>>> > >>> Hi,
>>> > >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>>> with
>>> > >>> JUnit test case so that you understand the difference we have.
>>> > >>>
>>> > >>> Regards
>>> > >>>
>>> > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>>> olegk@apache.org>
>>> > >>> wrote:
>>> > >>>
>>> > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>> > >>>> > Thanks Oleg.
>>> > >>>> > But look at
>>> > >>>> >
>>> > >>>>
>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>> > >>>> ,
>>> > >>>> > it concerns IGNORE_POLICY
>>> > >>>> >
>>> > >>>> > I really think there is at least one bug.
>>> > >>>> > Regards
>>> > >>>> >
>>> > >>>>
>>> > >>>> Sure thing. All these issues may well be due to bugs in HC. Could
>>> you
>>> > >>>> please though reproduce them with unit tests that do not involve
>>> JMeter
>>> > >>>> specific code?
>>> > >>>>
>>> > >>>> Oleg
>>> > >>>>
>>> > >>>>
>>> > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>>> olegk@apache.org>
>>> > >>>> wrote:
>>> > >>>> >
>>> > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>> > >>>> > > > Hi Oleg,
>>> > >>>> > > > Thanks for answer.
>>> > >>>> > > >
>>> > >>>> > > > Find my answers inline.
>>> > >>>> > > > Regards
>>> > >>>> > > >
>>> > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>> > >>>> olegk@apache.org>
>>> > >>>> > > wrote:
>>> > >>>> > > >
>>> > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>>> > >>>> > > > > > Hello,
>>> > >>>> > > > > > Any answer on this question ?
>>> > >>>> > > > > > Thanks
>>> > >>>> > > > > > Regards
>>> > >>>> > > > > >
>>> > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>> > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
>>> > >>>> > > > > >
>>> > >>>> > > > > > > Hello,
>>> > >>>> > > > > > > We're in the process of migrating JMeter to last
>>> HttpClient
>>> > >>>> 4.5.1.
>>> > >>>> > > > > > >
>>> > >>>> > > > > > > We are now migrating the CookieManager to remove all
>>> > >>>> deprecated
>>> > >>>> > > code.
>>> > >>>> > > > > > > To test this class, we had a JUNIT class :
>>> > >>>> > > > > > >
>>> > >>>> > > > > > >
>>> > >>>> > > > >
>>> > >>>> > >
>>> > >>>>
>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>> > >>>> > > > > > >
>>> > >>>> > > > > > > Before migration, it was still testing HC3 version.
>>> > >>>> > > > > > > So we first switched to HC4.23 and noticed some
>>> failures:
>>> > >>>> > > > > > >
>>> > >>>> > > > >
>>> > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>> > >>>> > > >
>>> > >>>> > > >
>>> > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>>> > >>>> Implementation
>>> > >>>> > > of
>>> > >>>> > > > CookieHandler and used 4.2.3, we got some failures compared
>>> to
>>> > >>>> HC3.
>>> > >>>> > > >
>>> > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>>> failures
>>> > >>>> all
>>> > >>>> > > > detailed in initial mail.
>>> > >>>> > > >
>>> > >>>> > > >
>>> > >>>> > > > What policy does
>>> > >>>> > > > > CookeManager use internally?
>>> > >>>> > > > >
>>> > >>>> > > > It depends on tests, you can see in the code that depending
>>> on
>>> > >>>> test
>>> > >>>> > > method
>>> > >>>> > > > we set different Policy to test them.
>>> > >>>> > > >
>>> > >>>> > >
>>> > >>>> > > You ought to be using RFC6265 policy either in strict or
>>> relaxed
>>> > >>>> mode
>>> > >>>> > > and nothing else. All other policies have been marked as
>>> obsolete
>>> > >>>> and
>>> > >>>> > > have already been removed in 5.0 (trunk).
>>> > >>>> > >
>>> > >>>> > > Oleg
>>> > >>>> > >
>>> > >>>> > >
>>> > >>>> > >
>>> > >>>>
>>> ---------------------------------------------------------------------
>>> > >>>> > > To unsubscribe, e-mail:
>>> httpclient-users-unsubscribe@hc.apache.org
>>> > >>>> > > For additional commands, e-mail:
>>> > >>>> httpclient-users-help@hc.apache.org
>>> > >>>> > >
>>> > >>>> > >
>>> > >>>> >
>>> > >>>> >
>>> > >>>>
>>> > >>>>
>>> > >>>>
>>> > >>>>
>>> ---------------------------------------------------------------------
>>> > >>>> To unsubscribe, e-mail:
>>> httpclient-users-unsubscribe@hc.apache.org
>>> > >>>> For additional commands, e-mail:
>>> httpclient-users-help@hc.apache.org
>>> > >>>>
>>> > >>>>
>>> > >>>
>>> > >>>
>>> > >>> --
>>> > >>> Cordialement.
>>> > >>> Philippe Mouawad.
>>> > >>>
>>> > >>>
>>> > >>>
>>> > >>
>>> > >>
>>> > >> --
>>> > >> Cordialement.
>>> > >> Philippe Mouawad.
>>> > >>
>>> > >>
>>> > >>
>>> > >
>>> > >
>>> > > --
>>> > > Cordialement.
>>> > > Philippe Mouawad.
>>> > >
>>> > >
>>> > >
>>> >
>>> >
>>>
>>>
>>>
>>
>>
>> --
>> Cordialement.
>> Philippe Mouawad.
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
For info, Oleg was very helpful and has updated the 3 bugs:
TestCookieManager#testCookiePolicyIgnore =>
https://issues.apache.org/jira/browse/HTTPCLIENT-1704 => Fixed in 4.5.2
TestCookieManager#testCookieOrdering1 =>
https://issues.apache.org/jira/browse/HTTPCLIENT-1705 => I mixed up between
testCookiePolicy2109 and testCookieOrdering1, so I closed my bug after he
reported an issue in my test case, we'll have to submit another test case
for testCookiePolicy2109
TestCookieManager#testSendCookie2 =>
https://issues.apache.org/jira/browse/HTTPCLIENT-1706 => Not a bug as per
RFC6265 contract, as Oleg nicely pointed at

------------------------------------------------------------------------------------------------------------------------------------------------

As the test case in question only assigns effective domain but does not
assign the actual attribute value the RFC6265 policy rejects the coolie due
to a requirement of section 4.1.2.3

4.1.2.3.
...
If the server omits the Domain attribute, the user
agent will return the cookie only to the origin server.

WARNING: Some existing user agents treat an absent Domain
attribute as if the Domain attribute were present and contained
the current host name. For example, if example.com returns a Set-
Cookie header without a Domain attribute, these user agent will
erroneously send the cookie to www.example.com as well.

The test case passes if the following line is added to the test setup

cookie1.setAttribute(ClientCookie.DOMAIN_ATTR, ".apache.org");

------------------------------------------------------------------------------------------------------------------------------------------------

Regards





On Mon, Dec 14, 2015 at 9:41 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hello Oleg,
> Thanks .
>
> Here it is:
>
> /*
>  * ====================================================================
>  * 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
>  * "License"); 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
>  * "AS IS" 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.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  */
> package org.apache.http.client.protocol;
>
> import java.util.List;
>
> import org.apache.http.Header;
> import org.apache.http.HttpResponse;
> import org.apache.http.HttpResponseInterceptor;
> import org.apache.http.HttpVersion;
> import org.apache.http.client.CookieStore;
> import org.apache.http.cookie.Cookie;
> import org.apache.http.cookie.CookieOrigin;
> import org.apache.http.cookie.CookieSpec;
> import org.apache.http.cookie.SM;
> import org.apache.http.impl.client.BasicCookieStore;
> import org.apache.http.impl.cookie.DefaultCookieSpec;
> import org.apache.http.message.BasicHttpResponse;
> import org.apache.http.util.Asserts;
> import org.junit.Assert;
> import org.junit.Before;
> import org.junit.Test;
>
> public class TestResponseProcessCookies {
>
>     private CookieOrigin cookieOrigin;
>     private CookieSpec cookieSpec;
>     private CookieStore cookieStore;
>
>     @Before
>     public void setUp() throws Exception {
>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/", false);
>         this.cookieSpec = new DefaultCookieSpec();
>         this.cookieStore = new BasicCookieStore();
>     }
>
>     @Test(expected=IllegalArgumentException.class)
>     public void testResponseParameterCheck() throws Exception {
>         final HttpClientContext context = HttpClientContext.create();
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(null, context);
>     }
>
>     @Test(expected=IllegalArgumentException.class)
>     public void testContextParameterCheck() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, null);
>     }
>
>     @Test
>     public void testParseMultipleCookies() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
> test2=2; version=1");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(1, cookies.size());
>         final Cookie cookie = cookies.get(0);
>         Assert.assertEquals(0, cookie.getVersion());
>         Assert.assertEquals("name1", cookie.getName());
>         Assert.assertEquals("value1", cookie.getValue());
>         Assert.assertEquals("localhost", cookie.getDomain());
>         Assert.assertEquals("/", cookie.getPath());
>
>     }
>
>     @Test
>     public void testParseCookies() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
>     }
>     @Test
>     public void testParseCookies2() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> test2=2;secure");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
>     }
>
>     @Test
>     public void testNoCookieOrigin() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
>
>     @Test
>     public void testNoCookieSpec() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
>
>     @Test
>     public void testNoCookieStore() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
>
>     @Test
>     public void testSetCookie2OverrideSetCookie() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(1, cookies.size());
>         final Cookie cookie = cookies.get(0);
>         Assert.assertEquals(1, cookie.getVersion());
>         Assert.assertEquals("name1", cookie.getName());
>         Assert.assertEquals("value2", cookie.getValue());
>         Assert.assertEquals("localhost.local", cookie.getDomain());
>         Assert.assertEquals("/", cookie.getPath());
>     }
>
>     @Test
>     public void testInvalidHeader() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertTrue(cookies.isEmpty());
>     }
>
>     @Test
>     public void testCookieRejected() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> www.somedomain.com; Version=1");
>
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
>
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
>
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertTrue(cookies.isEmpty());
>     }
>
> }
>
>
> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>> > Finally, for those  2 I am not sure  as per RFC6265, to use them , put
>> code
>> > in org.apache.http.client.protocol.TestResponseProcessCookies.
>> > They worked with HC3 but it does not mean they should work with HC4,
>> but I
>> > would like a confirmation:
>> >
>>
>> I cannot get the tests to compile due to missing instance variables
>> cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
>> post the complete class.
>>
>> Oleg
>>
>>
>> >
>> >     @Test
>> >     public void testParseCookies() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> >         StringBuilder sbHdr = new StringBuilder();
>> >         for (Header header : lstHdr) {
>> >             sbHdr.append(header.getValue());
>> >         }
>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> sbHdr.toString());
>> >     }
>> >     @Test
>> >     public void testParseCookies2() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>> test2=2;secure");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> >         StringBuilder sbHdr = new StringBuilder();
>> >         for (Header header : lstHdr) {
>> >             sbHdr.append(header.getValue());
>> >         }
>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> sbHdr.toString());
>> >     }
>> >
>> > Thanks
>> >
>> > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>> > philippe.mouawad@gmail.com> wrote:
>> >
>> > > Hi,
>> > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a
>> Test
>> > > case in it to show issue with Domain starting with ".".
>> > >
>> > >
>> > > Regards
>> > >
>> > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>> > > philippe.mouawad@gmail.com> wrote:
>> > >
>> > >> Hi Oleg,
>> > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to
>> show
>> > >> issue with Cookie Header ordering.
>> > >>
>> > >> Regards
>> > >>
>> > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>> > >> philippe.mouawad@gmail.com> wrote:
>> > >>
>> > >>> Hi,
>> > >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>> with
>> > >>> JUnit test case so that you understand the difference we have.
>> > >>>
>> > >>> Regards
>> > >>>
>> > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <olegk@apache.org
>> >
>> > >>> wrote:
>> > >>>
>> > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>> > >>>> > Thanks Oleg.
>> > >>>> > But look at
>> > >>>> >
>> > >>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>> > >>>> ,
>> > >>>> > it concerns IGNORE_POLICY
>> > >>>> >
>> > >>>> > I really think there is at least one bug.
>> > >>>> > Regards
>> > >>>> >
>> > >>>>
>> > >>>> Sure thing. All these issues may well be due to bugs in HC. Could
>> you
>> > >>>> please though reproduce them with unit tests that do not involve
>> JMeter
>> > >>>> specific code?
>> > >>>>
>> > >>>> Oleg
>> > >>>>
>> > >>>>
>> > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>> olegk@apache.org>
>> > >>>> wrote:
>> > >>>> >
>> > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>> > >>>> > > > Hi Oleg,
>> > >>>> > > > Thanks for answer.
>> > >>>> > > >
>> > >>>> > > > Find my answers inline.
>> > >>>> > > > Regards
>> > >>>> > > >
>> > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>> > >>>> olegk@apache.org>
>> > >>>> > > wrote:
>> > >>>> > > >
>> > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>> > >>>> > > > > > Hello,
>> > >>>> > > > > > Any answer on this question ?
>> > >>>> > > > > > Thanks
>> > >>>> > > > > > Regards
>> > >>>> > > > > >
>> > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>> > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
>> > >>>> > > > > >
>> > >>>> > > > > > > Hello,
>> > >>>> > > > > > > We're in the process of migrating JMeter to last
>> HttpClient
>> > >>>> 4.5.1.
>> > >>>> > > > > > >
>> > >>>> > > > > > > We are now migrating the CookieManager to remove all
>> > >>>> deprecated
>> > >>>> > > code.
>> > >>>> > > > > > > To test this class, we had a JUNIT class :
>> > >>>> > > > > > >
>> > >>>> > > > > > >
>> > >>>> > > > >
>> > >>>> > >
>> > >>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>> > >>>> > > > > > >
>> > >>>> > > > > > > Before migration, it was still testing HC3 version.
>> > >>>> > > > > > > So we first switched to HC4.23 and noticed some
>> failures:
>> > >>>> > > > > > >
>> > >>>> > > > >
>> > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>> > >>>> > > >
>> > >>>> > > >
>> > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>> > >>>> Implementation
>> > >>>> > > of
>> > >>>> > > > CookieHandler and used 4.2.3, we got some failures compared
>> to
>> > >>>> HC3.
>> > >>>> > > >
>> > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>> failures
>> > >>>> all
>> > >>>> > > > detailed in initial mail.
>> > >>>> > > >
>> > >>>> > > >
>> > >>>> > > > What policy does
>> > >>>> > > > > CookeManager use internally?
>> > >>>> > > > >
>> > >>>> > > > It depends on tests, you can see in the code that depending
>> on
>> > >>>> test
>> > >>>> > > method
>> > >>>> > > > we set different Policy to test them.
>> > >>>> > > >
>> > >>>> > >
>> > >>>> > > You ought to be using RFC6265 policy either in strict or
>> relaxed
>> > >>>> mode
>> > >>>> > > and nothing else. All other policies have been marked as
>> obsolete
>> > >>>> and
>> > >>>> > > have already been removed in 5.0 (trunk).
>> > >>>> > >
>> > >>>> > > Oleg
>> > >>>> > >
>> > >>>> > >
>> > >>>> > >
>> > >>>>
>> ---------------------------------------------------------------------
>> > >>>> > > To unsubscribe, e-mail:
>> httpclient-users-unsubscribe@hc.apache.org
>> > >>>> > > For additional commands, e-mail:
>> > >>>> httpclient-users-help@hc.apache.org
>> > >>>> > >
>> > >>>> > >
>> > >>>> >
>> > >>>> >
>> > >>>>
>> > >>>>
>> > >>>>
>> > >>>>
>> ---------------------------------------------------------------------
>> > >>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > >>>> For additional commands, e-mail:
>> httpclient-users-help@hc.apache.org
>> > >>>>
>> > >>>>
>> > >>>
>> > >>>
>> > >>> --
>> > >>> Cordialement.
>> > >>> Philippe Mouawad.
>> > >>>
>> > >>>
>> > >>>
>> > >>
>> > >>
>> > >> --
>> > >> Cordialement.
>> > >> Philippe Mouawad.
>> > >>
>> > >>
>> > >>
>> > >
>> > >
>> > > --
>> > > Cordialement.
>> > > Philippe Mouawad.
>> > >
>> > >
>> > >
>> >
>> >
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Thanks Oleg,
Did you have time to look at my JIRA HTTPCLIENT-1705 ?

Thanks
Regards

On Fri, Dec 18, 2015 at 10:51 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Wed, 2015-12-16 at 21:26 +0100, Philippe Mouawad wrote:
> > Hi Oleg,
> > First, big thanks for your help on this, it is really valuable ! And I
> > really appreciate your patience .
> > Second, I  made a mistake in my test case of HTTPCLIENT-1705 JIRA issue,
> > which I fixed and reuploaded tonight few seconds ago.
> > Third, we wanted to release a version by either end of year or begining
> of
> > next year.
> >
>
> I'll try to get 4.5.2 released in Jan 2016, but do not take it as a
> promise. It may take longer unless someone else volunteers to RM the
> release.
>
> > Is migration to HC5.0 a big thing ? Do you advise to target 4.5.2 or 5.0
> ?
> > the alpha state of 5.0 seems risky to me.
> >
>
> Yes, it will be a big thing. You should not even concern yourself with
> HC 5.0 unless you want to contribute to its development.
>
> Oleg
>
>
> > Thanks
> > Regards
> > Philippe
> >
> >
> > On Wed, Dec 16, 2015 at 1:57 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Tue, 2015-12-15 at 14:16 +0100, Philippe Mouawad wrote:
> > > > Hi ,
> > > > One last question, when is release of 4.5.2 expected as it fixes 2
> bugs
> > > we
> > > > are facing in JMeter.
> > > >
> > > > Thanks
> > > > Regards
> > > >
> > >
> > > Philippe
> > >
> > > I was not planning to do HC 4.5.2 any time soon. I would very much
> > > rather get the first alpha of HC 5.0. How soon do you need it?
> > >
> > > Oleg
> > >
> > >
> > > > On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> > > > philippe.mouawad@gmail.com> wrote:
> > > >
> > > > >
> > > > >
> > > > > On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <
> olegk@apache.org>
> > > > > wrote:
> > > > >
> > > > >> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> > > > >> > Hello Oleg,
> > > > >> > Thanks .
> > > > >> >
> > > > >>
> > > > >> Test case #testParseCookies
> > > > >>
> > > > >> The rest case does not look right to me. I am not sure I
> understand
> > > what
> > > > >> you are trying to test here.
> > > > >>
> > > > > Indeed, bad copy paste.
> > > > >
> > > > > The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is
> on
> > > > > JMeter side.
> > > > >
> > > > >>
> > > > >> Test case #testParseCookies
> > > > >>
> > > > >>
> > > > >
> > > > >> The cookie in question does not have a version attribute
> mandatory for
> > > > >> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed
> as
> > > > >> Netscape style cookie in which case comma is not considered a
> valid
> > > > >> header element delimiter and is treated as normal character.
> > > > >>
> > > > >
> > > > > Thanks for explanation.
> > > > > Note that test case worked fine in HC3. Was it a bug in HC3 ?
> > > > >
> > > > >
> > > > >>
> > > > >> Oleg
> > > > >>
> > > > >>
> > > > >> > Here it is:
> > > > >> >
> > > > >> > /*
> > > > >> >  *
> > > ====================================================================
> > > > >> >  * 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
> > > > >> >  * "License"); 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
> > > > >> >  * "AS IS" 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.
> > > > >> >  *
> > > ====================================================================
> > > > >> >  *
> > > > >> >  * This software consists of voluntary contributions made by
> many
> > > > >> >  * individuals on behalf of the Apache Software Foundation.  For
> > > more
> > > > >> >  * information on the Apache Software Foundation, please see
> > > > >> >  * <http://www.apache.org/>.
> > > > >> >  *
> > > > >> >  */
> > > > >> > package org.apache.http.client.protocol;
> > > > >> >
> > > > >> > import java.util.List;
> > > > >> >
> > > > >> > import org.apache.http.Header;
> > > > >> > import org.apache.http.HttpResponse;
> > > > >> > import org.apache.http.HttpResponseInterceptor;
> > > > >> > import org.apache.http.HttpVersion;
> > > > >> > import org.apache.http.client.CookieStore;
> > > > >> > import org.apache.http.cookie.Cookie;
> > > > >> > import org.apache.http.cookie.CookieOrigin;
> > > > >> > import org.apache.http.cookie.CookieSpec;
> > > > >> > import org.apache.http.cookie.SM;
> > > > >> > import org.apache.http.impl.client.BasicCookieStore;
> > > > >> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> > > > >> > import org.apache.http.message.BasicHttpResponse;
> > > > >> > import org.apache.http.util.Asserts;
> > > > >> > import org.junit.Assert;
> > > > >> > import org.junit.Before;
> > > > >> > import org.junit.Test;
> > > > >> >
> > > > >> > public class TestResponseProcessCookies {
> > > > >> >
> > > > >> >     private CookieOrigin cookieOrigin;
> > > > >> >     private CookieSpec cookieSpec;
> > > > >> >     private CookieStore cookieStore;
> > > > >> >
> > > > >> >     @Before
> > > > >> >     public void setUp() throws Exception {
> > > > >> >         this.cookieOrigin = new CookieOrigin("localhost", 80,
> "/",
> > > > >> false);
> > > > >> >         this.cookieSpec = new DefaultCookieSpec();
> > > > >> >         this.cookieStore = new BasicCookieStore();
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test(expected=IllegalArgumentException.class)
> > > > >> >     public void testResponseParameterCheck() throws Exception {
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(null, context);
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test(expected=IllegalArgumentException.class)
> > > > >> >     public void testContextParameterCheck() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, null);
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testParseMultipleCookies() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;
> > > comment=\"how,now\",
> > > > >> > test2=2; version=1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(1, cookies.size());
> > > > >> >         final Cookie cookie = cookies.get(0);
> > > > >> >         Assert.assertEquals(0, cookie.getVersion());
> > > > >> >         Assert.assertEquals("name1", cookie.getName());
> > > > >> >         Assert.assertEquals("value1", cookie.getValue());
> > > > >> >         Assert.assertEquals("localhost", cookie.getDomain());
> > > > >> >         Assert.assertEquals("/", cookie.getPath());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testParseCookies() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > > >> >         StringBuilder sbHdr = new StringBuilder();
> > > > >> >         for (Header header : lstHdr) {
> > > > >> >             sbHdr.append(header.getValue());
> > > > >> >         }
> > > > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > > >> sbHdr.toString());
> > > > >> >     }
> > > > >> >     @Test
> > > > >> >     public void testParseCookies2() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > > >> test2=2;secure");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > > >> >         StringBuilder sbHdr = new StringBuilder();
> > > > >> >         for (Header header : lstHdr) {
> > > > >> >             sbHdr.append(header.getValue());
> > > > >> >         }
> > > > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > > >> sbHdr.toString());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testNoCookieOrigin() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> null);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(0, cookies.size());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testNoCookieSpec() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> null);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(0, cookies.size());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testNoCookieStore() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> null);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(0, cookies.size());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testSetCookie2OverrideSetCookie() throws
> Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> > > Version=1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(1, cookies.size());
> > > > >> >         final Cookie cookie = cookies.get(0);
> > > > >> >         Assert.assertEquals(1, cookie.getVersion());
> > > > >> >         Assert.assertEquals("name1", cookie.getName());
> > > > >> >         Assert.assertEquals("value2", cookie.getValue());
> > > > >> >         Assert.assertEquals("localhost.local",
> cookie.getDomain());
> > > > >> >         Assert.assertEquals("/", cookie.getPath());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testInvalidHeader() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE2, "name=value;
> > > Version=crap");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertTrue(cookies.isEmpty());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testCookieRejected() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> > > > >> > www.somedomain.com; Version=1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertTrue(cookies.isEmpty());
> > > > >> >     }
> > > > >> >
> > > > >> > }
> > > > >> >
> > > > >> >
> > > > >> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> > > olegk@apache.org>
> > > > >> wrote:
> > > > >> >
> > > > >> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > > > >> > > > Finally, for those  2 I am not sure  as per RFC6265, to use
> > > them ,
> > > > >> put
> > > > >> > > code
> > > > >> > > > in
> org.apache.http.client.protocol.TestResponseProcessCookies.
> > > > >> > > > They worked with HC3 but it does not mean they should work
> with
> > > > >> HC4, but
> > > > >> > > I
> > > > >> > > > would like a confirmation:
> > > > >> > > >
> > > > >> > >
> > > > >> > > I cannot get the tests to compile due to missing instance
> > > variables
> > > > >> > > cookieOrigin, cookieSpec and cookieStore. I'll take another
> look
> > > if
> > > > >> you
> > > > >> > > post the complete class.
> > > > >> > >
> > > > >> > > Oleg
> > > > >> > >
> > > > >> > >
> > > > >> > > >
> > > > >> > > >     @Test
> > > > >> > > >     public void testParseCookies() throws Exception {
> > > > >> > > >         final HttpResponse response = new
> > > > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> > > >
> > > > >> > > >         final HttpClientContext context =
> > > > >> HttpClientContext.create();
> > > > >> > > >
>  context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > > > this.cookieOrigin);
> > > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > > > this.cookieSpec);
> > > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > > > this.cookieStore);
> > > > >> > > >
> > > > >> > > >         final HttpResponseInterceptor interceptor = new
> > > > >> > > > ResponseProcessCookies();
> > > > >> > > >         interceptor.process(response, context);
> > > > >> > > >
> > > > >> > > >         final List<Cookie> cookies =
> > > this.cookieStore.getCookies();
> > > > >> > > >         List<Header> lstHdr =
> cookieSpec.formatCookies(cookies);
> > > > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > > > >> > > >         for (Header header : lstHdr) {
> > > > >> > > >             sbHdr.append(header.getValue());
> > > > >> > > >         }
> > > > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > > >> > > sbHdr.toString());
> > > > >> > > >     }
> > > > >> > > >     @Test
> > > > >> > > >     public void testParseCookies2() throws Exception {
> > > > >> > > >         final HttpResponse response = new
> > > > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > > >> > > test2=2;secure");
> > > > >> > > >
> > > > >> > > >         final HttpClientContext context =
> > > > >> HttpClientContext.create();
> > > > >> > > >
>  context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > > > this.cookieOrigin);
> > > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > > > this.cookieSpec);
> > > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > > > this.cookieStore);
> > > > >> > > >
> > > > >> > > >         final HttpResponseInterceptor interceptor = new
> > > > >> > > > ResponseProcessCookies();
> > > > >> > > >         interceptor.process(response, context);
> > > > >> > > >
> > > > >> > > >         final List<Cookie> cookies =
> > > this.cookieStore.getCookies();
> > > > >> > > >         List<Header> lstHdr =
> cookieSpec.formatCookies(cookies);
> > > > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > > > >> > > >         for (Header header : lstHdr) {
> > > > >> > > >             sbHdr.append(header.getValue());
> > > > >> > > >         }
> > > > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > > >> > > sbHdr.toString());
> > > > >> > > >     }
> > > > >> > > >
> > > > >> > > > Thanks
> > > > >> > > >
> > > > >> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > > > >> > > > philippe.mouawad@gmail.com> wrote:
> > > > >> > > >
> > > > >> > > > > Hi,
> > > > >> > > > > Created
> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > > > >> with a
> > > > >> > > Test
> > > > >> > > > > case in it to show issue with Domain starting with ".".
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > Regards
> > > > >> > > > >
> > > > >> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > > >> > > > > philippe.mouawad@gmail.com> wrote:
> > > > >> > > > >
> > > > >> > > > >> Hi Oleg,
> > > > >> > > > >> Created
> > > https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > > > >> to show
> > > > >> > > > >> issue with Cookie Header ordering.
> > > > >> > > > >>
> > > > >> > > > >> Regards
> > > > >> > > > >>
> > > > >> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > > > >> > > > >> philippe.mouawad@gmail.com> wrote:
> > > > >> > > > >>
> > > > >> > > > >>> Hi,
> > > > >> > > > >>>  I created
> > > > >> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > > > >> > > with
> > > > >> > > > >>> JUnit test case so that you understand the difference we
> > > have.
> > > > >> > > > >>>
> > > > >> > > > >>> Regards
> > > > >> > > > >>>
> > > > >> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> > > > >> olegk@apache.org>
> > > > >> > > > >>> wrote:
> > > > >> > > > >>>
> > > > >> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad
> wrote:
> > > > >> > > > >>>> > Thanks Oleg.
> > > > >> > > > >>>> > But look at
> > > > >> > > > >>>> >
> > > > >> > > > >>>>
> > > > >> > >
> > > > >>
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > > > >> > > > >>>> ,
> > > > >> > > > >>>> > it concerns IGNORE_POLICY
> > > > >> > > > >>>> >
> > > > >> > > > >>>> > I really think there is at least one bug.
> > > > >> > > > >>>> > Regards
> > > > >> > > > >>>> >
> > > > >> > > > >>>>
> > > > >> > > > >>>> Sure thing. All these issues may well be due to bugs
> in HC.
> > > > >> Could
> > > > >> > > you
> > > > >> > > > >>>> please though reproduce them with unit tests that do
> not
> > > > >> involve
> > > > >> > > JMeter
> > > > >> > > > >>>> specific code?
> > > > >> > > > >>>>
> > > > >> > > > >>>> Oleg
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > > > >> > > olegk@apache.org>
> > > > >> > > > >>>> wrote:
> > > > >> > > > >>>> >
> > > > >> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> > > wrote:
> > > > >> > > > >>>> > > > Hi Oleg,
> > > > >> > > > >>>> > > > Thanks for answer.
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > Find my answers inline.
> > > > >> > > > >>>> > > > Regards
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg
> Kalnichevski <
> > > > >> > > > >>>> olegk@apache.org>
> > > > >> > > > >>>> > > wrote:
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe
> Mouawad
> > > > >> wrote:
> > > > >> > > > >>>> > > > > > Hello,
> > > > >> > > > >>>> > > > > > Any answer on this question ?
> > > > >> > > > >>>> > > > > > Thanks
> > > > >> > > > >>>> > > > > > Regards
> > > > >> > > > >>>> > > > > >
> > > > >> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe
> > > Mouawad <
> > > > >> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > > > >> > > > >>>> > > > > >
> > > > >> > > > >>>> > > > > > > Hello,
> > > > >> > > > >>>> > > > > > > We're in the process of migrating JMeter to
> > > last
> > > > >> > > HttpClient
> > > > >> > > > >>>> 4.5.1.
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > > > > We are now migrating the CookieManager to
> > > remove
> > > > >> all
> > > > >> > > > >>>> deprecated
> > > > >> > > > >>>> > > code.
> > > > >> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>>
> > > > >> > >
> > > > >>
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > > > > Before migration, it was still testing HC3
> > > version.
> > > > >> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed
> some
> > > > >> > > failures:
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > >
> > > > >> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC
> 4.5.1?
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > As I wrote, first we switched our JUnit tests to
> use
> > > HC4
> > > > >> > > > >>>> Implementation
> > > > >> > > > >>>> > > of
> > > > >> > > > >>>> > > > CookieHandler and used 4.2.3, we got some
> failures
> > > > >> compared to
> > > > >> > > > >>>> HC3.
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and
> got
> > > other
> > > > >> > > failures
> > > > >> > > > >>>> all
> > > > >> > > > >>>> > > > detailed in initial mail.
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > What policy does
> > > > >> > > > >>>> > > > > CookeManager use internally?
> > > > >> > > > >>>> > > > >
> > > > >> > > > >>>> > > > It depends on tests, you can see in the code that
> > > > >> depending on
> > > > >> > > > >>>> test
> > > > >> > > > >>>> > > method
> > > > >> > > > >>>> > > > we set different Policy to test them.
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > > You ought to be using RFC6265 policy either in
> strict
> > > or
> > > > >> relaxed
> > > > >> > > > >>>> mode
> > > > >> > > > >>>> > > and nothing else. All other policies have been
> marked
> > > as
> > > > >> > > obsolete
> > > > >> > > > >>>> and
> > > > >> > > > >>>> > > have already been removed in 5.0 (trunk).
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > > Oleg
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>>
> > > > >> > >
> > > ---------------------------------------------------------------------
> > > > >> > > > >>>> > > To unsubscribe, e-mail:
> > > > >> > > httpclient-users-unsubscribe@hc.apache.org
> > > > >> > > > >>>> > > For additional commands, e-mail:
> > > > >> > > > >>>> httpclient-users-help@hc.apache.org
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> >
> > > > >> > > > >>>> >
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > >
> > > ---------------------------------------------------------------------
> > > > >> > > > >>>> To unsubscribe, e-mail:
> > > > >> httpclient-users-unsubscribe@hc.apache.org
> > > > >> > > > >>>> For additional commands, e-mail:
> > > > >> > > httpclient-users-help@hc.apache.org
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > > > >>>
> > > > >> > > > >>>
> > > > >> > > > >>> --
> > > > >> > > > >>> Cordialement.
> > > > >> > > > >>> Philippe Mouawad.
> > > > >> > > > >>>
> > > > >> > > > >>>
> > > > >> > > > >>>
> > > > >> > > > >>
> > > > >> > > > >>
> > > > >> > > > >> --
> > > > >> > > > >> Cordialement.
> > > > >> > > > >> Philippe Mouawad.
> > > > >> > > > >>
> > > > >> > > > >>
> > > > >> > > > >>
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > --
> > > > >> > > > > Cordialement.
> > > > >> > > > > Philippe Mouawad.
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > >
> > > > >> > > >
> > > > >> > >
> > > > >> > >
> > > > >> > >
> > > > >> >
> > > > >> >
> > > > >>
> > > > >>
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > Cordialement.
> > > > > Philippe Mouawad.
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Thanks Oleg,
Did you have time to look at my JIRA HTTPCLIENT-1705 ?

Thanks
Regards

On Fri, Dec 18, 2015 at 10:51 AM, Oleg Kalnichevski <ol...@apache.org>
wrote:

> On Wed, 2015-12-16 at 21:26 +0100, Philippe Mouawad wrote:
> > Hi Oleg,
> > First, big thanks for your help on this, it is really valuable ! And I
> > really appreciate your patience .
> > Second, I  made a mistake in my test case of HTTPCLIENT-1705 JIRA issue,
> > which I fixed and reuploaded tonight few seconds ago.
> > Third, we wanted to release a version by either end of year or begining
> of
> > next year.
> >
>
> I'll try to get 4.5.2 released in Jan 2016, but do not take it as a
> promise. It may take longer unless someone else volunteers to RM the
> release.
>
> > Is migration to HC5.0 a big thing ? Do you advise to target 4.5.2 or 5.0
> ?
> > the alpha state of 5.0 seems risky to me.
> >
>
> Yes, it will be a big thing. You should not even concern yourself with
> HC 5.0 unless you want to contribute to its development.
>
> Oleg
>
>
> > Thanks
> > Regards
> > Philippe
> >
> >
> > On Wed, Dec 16, 2015 at 1:57 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Tue, 2015-12-15 at 14:16 +0100, Philippe Mouawad wrote:
> > > > Hi ,
> > > > One last question, when is release of 4.5.2 expected as it fixes 2
> bugs
> > > we
> > > > are facing in JMeter.
> > > >
> > > > Thanks
> > > > Regards
> > > >
> > >
> > > Philippe
> > >
> > > I was not planning to do HC 4.5.2 any time soon. I would very much
> > > rather get the first alpha of HC 5.0. How soon do you need it?
> > >
> > > Oleg
> > >
> > >
> > > > On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> > > > philippe.mouawad@gmail.com> wrote:
> > > >
> > > > >
> > > > >
> > > > > On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <
> olegk@apache.org>
> > > > > wrote:
> > > > >
> > > > >> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> > > > >> > Hello Oleg,
> > > > >> > Thanks .
> > > > >> >
> > > > >>
> > > > >> Test case #testParseCookies
> > > > >>
> > > > >> The rest case does not look right to me. I am not sure I
> understand
> > > what
> > > > >> you are trying to test here.
> > > > >>
> > > > > Indeed, bad copy paste.
> > > > >
> > > > > The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is
> on
> > > > > JMeter side.
> > > > >
> > > > >>
> > > > >> Test case #testParseCookies
> > > > >>
> > > > >>
> > > > >
> > > > >> The cookie in question does not have a version attribute
> mandatory for
> > > > >> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed
> as
> > > > >> Netscape style cookie in which case comma is not considered a
> valid
> > > > >> header element delimiter and is treated as normal character.
> > > > >>
> > > > >
> > > > > Thanks for explanation.
> > > > > Note that test case worked fine in HC3. Was it a bug in HC3 ?
> > > > >
> > > > >
> > > > >>
> > > > >> Oleg
> > > > >>
> > > > >>
> > > > >> > Here it is:
> > > > >> >
> > > > >> > /*
> > > > >> >  *
> > > ====================================================================
> > > > >> >  * 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
> > > > >> >  * "License"); 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
> > > > >> >  * "AS IS" 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.
> > > > >> >  *
> > > ====================================================================
> > > > >> >  *
> > > > >> >  * This software consists of voluntary contributions made by
> many
> > > > >> >  * individuals on behalf of the Apache Software Foundation.  For
> > > more
> > > > >> >  * information on the Apache Software Foundation, please see
> > > > >> >  * <http://www.apache.org/>.
> > > > >> >  *
> > > > >> >  */
> > > > >> > package org.apache.http.client.protocol;
> > > > >> >
> > > > >> > import java.util.List;
> > > > >> >
> > > > >> > import org.apache.http.Header;
> > > > >> > import org.apache.http.HttpResponse;
> > > > >> > import org.apache.http.HttpResponseInterceptor;
> > > > >> > import org.apache.http.HttpVersion;
> > > > >> > import org.apache.http.client.CookieStore;
> > > > >> > import org.apache.http.cookie.Cookie;
> > > > >> > import org.apache.http.cookie.CookieOrigin;
> > > > >> > import org.apache.http.cookie.CookieSpec;
> > > > >> > import org.apache.http.cookie.SM;
> > > > >> > import org.apache.http.impl.client.BasicCookieStore;
> > > > >> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> > > > >> > import org.apache.http.message.BasicHttpResponse;
> > > > >> > import org.apache.http.util.Asserts;
> > > > >> > import org.junit.Assert;
> > > > >> > import org.junit.Before;
> > > > >> > import org.junit.Test;
> > > > >> >
> > > > >> > public class TestResponseProcessCookies {
> > > > >> >
> > > > >> >     private CookieOrigin cookieOrigin;
> > > > >> >     private CookieSpec cookieSpec;
> > > > >> >     private CookieStore cookieStore;
> > > > >> >
> > > > >> >     @Before
> > > > >> >     public void setUp() throws Exception {
> > > > >> >         this.cookieOrigin = new CookieOrigin("localhost", 80,
> "/",
> > > > >> false);
> > > > >> >         this.cookieSpec = new DefaultCookieSpec();
> > > > >> >         this.cookieStore = new BasicCookieStore();
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test(expected=IllegalArgumentException.class)
> > > > >> >     public void testResponseParameterCheck() throws Exception {
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(null, context);
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test(expected=IllegalArgumentException.class)
> > > > >> >     public void testContextParameterCheck() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, null);
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testParseMultipleCookies() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;
> > > comment=\"how,now\",
> > > > >> > test2=2; version=1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(1, cookies.size());
> > > > >> >         final Cookie cookie = cookies.get(0);
> > > > >> >         Assert.assertEquals(0, cookie.getVersion());
> > > > >> >         Assert.assertEquals("name1", cookie.getName());
> > > > >> >         Assert.assertEquals("value1", cookie.getValue());
> > > > >> >         Assert.assertEquals("localhost", cookie.getDomain());
> > > > >> >         Assert.assertEquals("/", cookie.getPath());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testParseCookies() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > > >> >         StringBuilder sbHdr = new StringBuilder();
> > > > >> >         for (Header header : lstHdr) {
> > > > >> >             sbHdr.append(header.getValue());
> > > > >> >         }
> > > > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > > >> sbHdr.toString());
> > > > >> >     }
> > > > >> >     @Test
> > > > >> >     public void testParseCookies2() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > > >> test2=2;secure");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > > >> >         StringBuilder sbHdr = new StringBuilder();
> > > > >> >         for (Header header : lstHdr) {
> > > > >> >             sbHdr.append(header.getValue());
> > > > >> >         }
> > > > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > > >> sbHdr.toString());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testNoCookieOrigin() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> null);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(0, cookies.size());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testNoCookieSpec() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> null);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(0, cookies.size());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testNoCookieStore() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> null);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(0, cookies.size());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testSetCookie2OverrideSetCookie() throws
> Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> >         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> > > Version=1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertEquals(1, cookies.size());
> > > > >> >         final Cookie cookie = cookies.get(0);
> > > > >> >         Assert.assertEquals(1, cookie.getVersion());
> > > > >> >         Assert.assertEquals("name1", cookie.getName());
> > > > >> >         Assert.assertEquals("value2", cookie.getValue());
> > > > >> >         Assert.assertEquals("localhost.local",
> cookie.getDomain());
> > > > >> >         Assert.assertEquals("/", cookie.getPath());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testInvalidHeader() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE2, "name=value;
> > > Version=crap");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertTrue(cookies.isEmpty());
> > > > >> >     }
> > > > >> >
> > > > >> >     @Test
> > > > >> >     public void testCookieRejected() throws Exception {
> > > > >> >         final HttpResponse response = new
> > > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> > > > >> > www.somedomain.com; Version=1");
> > > > >> >
> > > > >> >         final HttpClientContext context =
> > > HttpClientContext.create();
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > this.cookieOrigin);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > this.cookieSpec);
> > > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > this.cookieStore);
> > > > >> >
> > > > >> >         final HttpResponseInterceptor interceptor = new
> > > > >> > ResponseProcessCookies();
> > > > >> >         interceptor.process(response, context);
> > > > >> >
> > > > >> >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > > > >> >         Assert.assertNotNull(cookies);
> > > > >> >         Assert.assertTrue(cookies.isEmpty());
> > > > >> >     }
> > > > >> >
> > > > >> > }
> > > > >> >
> > > > >> >
> > > > >> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> > > olegk@apache.org>
> > > > >> wrote:
> > > > >> >
> > > > >> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > > > >> > > > Finally, for those  2 I am not sure  as per RFC6265, to use
> > > them ,
> > > > >> put
> > > > >> > > code
> > > > >> > > > in
> org.apache.http.client.protocol.TestResponseProcessCookies.
> > > > >> > > > They worked with HC3 but it does not mean they should work
> with
> > > > >> HC4, but
> > > > >> > > I
> > > > >> > > > would like a confirmation:
> > > > >> > > >
> > > > >> > >
> > > > >> > > I cannot get the tests to compile due to missing instance
> > > variables
> > > > >> > > cookieOrigin, cookieSpec and cookieStore. I'll take another
> look
> > > if
> > > > >> you
> > > > >> > > post the complete class.
> > > > >> > >
> > > > >> > > Oleg
> > > > >> > >
> > > > >> > >
> > > > >> > > >
> > > > >> > > >     @Test
> > > > >> > > >     public void testParseCookies() throws Exception {
> > > > >> > > >         final HttpResponse response = new
> > > > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > > >> > > >
> > > > >> > > >         final HttpClientContext context =
> > > > >> HttpClientContext.create();
> > > > >> > > >
>  context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > > > this.cookieOrigin);
> > > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > > > this.cookieSpec);
> > > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > > > this.cookieStore);
> > > > >> > > >
> > > > >> > > >         final HttpResponseInterceptor interceptor = new
> > > > >> > > > ResponseProcessCookies();
> > > > >> > > >         interceptor.process(response, context);
> > > > >> > > >
> > > > >> > > >         final List<Cookie> cookies =
> > > this.cookieStore.getCookies();
> > > > >> > > >         List<Header> lstHdr =
> cookieSpec.formatCookies(cookies);
> > > > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > > > >> > > >         for (Header header : lstHdr) {
> > > > >> > > >             sbHdr.append(header.getValue());
> > > > >> > > >         }
> > > > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > > >> > > sbHdr.toString());
> > > > >> > > >     }
> > > > >> > > >     @Test
> > > > >> > > >     public void testParseCookies2() throws Exception {
> > > > >> > > >         final HttpResponse response = new
> > > > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > > >> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > > >> > > test2=2;secure");
> > > > >> > > >
> > > > >> > > >         final HttpClientContext context =
> > > > >> HttpClientContext.create();
> > > > >> > > >
>  context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > >> > > > this.cookieOrigin);
> > > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > >> > > > this.cookieSpec);
> > > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > >> > > > this.cookieStore);
> > > > >> > > >
> > > > >> > > >         final HttpResponseInterceptor interceptor = new
> > > > >> > > > ResponseProcessCookies();
> > > > >> > > >         interceptor.process(response, context);
> > > > >> > > >
> > > > >> > > >         final List<Cookie> cookies =
> > > this.cookieStore.getCookies();
> > > > >> > > >         List<Header> lstHdr =
> cookieSpec.formatCookies(cookies);
> > > > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > > > >> > > >         for (Header header : lstHdr) {
> > > > >> > > >             sbHdr.append(header.getValue());
> > > > >> > > >         }
> > > > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > > >> > > sbHdr.toString());
> > > > >> > > >     }
> > > > >> > > >
> > > > >> > > > Thanks
> > > > >> > > >
> > > > >> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > > > >> > > > philippe.mouawad@gmail.com> wrote:
> > > > >> > > >
> > > > >> > > > > Hi,
> > > > >> > > > > Created
> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > > > >> with a
> > > > >> > > Test
> > > > >> > > > > case in it to show issue with Domain starting with ".".
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > Regards
> > > > >> > > > >
> > > > >> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > > >> > > > > philippe.mouawad@gmail.com> wrote:
> > > > >> > > > >
> > > > >> > > > >> Hi Oleg,
> > > > >> > > > >> Created
> > > https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > > > >> to show
> > > > >> > > > >> issue with Cookie Header ordering.
> > > > >> > > > >>
> > > > >> > > > >> Regards
> > > > >> > > > >>
> > > > >> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > > > >> > > > >> philippe.mouawad@gmail.com> wrote:
> > > > >> > > > >>
> > > > >> > > > >>> Hi,
> > > > >> > > > >>>  I created
> > > > >> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > > > >> > > with
> > > > >> > > > >>> JUnit test case so that you understand the difference we
> > > have.
> > > > >> > > > >>>
> > > > >> > > > >>> Regards
> > > > >> > > > >>>
> > > > >> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> > > > >> olegk@apache.org>
> > > > >> > > > >>> wrote:
> > > > >> > > > >>>
> > > > >> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad
> wrote:
> > > > >> > > > >>>> > Thanks Oleg.
> > > > >> > > > >>>> > But look at
> > > > >> > > > >>>> >
> > > > >> > > > >>>>
> > > > >> > >
> > > > >>
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > > > >> > > > >>>> ,
> > > > >> > > > >>>> > it concerns IGNORE_POLICY
> > > > >> > > > >>>> >
> > > > >> > > > >>>> > I really think there is at least one bug.
> > > > >> > > > >>>> > Regards
> > > > >> > > > >>>> >
> > > > >> > > > >>>>
> > > > >> > > > >>>> Sure thing. All these issues may well be due to bugs
> in HC.
> > > > >> Could
> > > > >> > > you
> > > > >> > > > >>>> please though reproduce them with unit tests that do
> not
> > > > >> involve
> > > > >> > > JMeter
> > > > >> > > > >>>> specific code?
> > > > >> > > > >>>>
> > > > >> > > > >>>> Oleg
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > > > >> > > olegk@apache.org>
> > > > >> > > > >>>> wrote:
> > > > >> > > > >>>> >
> > > > >> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> > > wrote:
> > > > >> > > > >>>> > > > Hi Oleg,
> > > > >> > > > >>>> > > > Thanks for answer.
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > Find my answers inline.
> > > > >> > > > >>>> > > > Regards
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg
> Kalnichevski <
> > > > >> > > > >>>> olegk@apache.org>
> > > > >> > > > >>>> > > wrote:
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe
> Mouawad
> > > > >> wrote:
> > > > >> > > > >>>> > > > > > Hello,
> > > > >> > > > >>>> > > > > > Any answer on this question ?
> > > > >> > > > >>>> > > > > > Thanks
> > > > >> > > > >>>> > > > > > Regards
> > > > >> > > > >>>> > > > > >
> > > > >> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe
> > > Mouawad <
> > > > >> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > > > >> > > > >>>> > > > > >
> > > > >> > > > >>>> > > > > > > Hello,
> > > > >> > > > >>>> > > > > > > We're in the process of migrating JMeter to
> > > last
> > > > >> > > HttpClient
> > > > >> > > > >>>> 4.5.1.
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > > > > We are now migrating the CookieManager to
> > > remove
> > > > >> all
> > > > >> > > > >>>> deprecated
> > > > >> > > > >>>> > > code.
> > > > >> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>>
> > > > >> > >
> > > > >>
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > > > > Before migration, it was still testing HC3
> > > version.
> > > > >> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed
> some
> > > > >> > > failures:
> > > > >> > > > >>>> > > > > > >
> > > > >> > > > >>>> > > > >
> > > > >> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC
> 4.5.1?
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > As I wrote, first we switched our JUnit tests to
> use
> > > HC4
> > > > >> > > > >>>> Implementation
> > > > >> > > > >>>> > > of
> > > > >> > > > >>>> > > > CookieHandler and used 4.2.3, we got some
> failures
> > > > >> compared to
> > > > >> > > > >>>> HC3.
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and
> got
> > > other
> > > > >> > > failures
> > > > >> > > > >>>> all
> > > > >> > > > >>>> > > > detailed in initial mail.
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > > > What policy does
> > > > >> > > > >>>> > > > > CookeManager use internally?
> > > > >> > > > >>>> > > > >
> > > > >> > > > >>>> > > > It depends on tests, you can see in the code that
> > > > >> depending on
> > > > >> > > > >>>> test
> > > > >> > > > >>>> > > method
> > > > >> > > > >>>> > > > we set different Policy to test them.
> > > > >> > > > >>>> > > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > > You ought to be using RFC6265 policy either in
> strict
> > > or
> > > > >> relaxed
> > > > >> > > > >>>> mode
> > > > >> > > > >>>> > > and nothing else. All other policies have been
> marked
> > > as
> > > > >> > > obsolete
> > > > >> > > > >>>> and
> > > > >> > > > >>>> > > have already been removed in 5.0 (trunk).
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > > Oleg
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>>
> > > > >> > >
> > > ---------------------------------------------------------------------
> > > > >> > > > >>>> > > To unsubscribe, e-mail:
> > > > >> > > httpclient-users-unsubscribe@hc.apache.org
> > > > >> > > > >>>> > > For additional commands, e-mail:
> > > > >> > > > >>>> httpclient-users-help@hc.apache.org
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> > >
> > > > >> > > > >>>> >
> > > > >> > > > >>>> >
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > >
> > > ---------------------------------------------------------------------
> > > > >> > > > >>>> To unsubscribe, e-mail:
> > > > >> httpclient-users-unsubscribe@hc.apache.org
> > > > >> > > > >>>> For additional commands, e-mail:
> > > > >> > > httpclient-users-help@hc.apache.org
> > > > >> > > > >>>>
> > > > >> > > > >>>>
> > > > >> > > > >>>
> > > > >> > > > >>>
> > > > >> > > > >>> --
> > > > >> > > > >>> Cordialement.
> > > > >> > > > >>> Philippe Mouawad.
> > > > >> > > > >>>
> > > > >> > > > >>>
> > > > >> > > > >>>
> > > > >> > > > >>
> > > > >> > > > >>
> > > > >> > > > >> --
> > > > >> > > > >> Cordialement.
> > > > >> > > > >> Philippe Mouawad.
> > > > >> > > > >>
> > > > >> > > > >>
> > > > >> > > > >>
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > > --
> > > > >> > > > > Cordialement.
> > > > >> > > > > Philippe Mouawad.
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > > >
> > > > >> > > >
> > > > >> > > >
> > > > >> > >
> > > > >> > >
> > > > >> > >
> > > > >> >
> > > > >> >
> > > > >>
> > > > >>
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > Cordialement.
> > > > > Philippe Mouawad.
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2015-12-16 at 21:26 +0100, Philippe Mouawad wrote:
> Hi Oleg,
> First, big thanks for your help on this, it is really valuable ! And I
> really appreciate your patience .
> Second, I  made a mistake in my test case of HTTPCLIENT-1705 JIRA issue,
> which I fixed and reuploaded tonight few seconds ago.
> Third, we wanted to release a version by either end of year or begining of
> next year.
> 

I'll try to get 4.5.2 released in Jan 2016, but do not take it as a
promise. It may take longer unless someone else volunteers to RM the
release.

> Is migration to HC5.0 a big thing ? Do you advise to target 4.5.2 or 5.0 ?
> the alpha state of 5.0 seems risky to me.
> 

Yes, it will be a big thing. You should not even concern yourself with
HC 5.0 unless you want to contribute to its development.

Oleg


> Thanks
> Regards
> Philippe
> 
> 
> On Wed, Dec 16, 2015 at 1:57 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Tue, 2015-12-15 at 14:16 +0100, Philippe Mouawad wrote:
> > > Hi ,
> > > One last question, when is release of 4.5.2 expected as it fixes 2 bugs
> > we
> > > are facing in JMeter.
> > >
> > > Thanks
> > > Regards
> > >
> >
> > Philippe
> >
> > I was not planning to do HC 4.5.2 any time soon. I would very much
> > rather get the first alpha of HC 5.0. How soon do you need it?
> >
> > Oleg
> >
> >
> > > On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> > > philippe.mouawad@gmail.com> wrote:
> > >
> > > >
> > > >
> > > > On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> > > > wrote:
> > > >
> > > >> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> > > >> > Hello Oleg,
> > > >> > Thanks .
> > > >> >
> > > >>
> > > >> Test case #testParseCookies
> > > >>
> > > >> The rest case does not look right to me. I am not sure I understand
> > what
> > > >> you are trying to test here.
> > > >>
> > > > Indeed, bad copy paste.
> > > >
> > > > The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> > > > JMeter side.
> > > >
> > > >>
> > > >> Test case #testParseCookies
> > > >>
> > > >>
> > > >
> > > >> The cookie in question does not have a version attribute mandatory for
> > > >> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> > > >> Netscape style cookie in which case comma is not considered a valid
> > > >> header element delimiter and is treated as normal character.
> > > >>
> > > >
> > > > Thanks for explanation.
> > > > Note that test case worked fine in HC3. Was it a bug in HC3 ?
> > > >
> > > >
> > > >>
> > > >> Oleg
> > > >>
> > > >>
> > > >> > Here it is:
> > > >> >
> > > >> > /*
> > > >> >  *
> > ====================================================================
> > > >> >  * 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
> > > >> >  * "License"); 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
> > > >> >  * "AS IS" 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.
> > > >> >  *
> > ====================================================================
> > > >> >  *
> > > >> >  * This software consists of voluntary contributions made by many
> > > >> >  * individuals on behalf of the Apache Software Foundation.  For
> > more
> > > >> >  * information on the Apache Software Foundation, please see
> > > >> >  * <http://www.apache.org/>.
> > > >> >  *
> > > >> >  */
> > > >> > package org.apache.http.client.protocol;
> > > >> >
> > > >> > import java.util.List;
> > > >> >
> > > >> > import org.apache.http.Header;
> > > >> > import org.apache.http.HttpResponse;
> > > >> > import org.apache.http.HttpResponseInterceptor;
> > > >> > import org.apache.http.HttpVersion;
> > > >> > import org.apache.http.client.CookieStore;
> > > >> > import org.apache.http.cookie.Cookie;
> > > >> > import org.apache.http.cookie.CookieOrigin;
> > > >> > import org.apache.http.cookie.CookieSpec;
> > > >> > import org.apache.http.cookie.SM;
> > > >> > import org.apache.http.impl.client.BasicCookieStore;
> > > >> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> > > >> > import org.apache.http.message.BasicHttpResponse;
> > > >> > import org.apache.http.util.Asserts;
> > > >> > import org.junit.Assert;
> > > >> > import org.junit.Before;
> > > >> > import org.junit.Test;
> > > >> >
> > > >> > public class TestResponseProcessCookies {
> > > >> >
> > > >> >     private CookieOrigin cookieOrigin;
> > > >> >     private CookieSpec cookieSpec;
> > > >> >     private CookieStore cookieStore;
> > > >> >
> > > >> >     @Before
> > > >> >     public void setUp() throws Exception {
> > > >> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> > > >> false);
> > > >> >         this.cookieSpec = new DefaultCookieSpec();
> > > >> >         this.cookieStore = new BasicCookieStore();
> > > >> >     }
> > > >> >
> > > >> >     @Test(expected=IllegalArgumentException.class)
> > > >> >     public void testResponseParameterCheck() throws Exception {
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(null, context);
> > > >> >     }
> > > >> >
> > > >> >     @Test(expected=IllegalArgumentException.class)
> > > >> >     public void testContextParameterCheck() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, null);
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testParseMultipleCookies() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;
> > comment=\"how,now\",
> > > >> > test2=2; version=1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(1, cookies.size());
> > > >> >         final Cookie cookie = cookies.get(0);
> > > >> >         Assert.assertEquals(0, cookie.getVersion());
> > > >> >         Assert.assertEquals("name1", cookie.getName());
> > > >> >         Assert.assertEquals("value1", cookie.getValue());
> > > >> >         Assert.assertEquals("localhost", cookie.getDomain());
> > > >> >         Assert.assertEquals("/", cookie.getPath());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testParseCookies() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >> >         StringBuilder sbHdr = new StringBuilder();
> > > >> >         for (Header header : lstHdr) {
> > > >> >             sbHdr.append(header.getValue());
> > > >> >         }
> > > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > >> sbHdr.toString());
> > > >> >     }
> > > >> >     @Test
> > > >> >     public void testParseCookies2() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > >> test2=2;secure");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >> >         StringBuilder sbHdr = new StringBuilder();
> > > >> >         for (Header header : lstHdr) {
> > > >> >             sbHdr.append(header.getValue());
> > > >> >         }
> > > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > >> sbHdr.toString());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testNoCookieOrigin() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(0, cookies.size());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testNoCookieSpec() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(0, cookies.size());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testNoCookieStore() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(0, cookies.size());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testSetCookie2OverrideSetCookie() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> > Version=1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(1, cookies.size());
> > > >> >         final Cookie cookie = cookies.get(0);
> > > >> >         Assert.assertEquals(1, cookie.getVersion());
> > > >> >         Assert.assertEquals("name1", cookie.getName());
> > > >> >         Assert.assertEquals("value2", cookie.getValue());
> > > >> >         Assert.assertEquals("localhost.local", cookie.getDomain());
> > > >> >         Assert.assertEquals("/", cookie.getPath());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testInvalidHeader() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE2, "name=value;
> > Version=crap");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertTrue(cookies.isEmpty());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testCookieRejected() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> > > >> > www.somedomain.com; Version=1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertTrue(cookies.isEmpty());
> > > >> >     }
> > > >> >
> > > >> > }
> > > >> >
> > > >> >
> > > >> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> > olegk@apache.org>
> > > >> wrote:
> > > >> >
> > > >> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > > >> > > > Finally, for those  2 I am not sure  as per RFC6265, to use
> > them ,
> > > >> put
> > > >> > > code
> > > >> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > > >> > > > They worked with HC3 but it does not mean they should work with
> > > >> HC4, but
> > > >> > > I
> > > >> > > > would like a confirmation:
> > > >> > > >
> > > >> > >
> > > >> > > I cannot get the tests to compile due to missing instance
> > variables
> > > >> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look
> > if
> > > >> you
> > > >> > > post the complete class.
> > > >> > >
> > > >> > > Oleg
> > > >> > >
> > > >> > >
> > > >> > > >
> > > >> > > >     @Test
> > > >> > > >     public void testParseCookies() throws Exception {
> > > >> > > >         final HttpResponse response = new
> > > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> > > >
> > > >> > > >         final HttpClientContext context =
> > > >> HttpClientContext.create();
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > > > this.cookieOrigin);
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > > > this.cookieSpec);
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > > > this.cookieStore);
> > > >> > > >
> > > >> > > >         final HttpResponseInterceptor interceptor = new
> > > >> > > > ResponseProcessCookies();
> > > >> > > >         interceptor.process(response, context);
> > > >> > > >
> > > >> > > >         final List<Cookie> cookies =
> > this.cookieStore.getCookies();
> > > >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > > >> > > >         for (Header header : lstHdr) {
> > > >> > > >             sbHdr.append(header.getValue());
> > > >> > > >         }
> > > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > >> > > sbHdr.toString());
> > > >> > > >     }
> > > >> > > >     @Test
> > > >> > > >     public void testParseCookies2() throws Exception {
> > > >> > > >         final HttpResponse response = new
> > > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > >> > > test2=2;secure");
> > > >> > > >
> > > >> > > >         final HttpClientContext context =
> > > >> HttpClientContext.create();
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > > > this.cookieOrigin);
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > > > this.cookieSpec);
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > > > this.cookieStore);
> > > >> > > >
> > > >> > > >         final HttpResponseInterceptor interceptor = new
> > > >> > > > ResponseProcessCookies();
> > > >> > > >         interceptor.process(response, context);
> > > >> > > >
> > > >> > > >         final List<Cookie> cookies =
> > this.cookieStore.getCookies();
> > > >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > > >> > > >         for (Header header : lstHdr) {
> > > >> > > >             sbHdr.append(header.getValue());
> > > >> > > >         }
> > > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > >> > > sbHdr.toString());
> > > >> > > >     }
> > > >> > > >
> > > >> > > > Thanks
> > > >> > > >
> > > >> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > > >> > > > philippe.mouawad@gmail.com> wrote:
> > > >> > > >
> > > >> > > > > Hi,
> > > >> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > > >> with a
> > > >> > > Test
> > > >> > > > > case in it to show issue with Domain starting with ".".
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > Regards
> > > >> > > > >
> > > >> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > >> > > > > philippe.mouawad@gmail.com> wrote:
> > > >> > > > >
> > > >> > > > >> Hi Oleg,
> > > >> > > > >> Created
> > https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > > >> to show
> > > >> > > > >> issue with Cookie Header ordering.
> > > >> > > > >>
> > > >> > > > >> Regards
> > > >> > > > >>
> > > >> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > > >> > > > >> philippe.mouawad@gmail.com> wrote:
> > > >> > > > >>
> > > >> > > > >>> Hi,
> > > >> > > > >>>  I created
> > > >> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > > >> > > with
> > > >> > > > >>> JUnit test case so that you understand the difference we
> > have.
> > > >> > > > >>>
> > > >> > > > >>> Regards
> > > >> > > > >>>
> > > >> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> > > >> olegk@apache.org>
> > > >> > > > >>> wrote:
> > > >> > > > >>>
> > > >> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > > >> > > > >>>> > Thanks Oleg.
> > > >> > > > >>>> > But look at
> > > >> > > > >>>> >
> > > >> > > > >>>>
> > > >> > >
> > > >>
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > > >> > > > >>>> ,
> > > >> > > > >>>> > it concerns IGNORE_POLICY
> > > >> > > > >>>> >
> > > >> > > > >>>> > I really think there is at least one bug.
> > > >> > > > >>>> > Regards
> > > >> > > > >>>> >
> > > >> > > > >>>>
> > > >> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
> > > >> Could
> > > >> > > you
> > > >> > > > >>>> please though reproduce them with unit tests that do not
> > > >> involve
> > > >> > > JMeter
> > > >> > > > >>>> specific code?
> > > >> > > > >>>>
> > > >> > > > >>>> Oleg
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > > >> > > olegk@apache.org>
> > > >> > > > >>>> wrote:
> > > >> > > > >>>> >
> > > >> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> > wrote:
> > > >> > > > >>>> > > > Hi Oleg,
> > > >> > > > >>>> > > > Thanks for answer.
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > Find my answers inline.
> > > >> > > > >>>> > > > Regards
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > > >> > > > >>>> olegk@apache.org>
> > > >> > > > >>>> > > wrote:
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> > > >> wrote:
> > > >> > > > >>>> > > > > > Hello,
> > > >> > > > >>>> > > > > > Any answer on this question ?
> > > >> > > > >>>> > > > > > Thanks
> > > >> > > > >>>> > > > > > Regards
> > > >> > > > >>>> > > > > >
> > > >> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe
> > Mouawad <
> > > >> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > > >> > > > >>>> > > > > >
> > > >> > > > >>>> > > > > > > Hello,
> > > >> > > > >>>> > > > > > > We're in the process of migrating JMeter to
> > last
> > > >> > > HttpClient
> > > >> > > > >>>> 4.5.1.
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > > > > We are now migrating the CookieManager to
> > remove
> > > >> all
> > > >> > > > >>>> deprecated
> > > >> > > > >>>> > > code.
> > > >> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > >
> > > >> > > > >>>> > >
> > > >> > > > >>>>
> > > >> > >
> > > >>
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > > > > Before migration, it was still testing HC3
> > version.
> > > >> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> > > >> > > failures:
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > >
> > > >> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use
> > HC4
> > > >> > > > >>>> Implementation
> > > >> > > > >>>> > > of
> > > >> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
> > > >> compared to
> > > >> > > > >>>> HC3.
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got
> > other
> > > >> > > failures
> > > >> > > > >>>> all
> > > >> > > > >>>> > > > detailed in initial mail.
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > What policy does
> > > >> > > > >>>> > > > > CookeManager use internally?
> > > >> > > > >>>> > > > >
> > > >> > > > >>>> > > > It depends on tests, you can see in the code that
> > > >> depending on
> > > >> > > > >>>> test
> > > >> > > > >>>> > > method
> > > >> > > > >>>> > > > we set different Policy to test them.
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > >
> > > >> > > > >>>> > > You ought to be using RFC6265 policy either in strict
> > or
> > > >> relaxed
> > > >> > > > >>>> mode
> > > >> > > > >>>> > > and nothing else. All other policies have been marked
> > as
> > > >> > > obsolete
> > > >> > > > >>>> and
> > > >> > > > >>>> > > have already been removed in 5.0 (trunk).
> > > >> > > > >>>> > >
> > > >> > > > >>>> > > Oleg
> > > >> > > > >>>> > >
> > > >> > > > >>>> > >
> > > >> > > > >>>> > >
> > > >> > > > >>>>
> > > >> > >
> > ---------------------------------------------------------------------
> > > >> > > > >>>> > > To unsubscribe, e-mail:
> > > >> > > httpclient-users-unsubscribe@hc.apache.org
> > > >> > > > >>>> > > For additional commands, e-mail:
> > > >> > > > >>>> httpclient-users-help@hc.apache.org
> > > >> > > > >>>> > >
> > > >> > > > >>>> > >
> > > >> > > > >>>> >
> > > >> > > > >>>> >
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > >
> > ---------------------------------------------------------------------
> > > >> > > > >>>> To unsubscribe, e-mail:
> > > >> httpclient-users-unsubscribe@hc.apache.org
> > > >> > > > >>>> For additional commands, e-mail:
> > > >> > > httpclient-users-help@hc.apache.org
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > > > >>>
> > > >> > > > >>>
> > > >> > > > >>> --
> > > >> > > > >>> Cordialement.
> > > >> > > > >>> Philippe Mouawad.
> > > >> > > > >>>
> > > >> > > > >>>
> > > >> > > > >>>
> > > >> > > > >>
> > > >> > > > >>
> > > >> > > > >> --
> > > >> > > > >> Cordialement.
> > > >> > > > >> Philippe Mouawad.
> > > >> > > > >>
> > > >> > > > >>
> > > >> > > > >>
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > --
> > > >> > > > > Cordialement.
> > > >> > > > > Philippe Mouawad.
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > > >
> > > >> > >
> > > >> > >
> > > >> > >
> > > >> >
> > > >> >
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > > > --
> > > > Cordialement.
> > > > Philippe Mouawad.
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2015-12-16 at 21:26 +0100, Philippe Mouawad wrote:
> Hi Oleg,
> First, big thanks for your help on this, it is really valuable ! And I
> really appreciate your patience .
> Second, I  made a mistake in my test case of HTTPCLIENT-1705 JIRA issue,
> which I fixed and reuploaded tonight few seconds ago.
> Third, we wanted to release a version by either end of year or begining of
> next year.
> 

I'll try to get 4.5.2 released in Jan 2016, but do not take it as a
promise. It may take longer unless someone else volunteers to RM the
release.

> Is migration to HC5.0 a big thing ? Do you advise to target 4.5.2 or 5.0 ?
> the alpha state of 5.0 seems risky to me.
> 

Yes, it will be a big thing. You should not even concern yourself with
HC 5.0 unless you want to contribute to its development.

Oleg


> Thanks
> Regards
> Philippe
> 
> 
> On Wed, Dec 16, 2015 at 1:57 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Tue, 2015-12-15 at 14:16 +0100, Philippe Mouawad wrote:
> > > Hi ,
> > > One last question, when is release of 4.5.2 expected as it fixes 2 bugs
> > we
> > > are facing in JMeter.
> > >
> > > Thanks
> > > Regards
> > >
> >
> > Philippe
> >
> > I was not planning to do HC 4.5.2 any time soon. I would very much
> > rather get the first alpha of HC 5.0. How soon do you need it?
> >
> > Oleg
> >
> >
> > > On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> > > philippe.mouawad@gmail.com> wrote:
> > >
> > > >
> > > >
> > > > On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> > > > wrote:
> > > >
> > > >> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> > > >> > Hello Oleg,
> > > >> > Thanks .
> > > >> >
> > > >>
> > > >> Test case #testParseCookies
> > > >>
> > > >> The rest case does not look right to me. I am not sure I understand
> > what
> > > >> you are trying to test here.
> > > >>
> > > > Indeed, bad copy paste.
> > > >
> > > > The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> > > > JMeter side.
> > > >
> > > >>
> > > >> Test case #testParseCookies
> > > >>
> > > >>
> > > >
> > > >> The cookie in question does not have a version attribute mandatory for
> > > >> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> > > >> Netscape style cookie in which case comma is not considered a valid
> > > >> header element delimiter and is treated as normal character.
> > > >>
> > > >
> > > > Thanks for explanation.
> > > > Note that test case worked fine in HC3. Was it a bug in HC3 ?
> > > >
> > > >
> > > >>
> > > >> Oleg
> > > >>
> > > >>
> > > >> > Here it is:
> > > >> >
> > > >> > /*
> > > >> >  *
> > ====================================================================
> > > >> >  * 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
> > > >> >  * "License"); 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
> > > >> >  * "AS IS" 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.
> > > >> >  *
> > ====================================================================
> > > >> >  *
> > > >> >  * This software consists of voluntary contributions made by many
> > > >> >  * individuals on behalf of the Apache Software Foundation.  For
> > more
> > > >> >  * information on the Apache Software Foundation, please see
> > > >> >  * <http://www.apache.org/>.
> > > >> >  *
> > > >> >  */
> > > >> > package org.apache.http.client.protocol;
> > > >> >
> > > >> > import java.util.List;
> > > >> >
> > > >> > import org.apache.http.Header;
> > > >> > import org.apache.http.HttpResponse;
> > > >> > import org.apache.http.HttpResponseInterceptor;
> > > >> > import org.apache.http.HttpVersion;
> > > >> > import org.apache.http.client.CookieStore;
> > > >> > import org.apache.http.cookie.Cookie;
> > > >> > import org.apache.http.cookie.CookieOrigin;
> > > >> > import org.apache.http.cookie.CookieSpec;
> > > >> > import org.apache.http.cookie.SM;
> > > >> > import org.apache.http.impl.client.BasicCookieStore;
> > > >> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> > > >> > import org.apache.http.message.BasicHttpResponse;
> > > >> > import org.apache.http.util.Asserts;
> > > >> > import org.junit.Assert;
> > > >> > import org.junit.Before;
> > > >> > import org.junit.Test;
> > > >> >
> > > >> > public class TestResponseProcessCookies {
> > > >> >
> > > >> >     private CookieOrigin cookieOrigin;
> > > >> >     private CookieSpec cookieSpec;
> > > >> >     private CookieStore cookieStore;
> > > >> >
> > > >> >     @Before
> > > >> >     public void setUp() throws Exception {
> > > >> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> > > >> false);
> > > >> >         this.cookieSpec = new DefaultCookieSpec();
> > > >> >         this.cookieStore = new BasicCookieStore();
> > > >> >     }
> > > >> >
> > > >> >     @Test(expected=IllegalArgumentException.class)
> > > >> >     public void testResponseParameterCheck() throws Exception {
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(null, context);
> > > >> >     }
> > > >> >
> > > >> >     @Test(expected=IllegalArgumentException.class)
> > > >> >     public void testContextParameterCheck() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, null);
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testParseMultipleCookies() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;
> > comment=\"how,now\",
> > > >> > test2=2; version=1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(1, cookies.size());
> > > >> >         final Cookie cookie = cookies.get(0);
> > > >> >         Assert.assertEquals(0, cookie.getVersion());
> > > >> >         Assert.assertEquals("name1", cookie.getName());
> > > >> >         Assert.assertEquals("value1", cookie.getValue());
> > > >> >         Assert.assertEquals("localhost", cookie.getDomain());
> > > >> >         Assert.assertEquals("/", cookie.getPath());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testParseCookies() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >> >         StringBuilder sbHdr = new StringBuilder();
> > > >> >         for (Header header : lstHdr) {
> > > >> >             sbHdr.append(header.getValue());
> > > >> >         }
> > > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > >> sbHdr.toString());
> > > >> >     }
> > > >> >     @Test
> > > >> >     public void testParseCookies2() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > >> test2=2;secure");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >> >         StringBuilder sbHdr = new StringBuilder();
> > > >> >         for (Header header : lstHdr) {
> > > >> >             sbHdr.append(header.getValue());
> > > >> >         }
> > > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > >> sbHdr.toString());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testNoCookieOrigin() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(0, cookies.size());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testNoCookieSpec() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(0, cookies.size());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testNoCookieStore() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(0, cookies.size());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testSetCookie2OverrideSetCookie() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> >         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> > Version=1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertEquals(1, cookies.size());
> > > >> >         final Cookie cookie = cookies.get(0);
> > > >> >         Assert.assertEquals(1, cookie.getVersion());
> > > >> >         Assert.assertEquals("name1", cookie.getName());
> > > >> >         Assert.assertEquals("value2", cookie.getValue());
> > > >> >         Assert.assertEquals("localhost.local", cookie.getDomain());
> > > >> >         Assert.assertEquals("/", cookie.getPath());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testInvalidHeader() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE2, "name=value;
> > Version=crap");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertTrue(cookies.isEmpty());
> > > >> >     }
> > > >> >
> > > >> >     @Test
> > > >> >     public void testCookieRejected() throws Exception {
> > > >> >         final HttpResponse response = new
> > > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> > > >> > www.somedomain.com; Version=1");
> > > >> >
> > > >> >         final HttpClientContext context =
> > HttpClientContext.create();
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > this.cookieOrigin);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > this.cookieSpec);
> > > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > this.cookieStore);
> > > >> >
> > > >> >         final HttpResponseInterceptor interceptor = new
> > > >> > ResponseProcessCookies();
> > > >> >         interceptor.process(response, context);
> > > >> >
> > > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >> >         Assert.assertNotNull(cookies);
> > > >> >         Assert.assertTrue(cookies.isEmpty());
> > > >> >     }
> > > >> >
> > > >> > }
> > > >> >
> > > >> >
> > > >> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> > olegk@apache.org>
> > > >> wrote:
> > > >> >
> > > >> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > > >> > > > Finally, for those  2 I am not sure  as per RFC6265, to use
> > them ,
> > > >> put
> > > >> > > code
> > > >> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > > >> > > > They worked with HC3 but it does not mean they should work with
> > > >> HC4, but
> > > >> > > I
> > > >> > > > would like a confirmation:
> > > >> > > >
> > > >> > >
> > > >> > > I cannot get the tests to compile due to missing instance
> > variables
> > > >> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look
> > if
> > > >> you
> > > >> > > post the complete class.
> > > >> > >
> > > >> > > Oleg
> > > >> > >
> > > >> > >
> > > >> > > >
> > > >> > > >     @Test
> > > >> > > >     public void testParseCookies() throws Exception {
> > > >> > > >         final HttpResponse response = new
> > > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >> > > >
> > > >> > > >         final HttpClientContext context =
> > > >> HttpClientContext.create();
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > > > this.cookieOrigin);
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > > > this.cookieSpec);
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > > > this.cookieStore);
> > > >> > > >
> > > >> > > >         final HttpResponseInterceptor interceptor = new
> > > >> > > > ResponseProcessCookies();
> > > >> > > >         interceptor.process(response, context);
> > > >> > > >
> > > >> > > >         final List<Cookie> cookies =
> > this.cookieStore.getCookies();
> > > >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > > >> > > >         for (Header header : lstHdr) {
> > > >> > > >             sbHdr.append(header.getValue());
> > > >> > > >         }
> > > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > >> > > sbHdr.toString());
> > > >> > > >     }
> > > >> > > >     @Test
> > > >> > > >     public void testParseCookies2() throws Exception {
> > > >> > > >         final HttpResponse response = new
> > > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > >> > > test2=2;secure");
> > > >> > > >
> > > >> > > >         final HttpClientContext context =
> > > >> HttpClientContext.create();
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > >> > > > this.cookieOrigin);
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > >> > > > this.cookieSpec);
> > > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > >> > > > this.cookieStore);
> > > >> > > >
> > > >> > > >         final HttpResponseInterceptor interceptor = new
> > > >> > > > ResponseProcessCookies();
> > > >> > > >         interceptor.process(response, context);
> > > >> > > >
> > > >> > > >         final List<Cookie> cookies =
> > this.cookieStore.getCookies();
> > > >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > > >> > > >         for (Header header : lstHdr) {
> > > >> > > >             sbHdr.append(header.getValue());
> > > >> > > >         }
> > > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > >> > > sbHdr.toString());
> > > >> > > >     }
> > > >> > > >
> > > >> > > > Thanks
> > > >> > > >
> > > >> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > > >> > > > philippe.mouawad@gmail.com> wrote:
> > > >> > > >
> > > >> > > > > Hi,
> > > >> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > > >> with a
> > > >> > > Test
> > > >> > > > > case in it to show issue with Domain starting with ".".
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > Regards
> > > >> > > > >
> > > >> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > >> > > > > philippe.mouawad@gmail.com> wrote:
> > > >> > > > >
> > > >> > > > >> Hi Oleg,
> > > >> > > > >> Created
> > https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > > >> to show
> > > >> > > > >> issue with Cookie Header ordering.
> > > >> > > > >>
> > > >> > > > >> Regards
> > > >> > > > >>
> > > >> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > > >> > > > >> philippe.mouawad@gmail.com> wrote:
> > > >> > > > >>
> > > >> > > > >>> Hi,
> > > >> > > > >>>  I created
> > > >> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > > >> > > with
> > > >> > > > >>> JUnit test case so that you understand the difference we
> > have.
> > > >> > > > >>>
> > > >> > > > >>> Regards
> > > >> > > > >>>
> > > >> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> > > >> olegk@apache.org>
> > > >> > > > >>> wrote:
> > > >> > > > >>>
> > > >> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > > >> > > > >>>> > Thanks Oleg.
> > > >> > > > >>>> > But look at
> > > >> > > > >>>> >
> > > >> > > > >>>>
> > > >> > >
> > > >>
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > > >> > > > >>>> ,
> > > >> > > > >>>> > it concerns IGNORE_POLICY
> > > >> > > > >>>> >
> > > >> > > > >>>> > I really think there is at least one bug.
> > > >> > > > >>>> > Regards
> > > >> > > > >>>> >
> > > >> > > > >>>>
> > > >> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
> > > >> Could
> > > >> > > you
> > > >> > > > >>>> please though reproduce them with unit tests that do not
> > > >> involve
> > > >> > > JMeter
> > > >> > > > >>>> specific code?
> > > >> > > > >>>>
> > > >> > > > >>>> Oleg
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > > >> > > olegk@apache.org>
> > > >> > > > >>>> wrote:
> > > >> > > > >>>> >
> > > >> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> > wrote:
> > > >> > > > >>>> > > > Hi Oleg,
> > > >> > > > >>>> > > > Thanks for answer.
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > Find my answers inline.
> > > >> > > > >>>> > > > Regards
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > > >> > > > >>>> olegk@apache.org>
> > > >> > > > >>>> > > wrote:
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> > > >> wrote:
> > > >> > > > >>>> > > > > > Hello,
> > > >> > > > >>>> > > > > > Any answer on this question ?
> > > >> > > > >>>> > > > > > Thanks
> > > >> > > > >>>> > > > > > Regards
> > > >> > > > >>>> > > > > >
> > > >> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe
> > Mouawad <
> > > >> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > > >> > > > >>>> > > > > >
> > > >> > > > >>>> > > > > > > Hello,
> > > >> > > > >>>> > > > > > > We're in the process of migrating JMeter to
> > last
> > > >> > > HttpClient
> > > >> > > > >>>> 4.5.1.
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > > > > We are now migrating the CookieManager to
> > remove
> > > >> all
> > > >> > > > >>>> deprecated
> > > >> > > > >>>> > > code.
> > > >> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > >
> > > >> > > > >>>> > >
> > > >> > > > >>>>
> > > >> > >
> > > >>
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > > > > Before migration, it was still testing HC3
> > version.
> > > >> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> > > >> > > failures:
> > > >> > > > >>>> > > > > > >
> > > >> > > > >>>> > > > >
> > > >> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use
> > HC4
> > > >> > > > >>>> Implementation
> > > >> > > > >>>> > > of
> > > >> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
> > > >> compared to
> > > >> > > > >>>> HC3.
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got
> > other
> > > >> > > failures
> > > >> > > > >>>> all
> > > >> > > > >>>> > > > detailed in initial mail.
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > > > What policy does
> > > >> > > > >>>> > > > > CookeManager use internally?
> > > >> > > > >>>> > > > >
> > > >> > > > >>>> > > > It depends on tests, you can see in the code that
> > > >> depending on
> > > >> > > > >>>> test
> > > >> > > > >>>> > > method
> > > >> > > > >>>> > > > we set different Policy to test them.
> > > >> > > > >>>> > > >
> > > >> > > > >>>> > >
> > > >> > > > >>>> > > You ought to be using RFC6265 policy either in strict
> > or
> > > >> relaxed
> > > >> > > > >>>> mode
> > > >> > > > >>>> > > and nothing else. All other policies have been marked
> > as
> > > >> > > obsolete
> > > >> > > > >>>> and
> > > >> > > > >>>> > > have already been removed in 5.0 (trunk).
> > > >> > > > >>>> > >
> > > >> > > > >>>> > > Oleg
> > > >> > > > >>>> > >
> > > >> > > > >>>> > >
> > > >> > > > >>>> > >
> > > >> > > > >>>>
> > > >> > >
> > ---------------------------------------------------------------------
> > > >> > > > >>>> > > To unsubscribe, e-mail:
> > > >> > > httpclient-users-unsubscribe@hc.apache.org
> > > >> > > > >>>> > > For additional commands, e-mail:
> > > >> > > > >>>> httpclient-users-help@hc.apache.org
> > > >> > > > >>>> > >
> > > >> > > > >>>> > >
> > > >> > > > >>>> >
> > > >> > > > >>>> >
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > >
> > ---------------------------------------------------------------------
> > > >> > > > >>>> To unsubscribe, e-mail:
> > > >> httpclient-users-unsubscribe@hc.apache.org
> > > >> > > > >>>> For additional commands, e-mail:
> > > >> > > httpclient-users-help@hc.apache.org
> > > >> > > > >>>>
> > > >> > > > >>>>
> > > >> > > > >>>
> > > >> > > > >>>
> > > >> > > > >>> --
> > > >> > > > >>> Cordialement.
> > > >> > > > >>> Philippe Mouawad.
> > > >> > > > >>>
> > > >> > > > >>>
> > > >> > > > >>>
> > > >> > > > >>
> > > >> > > > >>
> > > >> > > > >> --
> > > >> > > > >> Cordialement.
> > > >> > > > >> Philippe Mouawad.
> > > >> > > > >>
> > > >> > > > >>
> > > >> > > > >>
> > > >> > > > >
> > > >> > > > >
> > > >> > > > > --
> > > >> > > > > Cordialement.
> > > >> > > > > Philippe Mouawad.
> > > >> > > > >
> > > >> > > > >
> > > >> > > > >
> > > >> > > >
> > > >> > > >
> > > >> > >
> > > >> > >
> > > >> > >
> > > >> >
> > > >> >
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > > > --
> > > > Cordialement.
> > > > Philippe Mouawad.
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
> 
> 



Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
First, big thanks for your help on this, it is really valuable ! And I
really appreciate your patience .
Second, I  made a mistake in my test case of HTTPCLIENT-1705 JIRA issue,
which I fixed and reuploaded tonight few seconds ago.
Third, we wanted to release a version by either end of year or begining of
next year.

Is migration to HC5.0 a big thing ? Do you advise to target 4.5.2 or 5.0 ?
the alpha state of 5.0 seems risky to me.

Thanks
Regards
Philippe


On Wed, Dec 16, 2015 at 1:57 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Tue, 2015-12-15 at 14:16 +0100, Philippe Mouawad wrote:
> > Hi ,
> > One last question, when is release of 4.5.2 expected as it fixes 2 bugs
> we
> > are facing in JMeter.
> >
> > Thanks
> > Regards
> >
>
> Philippe
>
> I was not planning to do HC 4.5.2 any time soon. I would very much
> rather get the first alpha of HC 5.0. How soon do you need it?
>
> Oleg
>
>
> > On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> > >
> > >
> > > On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> > > wrote:
> > >
> > >> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> > >> > Hello Oleg,
> > >> > Thanks .
> > >> >
> > >>
> > >> Test case #testParseCookies
> > >>
> > >> The rest case does not look right to me. I am not sure I understand
> what
> > >> you are trying to test here.
> > >>
> > > Indeed, bad copy paste.
> > >
> > > The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> > > JMeter side.
> > >
> > >>
> > >> Test case #testParseCookies
> > >>
> > >>
> > >
> > >> The cookie in question does not have a version attribute mandatory for
> > >> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> > >> Netscape style cookie in which case comma is not considered a valid
> > >> header element delimiter and is treated as normal character.
> > >>
> > >
> > > Thanks for explanation.
> > > Note that test case worked fine in HC3. Was it a bug in HC3 ?
> > >
> > >
> > >>
> > >> Oleg
> > >>
> > >>
> > >> > Here it is:
> > >> >
> > >> > /*
> > >> >  *
> ====================================================================
> > >> >  * 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
> > >> >  * "License"); 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
> > >> >  * "AS IS" 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.
> > >> >  *
> ====================================================================
> > >> >  *
> > >> >  * This software consists of voluntary contributions made by many
> > >> >  * individuals on behalf of the Apache Software Foundation.  For
> more
> > >> >  * information on the Apache Software Foundation, please see
> > >> >  * <http://www.apache.org/>.
> > >> >  *
> > >> >  */
> > >> > package org.apache.http.client.protocol;
> > >> >
> > >> > import java.util.List;
> > >> >
> > >> > import org.apache.http.Header;
> > >> > import org.apache.http.HttpResponse;
> > >> > import org.apache.http.HttpResponseInterceptor;
> > >> > import org.apache.http.HttpVersion;
> > >> > import org.apache.http.client.CookieStore;
> > >> > import org.apache.http.cookie.Cookie;
> > >> > import org.apache.http.cookie.CookieOrigin;
> > >> > import org.apache.http.cookie.CookieSpec;
> > >> > import org.apache.http.cookie.SM;
> > >> > import org.apache.http.impl.client.BasicCookieStore;
> > >> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> > >> > import org.apache.http.message.BasicHttpResponse;
> > >> > import org.apache.http.util.Asserts;
> > >> > import org.junit.Assert;
> > >> > import org.junit.Before;
> > >> > import org.junit.Test;
> > >> >
> > >> > public class TestResponseProcessCookies {
> > >> >
> > >> >     private CookieOrigin cookieOrigin;
> > >> >     private CookieSpec cookieSpec;
> > >> >     private CookieStore cookieStore;
> > >> >
> > >> >     @Before
> > >> >     public void setUp() throws Exception {
> > >> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> > >> false);
> > >> >         this.cookieSpec = new DefaultCookieSpec();
> > >> >         this.cookieStore = new BasicCookieStore();
> > >> >     }
> > >> >
> > >> >     @Test(expected=IllegalArgumentException.class)
> > >> >     public void testResponseParameterCheck() throws Exception {
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(null, context);
> > >> >     }
> > >> >
> > >> >     @Test(expected=IllegalArgumentException.class)
> > >> >     public void testContextParameterCheck() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, null);
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testParseMultipleCookies() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;
> comment=\"how,now\",
> > >> > test2=2; version=1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(1, cookies.size());
> > >> >         final Cookie cookie = cookies.get(0);
> > >> >         Assert.assertEquals(0, cookie.getVersion());
> > >> >         Assert.assertEquals("name1", cookie.getName());
> > >> >         Assert.assertEquals("value1", cookie.getValue());
> > >> >         Assert.assertEquals("localhost", cookie.getDomain());
> > >> >         Assert.assertEquals("/", cookie.getPath());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testParseCookies() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >> >         StringBuilder sbHdr = new StringBuilder();
> > >> >         for (Header header : lstHdr) {
> > >> >             sbHdr.append(header.getValue());
> > >> >         }
> > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > >> sbHdr.toString());
> > >> >     }
> > >> >     @Test
> > >> >     public void testParseCookies2() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > >> test2=2;secure");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >> >         StringBuilder sbHdr = new StringBuilder();
> > >> >         for (Header header : lstHdr) {
> > >> >             sbHdr.append(header.getValue());
> > >> >         }
> > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > >> sbHdr.toString());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testNoCookieOrigin() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(0, cookies.size());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testNoCookieSpec() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(0, cookies.size());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testNoCookieStore() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(0, cookies.size());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testSetCookie2OverrideSetCookie() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> Version=1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(1, cookies.size());
> > >> >         final Cookie cookie = cookies.get(0);
> > >> >         Assert.assertEquals(1, cookie.getVersion());
> > >> >         Assert.assertEquals("name1", cookie.getName());
> > >> >         Assert.assertEquals("value2", cookie.getValue());
> > >> >         Assert.assertEquals("localhost.local", cookie.getDomain());
> > >> >         Assert.assertEquals("/", cookie.getPath());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testInvalidHeader() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE2, "name=value;
> Version=crap");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertTrue(cookies.isEmpty());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testCookieRejected() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> > >> > www.somedomain.com; Version=1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertTrue(cookies.isEmpty());
> > >> >     }
> > >> >
> > >> > }
> > >> >
> > >> >
> > >> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> olegk@apache.org>
> > >> wrote:
> > >> >
> > >> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > >> > > > Finally, for those  2 I am not sure  as per RFC6265, to use
> them ,
> > >> put
> > >> > > code
> > >> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > >> > > > They worked with HC3 but it does not mean they should work with
> > >> HC4, but
> > >> > > I
> > >> > > > would like a confirmation:
> > >> > > >
> > >> > >
> > >> > > I cannot get the tests to compile due to missing instance
> variables
> > >> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look
> if
> > >> you
> > >> > > post the complete class.
> > >> > >
> > >> > > Oleg
> > >> > >
> > >> > >
> > >> > > >
> > >> > > >     @Test
> > >> > > >     public void testParseCookies() throws Exception {
> > >> > > >         final HttpResponse response = new
> > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> > > >
> > >> > > >         final HttpClientContext context =
> > >> HttpClientContext.create();
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > > > this.cookieOrigin);
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > > > this.cookieSpec);
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > > > this.cookieStore);
> > >> > > >
> > >> > > >         final HttpResponseInterceptor interceptor = new
> > >> > > > ResponseProcessCookies();
> > >> > > >         interceptor.process(response, context);
> > >> > > >
> > >> > > >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > >> > > >         for (Header header : lstHdr) {
> > >> > > >             sbHdr.append(header.getValue());
> > >> > > >         }
> > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > >> > > sbHdr.toString());
> > >> > > >     }
> > >> > > >     @Test
> > >> > > >     public void testParseCookies2() throws Exception {
> > >> > > >         final HttpResponse response = new
> > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > >> > > test2=2;secure");
> > >> > > >
> > >> > > >         final HttpClientContext context =
> > >> HttpClientContext.create();
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > > > this.cookieOrigin);
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > > > this.cookieSpec);
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > > > this.cookieStore);
> > >> > > >
> > >> > > >         final HttpResponseInterceptor interceptor = new
> > >> > > > ResponseProcessCookies();
> > >> > > >         interceptor.process(response, context);
> > >> > > >
> > >> > > >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > >> > > >         for (Header header : lstHdr) {
> > >> > > >             sbHdr.append(header.getValue());
> > >> > > >         }
> > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > >> > > sbHdr.toString());
> > >> > > >     }
> > >> > > >
> > >> > > > Thanks
> > >> > > >
> > >> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > >> > > > philippe.mouawad@gmail.com> wrote:
> > >> > > >
> > >> > > > > Hi,
> > >> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > >> with a
> > >> > > Test
> > >> > > > > case in it to show issue with Domain starting with ".".
> > >> > > > >
> > >> > > > >
> > >> > > > > Regards
> > >> > > > >
> > >> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > >> > > > > philippe.mouawad@gmail.com> wrote:
> > >> > > > >
> > >> > > > >> Hi Oleg,
> > >> > > > >> Created
> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > >> to show
> > >> > > > >> issue with Cookie Header ordering.
> > >> > > > >>
> > >> > > > >> Regards
> > >> > > > >>
> > >> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > >> > > > >> philippe.mouawad@gmail.com> wrote:
> > >> > > > >>
> > >> > > > >>> Hi,
> > >> > > > >>>  I created
> > >> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > >> > > with
> > >> > > > >>> JUnit test case so that you understand the difference we
> have.
> > >> > > > >>>
> > >> > > > >>> Regards
> > >> > > > >>>
> > >> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> > >> olegk@apache.org>
> > >> > > > >>> wrote:
> > >> > > > >>>
> > >> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > >> > > > >>>> > Thanks Oleg.
> > >> > > > >>>> > But look at
> > >> > > > >>>> >
> > >> > > > >>>>
> > >> > >
> > >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > >> > > > >>>> ,
> > >> > > > >>>> > it concerns IGNORE_POLICY
> > >> > > > >>>> >
> > >> > > > >>>> > I really think there is at least one bug.
> > >> > > > >>>> > Regards
> > >> > > > >>>> >
> > >> > > > >>>>
> > >> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
> > >> Could
> > >> > > you
> > >> > > > >>>> please though reproduce them with unit tests that do not
> > >> involve
> > >> > > JMeter
> > >> > > > >>>> specific code?
> > >> > > > >>>>
> > >> > > > >>>> Oleg
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > >> > > olegk@apache.org>
> > >> > > > >>>> wrote:
> > >> > > > >>>> >
> > >> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> wrote:
> > >> > > > >>>> > > > Hi Oleg,
> > >> > > > >>>> > > > Thanks for answer.
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > Find my answers inline.
> > >> > > > >>>> > > > Regards
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > >> > > > >>>> olegk@apache.org>
> > >> > > > >>>> > > wrote:
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> > >> wrote:
> > >> > > > >>>> > > > > > Hello,
> > >> > > > >>>> > > > > > Any answer on this question ?
> > >> > > > >>>> > > > > > Thanks
> > >> > > > >>>> > > > > > Regards
> > >> > > > >>>> > > > > >
> > >> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe
> Mouawad <
> > >> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > >> > > > >>>> > > > > >
> > >> > > > >>>> > > > > > > Hello,
> > >> > > > >>>> > > > > > > We're in the process of migrating JMeter to
> last
> > >> > > HttpClient
> > >> > > > >>>> 4.5.1.
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > > > > We are now migrating the CookieManager to
> remove
> > >> all
> > >> > > > >>>> deprecated
> > >> > > > >>>> > > code.
> > >> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > >
> > >> > > > >>>> > >
> > >> > > > >>>>
> > >> > >
> > >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > > > > Before migration, it was still testing HC3
> version.
> > >> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> > >> > > failures:
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > >
> > >> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > >> > > > >>>> > > >
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use
> HC4
> > >> > > > >>>> Implementation
> > >> > > > >>>> > > of
> > >> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
> > >> compared to
> > >> > > > >>>> HC3.
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got
> other
> > >> > > failures
> > >> > > > >>>> all
> > >> > > > >>>> > > > detailed in initial mail.
> > >> > > > >>>> > > >
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > What policy does
> > >> > > > >>>> > > > > CookeManager use internally?
> > >> > > > >>>> > > > >
> > >> > > > >>>> > > > It depends on tests, you can see in the code that
> > >> depending on
> > >> > > > >>>> test
> > >> > > > >>>> > > method
> > >> > > > >>>> > > > we set different Policy to test them.
> > >> > > > >>>> > > >
> > >> > > > >>>> > >
> > >> > > > >>>> > > You ought to be using RFC6265 policy either in strict
> or
> > >> relaxed
> > >> > > > >>>> mode
> > >> > > > >>>> > > and nothing else. All other policies have been marked
> as
> > >> > > obsolete
> > >> > > > >>>> and
> > >> > > > >>>> > > have already been removed in 5.0 (trunk).
> > >> > > > >>>> > >
> > >> > > > >>>> > > Oleg
> > >> > > > >>>> > >
> > >> > > > >>>> > >
> > >> > > > >>>> > >
> > >> > > > >>>>
> > >> > >
> ---------------------------------------------------------------------
> > >> > > > >>>> > > To unsubscribe, e-mail:
> > >> > > httpclient-users-unsubscribe@hc.apache.org
> > >> > > > >>>> > > For additional commands, e-mail:
> > >> > > > >>>> httpclient-users-help@hc.apache.org
> > >> > > > >>>> > >
> > >> > > > >>>> > >
> > >> > > > >>>> >
> > >> > > > >>>> >
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > >
> ---------------------------------------------------------------------
> > >> > > > >>>> To unsubscribe, e-mail:
> > >> httpclient-users-unsubscribe@hc.apache.org
> > >> > > > >>>> For additional commands, e-mail:
> > >> > > httpclient-users-help@hc.apache.org
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > > > >>>
> > >> > > > >>>
> > >> > > > >>> --
> > >> > > > >>> Cordialement.
> > >> > > > >>> Philippe Mouawad.
> > >> > > > >>>
> > >> > > > >>>
> > >> > > > >>>
> > >> > > > >>
> > >> > > > >>
> > >> > > > >> --
> > >> > > > >> Cordialement.
> > >> > > > >> Philippe Mouawad.
> > >> > > > >>
> > >> > > > >>
> > >> > > > >>
> > >> > > > >
> > >> > > > >
> > >> > > > > --
> > >> > > > > Cordialement.
> > >> > > > > Philippe Mouawad.
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > >
> > >> > > >
> > >> > >
> > >> > >
> > >> > >
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >
> > >
> > > --
> > > Cordialement.
> > > Philippe Mouawad.
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
First, big thanks for your help on this, it is really valuable ! And I
really appreciate your patience .
Second, I  made a mistake in my test case of HTTPCLIENT-1705 JIRA issue,
which I fixed and reuploaded tonight few seconds ago.
Third, we wanted to release a version by either end of year or begining of
next year.

Is migration to HC5.0 a big thing ? Do you advise to target 4.5.2 or 5.0 ?
the alpha state of 5.0 seems risky to me.

Thanks
Regards
Philippe


On Wed, Dec 16, 2015 at 1:57 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Tue, 2015-12-15 at 14:16 +0100, Philippe Mouawad wrote:
> > Hi ,
> > One last question, when is release of 4.5.2 expected as it fixes 2 bugs
> we
> > are facing in JMeter.
> >
> > Thanks
> > Regards
> >
>
> Philippe
>
> I was not planning to do HC 4.5.2 any time soon. I would very much
> rather get the first alpha of HC 5.0. How soon do you need it?
>
> Oleg
>
>
> > On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> > >
> > >
> > > On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> > > wrote:
> > >
> > >> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> > >> > Hello Oleg,
> > >> > Thanks .
> > >> >
> > >>
> > >> Test case #testParseCookies
> > >>
> > >> The rest case does not look right to me. I am not sure I understand
> what
> > >> you are trying to test here.
> > >>
> > > Indeed, bad copy paste.
> > >
> > > The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> > > JMeter side.
> > >
> > >>
> > >> Test case #testParseCookies
> > >>
> > >>
> > >
> > >> The cookie in question does not have a version attribute mandatory for
> > >> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> > >> Netscape style cookie in which case comma is not considered a valid
> > >> header element delimiter and is treated as normal character.
> > >>
> > >
> > > Thanks for explanation.
> > > Note that test case worked fine in HC3. Was it a bug in HC3 ?
> > >
> > >
> > >>
> > >> Oleg
> > >>
> > >>
> > >> > Here it is:
> > >> >
> > >> > /*
> > >> >  *
> ====================================================================
> > >> >  * 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
> > >> >  * "License"); 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
> > >> >  * "AS IS" 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.
> > >> >  *
> ====================================================================
> > >> >  *
> > >> >  * This software consists of voluntary contributions made by many
> > >> >  * individuals on behalf of the Apache Software Foundation.  For
> more
> > >> >  * information on the Apache Software Foundation, please see
> > >> >  * <http://www.apache.org/>.
> > >> >  *
> > >> >  */
> > >> > package org.apache.http.client.protocol;
> > >> >
> > >> > import java.util.List;
> > >> >
> > >> > import org.apache.http.Header;
> > >> > import org.apache.http.HttpResponse;
> > >> > import org.apache.http.HttpResponseInterceptor;
> > >> > import org.apache.http.HttpVersion;
> > >> > import org.apache.http.client.CookieStore;
> > >> > import org.apache.http.cookie.Cookie;
> > >> > import org.apache.http.cookie.CookieOrigin;
> > >> > import org.apache.http.cookie.CookieSpec;
> > >> > import org.apache.http.cookie.SM;
> > >> > import org.apache.http.impl.client.BasicCookieStore;
> > >> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> > >> > import org.apache.http.message.BasicHttpResponse;
> > >> > import org.apache.http.util.Asserts;
> > >> > import org.junit.Assert;
> > >> > import org.junit.Before;
> > >> > import org.junit.Test;
> > >> >
> > >> > public class TestResponseProcessCookies {
> > >> >
> > >> >     private CookieOrigin cookieOrigin;
> > >> >     private CookieSpec cookieSpec;
> > >> >     private CookieStore cookieStore;
> > >> >
> > >> >     @Before
> > >> >     public void setUp() throws Exception {
> > >> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> > >> false);
> > >> >         this.cookieSpec = new DefaultCookieSpec();
> > >> >         this.cookieStore = new BasicCookieStore();
> > >> >     }
> > >> >
> > >> >     @Test(expected=IllegalArgumentException.class)
> > >> >     public void testResponseParameterCheck() throws Exception {
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(null, context);
> > >> >     }
> > >> >
> > >> >     @Test(expected=IllegalArgumentException.class)
> > >> >     public void testContextParameterCheck() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, null);
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testParseMultipleCookies() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;
> comment=\"how,now\",
> > >> > test2=2; version=1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(1, cookies.size());
> > >> >         final Cookie cookie = cookies.get(0);
> > >> >         Assert.assertEquals(0, cookie.getVersion());
> > >> >         Assert.assertEquals("name1", cookie.getName());
> > >> >         Assert.assertEquals("value1", cookie.getValue());
> > >> >         Assert.assertEquals("localhost", cookie.getDomain());
> > >> >         Assert.assertEquals("/", cookie.getPath());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testParseCookies() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >> >         StringBuilder sbHdr = new StringBuilder();
> > >> >         for (Header header : lstHdr) {
> > >> >             sbHdr.append(header.getValue());
> > >> >         }
> > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > >> sbHdr.toString());
> > >> >     }
> > >> >     @Test
> > >> >     public void testParseCookies2() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > >> test2=2;secure");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >> >         StringBuilder sbHdr = new StringBuilder();
> > >> >         for (Header header : lstHdr) {
> > >> >             sbHdr.append(header.getValue());
> > >> >         }
> > >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > >> sbHdr.toString());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testNoCookieOrigin() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(0, cookies.size());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testNoCookieSpec() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(0, cookies.size());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testNoCookieStore() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(0, cookies.size());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testSetCookie2OverrideSetCookie() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> >         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> Version=1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertEquals(1, cookies.size());
> > >> >         final Cookie cookie = cookies.get(0);
> > >> >         Assert.assertEquals(1, cookie.getVersion());
> > >> >         Assert.assertEquals("name1", cookie.getName());
> > >> >         Assert.assertEquals("value2", cookie.getValue());
> > >> >         Assert.assertEquals("localhost.local", cookie.getDomain());
> > >> >         Assert.assertEquals("/", cookie.getPath());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testInvalidHeader() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE2, "name=value;
> Version=crap");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertTrue(cookies.isEmpty());
> > >> >     }
> > >> >
> > >> >     @Test
> > >> >     public void testCookieRejected() throws Exception {
> > >> >         final HttpResponse response = new
> > >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> > >> > www.somedomain.com; Version=1");
> > >> >
> > >> >         final HttpClientContext context =
> HttpClientContext.create();
> > >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > this.cookieOrigin);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > this.cookieSpec);
> > >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > this.cookieStore);
> > >> >
> > >> >         final HttpResponseInterceptor interceptor = new
> > >> > ResponseProcessCookies();
> > >> >         interceptor.process(response, context);
> > >> >
> > >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >> >         Assert.assertNotNull(cookies);
> > >> >         Assert.assertTrue(cookies.isEmpty());
> > >> >     }
> > >> >
> > >> > }
> > >> >
> > >> >
> > >> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> olegk@apache.org>
> > >> wrote:
> > >> >
> > >> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > >> > > > Finally, for those  2 I am not sure  as per RFC6265, to use
> them ,
> > >> put
> > >> > > code
> > >> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > >> > > > They worked with HC3 but it does not mean they should work with
> > >> HC4, but
> > >> > > I
> > >> > > > would like a confirmation:
> > >> > > >
> > >> > >
> > >> > > I cannot get the tests to compile due to missing instance
> variables
> > >> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look
> if
> > >> you
> > >> > > post the complete class.
> > >> > >
> > >> > > Oleg
> > >> > >
> > >> > >
> > >> > > >
> > >> > > >     @Test
> > >> > > >     public void testParseCookies() throws Exception {
> > >> > > >         final HttpResponse response = new
> > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >> > > >
> > >> > > >         final HttpClientContext context =
> > >> HttpClientContext.create();
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > > > this.cookieOrigin);
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > > > this.cookieSpec);
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > > > this.cookieStore);
> > >> > > >
> > >> > > >         final HttpResponseInterceptor interceptor = new
> > >> > > > ResponseProcessCookies();
> > >> > > >         interceptor.process(response, context);
> > >> > > >
> > >> > > >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > >> > > >         for (Header header : lstHdr) {
> > >> > > >             sbHdr.append(header.getValue());
> > >> > > >         }
> > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > >> > > sbHdr.toString());
> > >> > > >     }
> > >> > > >     @Test
> > >> > > >     public void testParseCookies2() throws Exception {
> > >> > > >         final HttpResponse response = new
> > >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > >> > > test2=2;secure");
> > >> > > >
> > >> > > >         final HttpClientContext context =
> > >> HttpClientContext.create();
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > >> > > > this.cookieOrigin);
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > >> > > > this.cookieSpec);
> > >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > >> > > > this.cookieStore);
> > >> > > >
> > >> > > >         final HttpResponseInterceptor interceptor = new
> > >> > > > ResponseProcessCookies();
> > >> > > >         interceptor.process(response, context);
> > >> > > >
> > >> > > >         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> > >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >> > > >         StringBuilder sbHdr = new StringBuilder();
> > >> > > >         for (Header header : lstHdr) {
> > >> > > >             sbHdr.append(header.getValue());
> > >> > > >         }
> > >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > >> > > sbHdr.toString());
> > >> > > >     }
> > >> > > >
> > >> > > > Thanks
> > >> > > >
> > >> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > >> > > > philippe.mouawad@gmail.com> wrote:
> > >> > > >
> > >> > > > > Hi,
> > >> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > >> with a
> > >> > > Test
> > >> > > > > case in it to show issue with Domain starting with ".".
> > >> > > > >
> > >> > > > >
> > >> > > > > Regards
> > >> > > > >
> > >> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > >> > > > > philippe.mouawad@gmail.com> wrote:
> > >> > > > >
> > >> > > > >> Hi Oleg,
> > >> > > > >> Created
> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> > >> to show
> > >> > > > >> issue with Cookie Header ordering.
> > >> > > > >>
> > >> > > > >> Regards
> > >> > > > >>
> > >> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > >> > > > >> philippe.mouawad@gmail.com> wrote:
> > >> > > > >>
> > >> > > > >>> Hi,
> > >> > > > >>>  I created
> > >> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > >> > > with
> > >> > > > >>> JUnit test case so that you understand the difference we
> have.
> > >> > > > >>>
> > >> > > > >>> Regards
> > >> > > > >>>
> > >> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> > >> olegk@apache.org>
> > >> > > > >>> wrote:
> > >> > > > >>>
> > >> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > >> > > > >>>> > Thanks Oleg.
> > >> > > > >>>> > But look at
> > >> > > > >>>> >
> > >> > > > >>>>
> > >> > >
> > >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > >> > > > >>>> ,
> > >> > > > >>>> > it concerns IGNORE_POLICY
> > >> > > > >>>> >
> > >> > > > >>>> > I really think there is at least one bug.
> > >> > > > >>>> > Regards
> > >> > > > >>>> >
> > >> > > > >>>>
> > >> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
> > >> Could
> > >> > > you
> > >> > > > >>>> please though reproduce them with unit tests that do not
> > >> involve
> > >> > > JMeter
> > >> > > > >>>> specific code?
> > >> > > > >>>>
> > >> > > > >>>> Oleg
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > >> > > olegk@apache.org>
> > >> > > > >>>> wrote:
> > >> > > > >>>> >
> > >> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> wrote:
> > >> > > > >>>> > > > Hi Oleg,
> > >> > > > >>>> > > > Thanks for answer.
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > Find my answers inline.
> > >> > > > >>>> > > > Regards
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > >> > > > >>>> olegk@apache.org>
> > >> > > > >>>> > > wrote:
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> > >> wrote:
> > >> > > > >>>> > > > > > Hello,
> > >> > > > >>>> > > > > > Any answer on this question ?
> > >> > > > >>>> > > > > > Thanks
> > >> > > > >>>> > > > > > Regards
> > >> > > > >>>> > > > > >
> > >> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe
> Mouawad <
> > >> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > >> > > > >>>> > > > > >
> > >> > > > >>>> > > > > > > Hello,
> > >> > > > >>>> > > > > > > We're in the process of migrating JMeter to
> last
> > >> > > HttpClient
> > >> > > > >>>> 4.5.1.
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > > > > We are now migrating the CookieManager to
> remove
> > >> all
> > >> > > > >>>> deprecated
> > >> > > > >>>> > > code.
> > >> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > >
> > >> > > > >>>> > >
> > >> > > > >>>>
> > >> > >
> > >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > > > > Before migration, it was still testing HC3
> version.
> > >> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> > >> > > failures:
> > >> > > > >>>> > > > > > >
> > >> > > > >>>> > > > >
> > >> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > >> > > > >>>> > > >
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use
> HC4
> > >> > > > >>>> Implementation
> > >> > > > >>>> > > of
> > >> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
> > >> compared to
> > >> > > > >>>> HC3.
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got
> other
> > >> > > failures
> > >> > > > >>>> all
> > >> > > > >>>> > > > detailed in initial mail.
> > >> > > > >>>> > > >
> > >> > > > >>>> > > >
> > >> > > > >>>> > > > What policy does
> > >> > > > >>>> > > > > CookeManager use internally?
> > >> > > > >>>> > > > >
> > >> > > > >>>> > > > It depends on tests, you can see in the code that
> > >> depending on
> > >> > > > >>>> test
> > >> > > > >>>> > > method
> > >> > > > >>>> > > > we set different Policy to test them.
> > >> > > > >>>> > > >
> > >> > > > >>>> > >
> > >> > > > >>>> > > You ought to be using RFC6265 policy either in strict
> or
> > >> relaxed
> > >> > > > >>>> mode
> > >> > > > >>>> > > and nothing else. All other policies have been marked
> as
> > >> > > obsolete
> > >> > > > >>>> and
> > >> > > > >>>> > > have already been removed in 5.0 (trunk).
> > >> > > > >>>> > >
> > >> > > > >>>> > > Oleg
> > >> > > > >>>> > >
> > >> > > > >>>> > >
> > >> > > > >>>> > >
> > >> > > > >>>>
> > >> > >
> ---------------------------------------------------------------------
> > >> > > > >>>> > > To unsubscribe, e-mail:
> > >> > > httpclient-users-unsubscribe@hc.apache.org
> > >> > > > >>>> > > For additional commands, e-mail:
> > >> > > > >>>> httpclient-users-help@hc.apache.org
> > >> > > > >>>> > >
> > >> > > > >>>> > >
> > >> > > > >>>> >
> > >> > > > >>>> >
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > >
> ---------------------------------------------------------------------
> > >> > > > >>>> To unsubscribe, e-mail:
> > >> httpclient-users-unsubscribe@hc.apache.org
> > >> > > > >>>> For additional commands, e-mail:
> > >> > > httpclient-users-help@hc.apache.org
> > >> > > > >>>>
> > >> > > > >>>>
> > >> > > > >>>
> > >> > > > >>>
> > >> > > > >>> --
> > >> > > > >>> Cordialement.
> > >> > > > >>> Philippe Mouawad.
> > >> > > > >>>
> > >> > > > >>>
> > >> > > > >>>
> > >> > > > >>
> > >> > > > >>
> > >> > > > >> --
> > >> > > > >> Cordialement.
> > >> > > > >> Philippe Mouawad.
> > >> > > > >>
> > >> > > > >>
> > >> > > > >>
> > >> > > > >
> > >> > > > >
> > >> > > > > --
> > >> > > > > Cordialement.
> > >> > > > > Philippe Mouawad.
> > >> > > > >
> > >> > > > >
> > >> > > > >
> > >> > > >
> > >> > > >
> > >> > >
> > >> > >
> > >> > >
> > >> >
> > >> >
> > >>
> > >>
> > >>
> > >
> > >
> > > --
> > > Cordialement.
> > > Philippe Mouawad.
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2015-12-15 at 14:16 +0100, Philippe Mouawad wrote:
> Hi ,
> One last question, when is release of 4.5.2 expected as it fixes 2 bugs we
> are facing in JMeter.
> 
> Thanks
> Regards
> 

Philippe

I was not planning to do HC 4.5.2 any time soon. I would very much
rather get the first alpha of HC 5.0. How soon do you need it?

Oleg


> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
> 
> >
> >
> > On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> >> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> >> > Hello Oleg,
> >> > Thanks .
> >> >
> >>
> >> Test case #testParseCookies
> >>
> >> The rest case does not look right to me. I am not sure I understand what
> >> you are trying to test here.
> >>
> > Indeed, bad copy paste.
> >
> > The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> > JMeter side.
> >
> >>
> >> Test case #testParseCookies
> >>
> >>
> >
> >> The cookie in question does not have a version attribute mandatory for
> >> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> >> Netscape style cookie in which case comma is not considered a valid
> >> header element delimiter and is treated as normal character.
> >>
> >
> > Thanks for explanation.
> > Note that test case worked fine in HC3. Was it a bug in HC3 ?
> >
> >
> >>
> >> Oleg
> >>
> >>
> >> > Here it is:
> >> >
> >> > /*
> >> >  * ====================================================================
> >> >  * 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
> >> >  * "License"); 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
> >> >  * "AS IS" 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.
> >> >  * ====================================================================
> >> >  *
> >> >  * This software consists of voluntary contributions made by many
> >> >  * individuals on behalf of the Apache Software Foundation.  For more
> >> >  * information on the Apache Software Foundation, please see
> >> >  * <http://www.apache.org/>.
> >> >  *
> >> >  */
> >> > package org.apache.http.client.protocol;
> >> >
> >> > import java.util.List;
> >> >
> >> > import org.apache.http.Header;
> >> > import org.apache.http.HttpResponse;
> >> > import org.apache.http.HttpResponseInterceptor;
> >> > import org.apache.http.HttpVersion;
> >> > import org.apache.http.client.CookieStore;
> >> > import org.apache.http.cookie.Cookie;
> >> > import org.apache.http.cookie.CookieOrigin;
> >> > import org.apache.http.cookie.CookieSpec;
> >> > import org.apache.http.cookie.SM;
> >> > import org.apache.http.impl.client.BasicCookieStore;
> >> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> >> > import org.apache.http.message.BasicHttpResponse;
> >> > import org.apache.http.util.Asserts;
> >> > import org.junit.Assert;
> >> > import org.junit.Before;
> >> > import org.junit.Test;
> >> >
> >> > public class TestResponseProcessCookies {
> >> >
> >> >     private CookieOrigin cookieOrigin;
> >> >     private CookieSpec cookieSpec;
> >> >     private CookieStore cookieStore;
> >> >
> >> >     @Before
> >> >     public void setUp() throws Exception {
> >> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> >> false);
> >> >         this.cookieSpec = new DefaultCookieSpec();
> >> >         this.cookieStore = new BasicCookieStore();
> >> >     }
> >> >
> >> >     @Test(expected=IllegalArgumentException.class)
> >> >     public void testResponseParameterCheck() throws Exception {
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(null, context);
> >> >     }
> >> >
> >> >     @Test(expected=IllegalArgumentException.class)
> >> >     public void testContextParameterCheck() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, null);
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testParseMultipleCookies() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
> >> > test2=2; version=1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(1, cookies.size());
> >> >         final Cookie cookie = cookies.get(0);
> >> >         Assert.assertEquals(0, cookie.getVersion());
> >> >         Assert.assertEquals("name1", cookie.getName());
> >> >         Assert.assertEquals("value1", cookie.getValue());
> >> >         Assert.assertEquals("localhost", cookie.getDomain());
> >> >         Assert.assertEquals("/", cookie.getPath());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testParseCookies() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >> >         StringBuilder sbHdr = new StringBuilder();
> >> >         for (Header header : lstHdr) {
> >> >             sbHdr.append(header.getValue());
> >> >         }
> >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> >> sbHdr.toString());
> >> >     }
> >> >     @Test
> >> >     public void testParseCookies2() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >> test2=2;secure");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >> >         StringBuilder sbHdr = new StringBuilder();
> >> >         for (Header header : lstHdr) {
> >> >             sbHdr.append(header.getValue());
> >> >         }
> >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> >> sbHdr.toString());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testNoCookieOrigin() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(0, cookies.size());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testNoCookieSpec() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(0, cookies.size());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testNoCookieStore() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(0, cookies.size());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testSetCookie2OverrideSetCookie() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(1, cookies.size());
> >> >         final Cookie cookie = cookies.get(0);
> >> >         Assert.assertEquals(1, cookie.getVersion());
> >> >         Assert.assertEquals("name1", cookie.getName());
> >> >         Assert.assertEquals("value2", cookie.getValue());
> >> >         Assert.assertEquals("localhost.local", cookie.getDomain());
> >> >         Assert.assertEquals("/", cookie.getPath());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testInvalidHeader() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertTrue(cookies.isEmpty());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testCookieRejected() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> >> > www.somedomain.com; Version=1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertTrue(cookies.isEmpty());
> >> >     }
> >> >
> >> > }
> >> >
> >> >
> >> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
> >> wrote:
> >> >
> >> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> >> > > > Finally, for those  2 I am not sure  as per RFC6265, to use them ,
> >> put
> >> > > code
> >> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> >> > > > They worked with HC3 but it does not mean they should work with
> >> HC4, but
> >> > > I
> >> > > > would like a confirmation:
> >> > > >
> >> > >
> >> > > I cannot get the tests to compile due to missing instance variables
> >> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look if
> >> you
> >> > > post the complete class.
> >> > >
> >> > > Oleg
> >> > >
> >> > >
> >> > > >
> >> > > >     @Test
> >> > > >     public void testParseCookies() throws Exception {
> >> > > >         final HttpResponse response = new
> >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> > > >
> >> > > >         final HttpClientContext context =
> >> HttpClientContext.create();
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > > > this.cookieOrigin);
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > > > this.cookieSpec);
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > > > this.cookieStore);
> >> > > >
> >> > > >         final HttpResponseInterceptor interceptor = new
> >> > > > ResponseProcessCookies();
> >> > > >         interceptor.process(response, context);
> >> > > >
> >> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >> > > >         StringBuilder sbHdr = new StringBuilder();
> >> > > >         for (Header header : lstHdr) {
> >> > > >             sbHdr.append(header.getValue());
> >> > > >         }
> >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> >> > > sbHdr.toString());
> >> > > >     }
> >> > > >     @Test
> >> > > >     public void testParseCookies2() throws Exception {
> >> > > >         final HttpResponse response = new
> >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >> > > test2=2;secure");
> >> > > >
> >> > > >         final HttpClientContext context =
> >> HttpClientContext.create();
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > > > this.cookieOrigin);
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > > > this.cookieSpec);
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > > > this.cookieStore);
> >> > > >
> >> > > >         final HttpResponseInterceptor interceptor = new
> >> > > > ResponseProcessCookies();
> >> > > >         interceptor.process(response, context);
> >> > > >
> >> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >> > > >         StringBuilder sbHdr = new StringBuilder();
> >> > > >         for (Header header : lstHdr) {
> >> > > >             sbHdr.append(header.getValue());
> >> > > >         }
> >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> >> > > sbHdr.toString());
> >> > > >     }
> >> > > >
> >> > > > Thanks
> >> > > >
> >> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> >> > > > philippe.mouawad@gmail.com> wrote:
> >> > > >
> >> > > > > Hi,
> >> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >> with a
> >> > > Test
> >> > > > > case in it to show issue with Domain starting with ".".
> >> > > > >
> >> > > > >
> >> > > > > Regards
> >> > > > >
> >> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> >> > > > > philippe.mouawad@gmail.com> wrote:
> >> > > > >
> >> > > > >> Hi Oleg,
> >> > > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >> to show
> >> > > > >> issue with Cookie Header ordering.
> >> > > > >>
> >> > > > >> Regards
> >> > > > >>
> >> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >> > > > >> philippe.mouawad@gmail.com> wrote:
> >> > > > >>
> >> > > > >>> Hi,
> >> > > > >>>  I created
> >> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> >> > > with
> >> > > > >>> JUnit test case so that you understand the difference we have.
> >> > > > >>>
> >> > > > >>> Regards
> >> > > > >>>
> >> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> >> olegk@apache.org>
> >> > > > >>> wrote:
> >> > > > >>>
> >> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> >> > > > >>>> > Thanks Oleg.
> >> > > > >>>> > But look at
> >> > > > >>>> >
> >> > > > >>>>
> >> > >
> >> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >> > > > >>>> ,
> >> > > > >>>> > it concerns IGNORE_POLICY
> >> > > > >>>> >
> >> > > > >>>> > I really think there is at least one bug.
> >> > > > >>>> > Regards
> >> > > > >>>> >
> >> > > > >>>>
> >> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
> >> Could
> >> > > you
> >> > > > >>>> please though reproduce them with unit tests that do not
> >> involve
> >> > > JMeter
> >> > > > >>>> specific code?
> >> > > > >>>>
> >> > > > >>>> Oleg
> >> > > > >>>>
> >> > > > >>>>
> >> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> >> > > olegk@apache.org>
> >> > > > >>>> wrote:
> >> > > > >>>> >
> >> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> >> > > > >>>> > > > Hi Oleg,
> >> > > > >>>> > > > Thanks for answer.
> >> > > > >>>> > > >
> >> > > > >>>> > > > Find my answers inline.
> >> > > > >>>> > > > Regards
> >> > > > >>>> > > >
> >> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >> > > > >>>> olegk@apache.org>
> >> > > > >>>> > > wrote:
> >> > > > >>>> > > >
> >> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> >> wrote:
> >> > > > >>>> > > > > > Hello,
> >> > > > >>>> > > > > > Any answer on this question ?
> >> > > > >>>> > > > > > Thanks
> >> > > > >>>> > > > > > Regards
> >> > > > >>>> > > > > >
> >> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> >> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> >> > > > >>>> > > > > >
> >> > > > >>>> > > > > > > Hello,
> >> > > > >>>> > > > > > > We're in the process of migrating JMeter to last
> >> > > HttpClient
> >> > > > >>>> 4.5.1.
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > > > > We are now migrating the CookieManager to remove
> >> all
> >> > > > >>>> deprecated
> >> > > > >>>> > > code.
> >> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > >
> >> > > > >>>> > >
> >> > > > >>>>
> >> > >
> >> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > > > > Before migration, it was still testing HC3 version.
> >> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> >> > > failures:
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > >
> >> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >> > > > >>>> > > >
> >> > > > >>>> > > >
> >> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> >> > > > >>>> Implementation
> >> > > > >>>> > > of
> >> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
> >> compared to
> >> > > > >>>> HC3.
> >> > > > >>>> > > >
> >> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> >> > > failures
> >> > > > >>>> all
> >> > > > >>>> > > > detailed in initial mail.
> >> > > > >>>> > > >
> >> > > > >>>> > > >
> >> > > > >>>> > > > What policy does
> >> > > > >>>> > > > > CookeManager use internally?
> >> > > > >>>> > > > >
> >> > > > >>>> > > > It depends on tests, you can see in the code that
> >> depending on
> >> > > > >>>> test
> >> > > > >>>> > > method
> >> > > > >>>> > > > we set different Policy to test them.
> >> > > > >>>> > > >
> >> > > > >>>> > >
> >> > > > >>>> > > You ought to be using RFC6265 policy either in strict or
> >> relaxed
> >> > > > >>>> mode
> >> > > > >>>> > > and nothing else. All other policies have been marked as
> >> > > obsolete
> >> > > > >>>> and
> >> > > > >>>> > > have already been removed in 5.0 (trunk).
> >> > > > >>>> > >
> >> > > > >>>> > > Oleg
> >> > > > >>>> > >
> >> > > > >>>> > >
> >> > > > >>>> > >
> >> > > > >>>>
> >> > > ---------------------------------------------------------------------
> >> > > > >>>> > > To unsubscribe, e-mail:
> >> > > httpclient-users-unsubscribe@hc.apache.org
> >> > > > >>>> > > For additional commands, e-mail:
> >> > > > >>>> httpclient-users-help@hc.apache.org
> >> > > > >>>> > >
> >> > > > >>>> > >
> >> > > > >>>> >
> >> > > > >>>> >
> >> > > > >>>>
> >> > > > >>>>
> >> > > > >>>>
> >> > > > >>>>
> >> > > ---------------------------------------------------------------------
> >> > > > >>>> To unsubscribe, e-mail:
> >> httpclient-users-unsubscribe@hc.apache.org
> >> > > > >>>> For additional commands, e-mail:
> >> > > httpclient-users-help@hc.apache.org
> >> > > > >>>>
> >> > > > >>>>
> >> > > > >>>
> >> > > > >>>
> >> > > > >>> --
> >> > > > >>> Cordialement.
> >> > > > >>> Philippe Mouawad.
> >> > > > >>>
> >> > > > >>>
> >> > > > >>>
> >> > > > >>
> >> > > > >>
> >> > > > >> --
> >> > > > >> Cordialement.
> >> > > > >> Philippe Mouawad.
> >> > > > >>
> >> > > > >>
> >> > > > >>
> >> > > > >
> >> > > > >
> >> > > > > --
> >> > > > > Cordialement.
> >> > > > > Philippe Mouawad.
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > >
> >> > > >
> >> > >
> >> > >
> >> > >
> >> >
> >> >
> >>
> >>
> >>
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
> >
> >
> >
> 
> 



Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Andrey Pokhilko <ap...@ya.ru>.
Unit tests looks fine.

Andrey Pokhilko

On 12/19/2015 01:44 AM, Philippe Mouawad wrote:
> Hi,
> I finalized with the great help of Oleg K. the work on CookieManager and
> the validation of TestCookieManager:
> - https://github.com/apache/jmeter/pull/64
>
> @Andrei, I added 2 tests for the ".bt.com" case:
> - testAddCookieFromHeaderWithWildcard
> - testAddCookieFromHeaderWithWildcard2
>
> Can you have a look and see if it answers your issue ?
>
> @Oleg, if you read this mailing list, and can have a look at the code it
> would be great.
>
> Thanks
>
>
> On Wed, Dec 16, 2015 at 9:01 AM, Andrey Pokhilko <ap...@ya.ru> wrote:
>
>> I reviewed the code for test case in the PR, looks fine.
>>
>> Andrey Pokhilko
>>
>> On 12/16/2015 01:06 AM, Philippe Mouawad wrote:
>>> Hi ,
>>> I think that's what I wrote no ?
>>> It's failing because at step 2 , as the domain is "bt.com" not ".bt.com
>> ",
>>> we don't send the cookie , so I suppose we break the test.
>>>
>>> I think in HC4.5 (as per answer of Oleg on ) , domain matching occurs
>> based
>>> on (((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR))
>> as
>>> per BasicDomainHandler#match method used by NetscapeDraftSpec policy.
>>> So I think we need to modify the Cookie JMeter class to preserve this
>>> information which is used to match cookies to URL.
>>>
>>> Regards
>>>
>>>
>>> On Tue, Dec 15, 2015 at 10:48 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>
>>>> No.
>>>>
>>>> Right test case is:
>>>> 1. we get cookie for domain .bt.com
>>>> 2. We do request to sub.bt.com and expect to send the cookie
>>>>
>>>> That's the case that was broken with upgrading to 0.4.5 in our field
>> tries.
>>>> Andrey Pokhilko
>>>>
>>>> On 12/16/2015 12:44 AM, Philippe Mouawad wrote:
>>>>> Hi Andrei,
>>>>> I  am not sure to understand.
>>>>>
>>>>> If you look at my test case sent to HTTPCLIENT, the cookie is
>> transmitted
>>>>> for subdomain.bt.com except that domain has value bt.com not ".bt.com
>> ".
>>>>> Do you mean that as on jmeter side , we get "bt.com" as domain, we
>> don't
>>>>> transmit in next request the cookie for subdomain.bt.com ?
>>>>>
>>>>> Thanks
>>>>>
>>>>> On Tue, Dec 15, 2015 at 10:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>>>
>>>>>> The impact of it is broken test plans. When cookie is set for .bt.com
>> ,
>>>>>> it means that subdomain.bt.com must receive that cookie. That's by
>> RFC
>>>>>> AFAIK.
>>>>>>
>>>>>> Andrey Pokhilko
>>>>>>
>>>>>> On 12/15/2015 11:41 PM, Philippe Mouawad wrote:
>>>>>>> Hi Andrey,
>>>>>>> Test case is failing, but it seems to be a regular HC4.5 behaviour.
>>>>>>>
>>>>>>> What was the impact of this failing test case on JMeter side ?
>>>>>>> It's not clear for me from your mail, if you can give a full example
>>>> with
>>>>>>> each step it wil help me understand.
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> On Tue, Dec 15, 2015 at 5:56 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>>>>>
>>>>>>>> It's one from 10/27/2015 06:32 PM:
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> Today we've found an issue in using HTTPClient 4.5 in JMeter. If we
>>>> just
>>>>>>>> replace the libraries with no change to JMeter code, it stops
>>>> processing
>>>>>>>> wildcard domains for cookies. I've failed to understand if it is
>>>>>>>> regression in HTTPClient or something else.
>>>>>>>>
>>>>>>>> I've managed to write a unit test for it, I can commit it into trunk
>>>> if
>>>>>>>> needed. Unit test works fine on old libraries, but fails with 4.5:
>>>>>>>>
>>>>>>>> package org.apache.jmeter.protocol.http.control;
>>>>>>>>
>>>>>>>> import org.apache.http.cookie.Cookie;
>>>>>>>> import org.apache.jmeter.testelement.property.CollectionProperty;
>>>>>>>> import org.junit.Assert;
>>>>>>>> import org.junit.Test;
>>>>>>>>
>>>>>>>> import java.net.URL;
>>>>>>>> import java.util.List;
>>>>>>>>
>>>>>>>> public class HC4CookieHandlerTest {
>>>>>>>>
>>>>>>>>     @Test public void testAddCookieFromHeader_wildcard() throws
>>>>>> Exception {
>>>>>>>>         HC4CookieHandler obj = new
>> HC4CookieHandler("compatibility");
>>>>>>>>         URL url = new URL("https://subdomain.bt.com/page");
>>>>>>>>         CookieManager mgr = new CookieManager();
>>>>>>>>         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
>>>>>>>>         obj.addCookieFromHeader(mgr, true, headerLine, url);
>>>>>>>>         CollectionProperty cp = mgr.getCookies();
>>>>>>>>         List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
>>>>>>>>         Assert.assertEquals(1, res.size());
>>>>>>>>         for (Cookie cookie : res) {
>>>>>>>>             Assert.assertEquals(".bt.com", cookie.getDomain());
>>>>>>>>         }
>>>>>>>>     }
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Andrey Pokhilko
>>>>>>>>
>>>>>>>> On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
>>>>>>>>> I was searching in my mails for it :-) Andrei
>>>>>>>>>
>>>>>>>>> On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru>
>> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> First of all - you've made awesome job on coordinating all this
>>>>>> tedious
>>>>>>>>>> communications with Oleg. Thanks, your contribution is invaluable
>> in
>>>>>> my
>>>>>>>>>> eyes.
>>>>>>>>>>
>>>>>>>>>> Just a note - don't you want to include the test case I provided
>>>> some
>>>>>>>>>> time ago into this PR? To make sure the initial  case that
>> revealed
>>>>>>>>>> issues finally works...
>>>>>>>>>>
>>>>>>>>>> Andrey Pokhilko
>>>>>>>>>>
>>>>>>>>>> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>> I submitted a PR https://github.com/apache/jmeter/pull/62  after
>>>>>>>> fixing
>>>>>>>>>> the
>>>>>>>>>>> remaining issues I think.
>>>>>>>>>>> I still have one failing test , related to
>>>>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I
>>>>>> reopened.
>>>>>>>>>>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we
>>>>>> need
>>>>>>>>>> 4.5.2
>>>>>>>>>>> I changed testCookies2 as per Oleg note and added testCookies3.
>>>>>>>>>>>
>>>>>>>>>>> Please review as this is very sensitive and I would really like a
>>>>>>>> second
>>>>>>>>>>> eye on it.
>>>>>>>>>>>
>>>>>>>>>>> Thanks
>>>>>>>>>>> Regards
>>>>>>>>>>>
>>>>>>>>>>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi ,
>>>>>>>>>>>> One last question, when is release of 4.5.2 expected as it
>> fixes 2
>>>>>>>> bugs
>>>>>>>>>> we
>>>>>>>>>>>> are facing in JMeter.
>>>>>>>>>>>>
>>>>>>>>>>>> Thanks
>>>>>>>>>>>> Regards
>>>>>>>>>>>>
>>>>>>>>>>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <
>>>>>> olegk@apache.org
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>>> Hello Oleg,
>>>>>>>>>>>>>>> Thanks .
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Test case #testParseCookies
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> The rest case does not look right to me. I am not sure I
>>>>>> understand
>>>>>>>>>> what
>>>>>>>>>>>>>> you are trying to test here.
>>>>>>>>>>>>>>
>>>>>>>>>>>>> Indeed, bad copy paste.
>>>>>>>>>>>>>
>>>>>>>>>>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue
>> is
>>>>>> on
>>>>>>>>>>>>> JMeter side.
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Test case #testParseCookies
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> The cookie in question does not have a version attribute
>>>> mandatory
>>>>>>>> for
>>>>>>>>>>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is
>> parsed
>>>>>> as
>>>>>>>>>>>>>> Netscape style cookie in which case comma is not considered a
>>>>>> valid
>>>>>>>>>>>>>> header element delimiter and is treated as normal character.
>>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks for explanation.
>>>>>>>>>>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Here it is:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> /*
>>>>>>>>>>>>>>>  *
>> ====================================================================
>>>>>>>>>>>>>>>  * 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
>>>>>>>>>>>>>>>  * "License"); 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
>>>>>>>>>>>>>>>  * "AS IS" 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.
>>>>>>>>>>>>>>>  *
>> ====================================================================
>>>>>>>>>>>>>>>  *
>>>>>>>>>>>>>>>  * This software consists of voluntary contributions made by
>>>> many
>>>>>>>>>>>>>>>  * individuals on behalf of the Apache Software Foundation.
>>>> For
>>>>>>>> more
>>>>>>>>>>>>>>>  * information on the Apache Software Foundation, please see
>>>>>>>>>>>>>>>  * <http://www.apache.org/>.
>>>>>>>>>>>>>>>  *
>>>>>>>>>>>>>>>  */
>>>>>>>>>>>>>>> package org.apache.http.client.protocol;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> import java.util.List;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> import org.apache.http.Header;
>>>>>>>>>>>>>>> import org.apache.http.HttpResponse;
>>>>>>>>>>>>>>> import org.apache.http.HttpResponseInterceptor;
>>>>>>>>>>>>>>> import org.apache.http.HttpVersion;
>>>>>>>>>>>>>>> import org.apache.http.client.CookieStore;
>>>>>>>>>>>>>>> import org.apache.http.cookie.Cookie;
>>>>>>>>>>>>>>> import org.apache.http.cookie.CookieOrigin;
>>>>>>>>>>>>>>> import org.apache.http.cookie.CookieSpec;
>>>>>>>>>>>>>>> import org.apache.http.cookie.SM;
>>>>>>>>>>>>>>> import org.apache.http.impl.client.BasicCookieStore;
>>>>>>>>>>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
>>>>>>>>>>>>>>> import org.apache.http.message.BasicHttpResponse;
>>>>>>>>>>>>>>> import org.apache.http.util.Asserts;
>>>>>>>>>>>>>>> import org.junit.Assert;
>>>>>>>>>>>>>>> import org.junit.Before;
>>>>>>>>>>>>>>> import org.junit.Test;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> public class TestResponseProcessCookies {
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     private CookieOrigin cookieOrigin;
>>>>>>>>>>>>>>>     private CookieSpec cookieSpec;
>>>>>>>>>>>>>>>     private CookieStore cookieStore;
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Before
>>>>>>>>>>>>>>>     public void setUp() throws Exception {
>>>>>>>>>>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80,
>>>>>> "/",
>>>>>>>>>>>>>> false);
>>>>>>>>>>>>>>>         this.cookieSpec = new DefaultCookieSpec();
>>>>>>>>>>>>>>>         this.cookieStore = new BasicCookieStore();
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>>>>>>>>>     public void testResponseParameterCheck() throws
>> Exception {
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(null, context);
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>>>>>>>>>     public void testContextParameterCheck() throws Exception
>> {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, null);
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testParseMultipleCookies() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
>>>>>>>>>>>>>> comment=\"how,now\",
>>>>>>>>>>>>>>> test2=2; version=1");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>>>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>>>>>>>>>         Assert.assertEquals(0, cookie.getVersion());
>>>>>>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>>>>>>>>>         Assert.assertEquals("value1", cookie.getValue());
>>>>>>>>>>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
>>>>>>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         List<Header> lstHdr =
>>>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>>>         }
>>>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>>>>>>>> test2=2;secure");
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         List<Header> lstHdr =
>>>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>>>         }
>>>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testNoCookieOrigin() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>> null);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testNoCookieSpec() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>> null);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testNoCookieStore() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>> null);
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testSetCookie2OverrideSetCookie() throws
>>>>>> Exception
>>>>>>>> {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
>>>>>>>>>> Version=1");
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>>>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>>>>>>>>>         Assert.assertEquals(1, cookie.getVersion());
>>>>>>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>>>>>>>>>         Assert.assertEquals("value2", cookie.getValue());
>>>>>>>>>>>>>>>         Assert.assertEquals("localhost.local",
>>>>>> cookie.getDomain());
>>>>>>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testInvalidHeader() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
>>>>>>>>>> Version=crap");
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testCookieRejected() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
>> Domain=
>>>>>>>>>>>>>>> www.somedomain.com; Version=1");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
>>>>>>>> olegk@apache.org
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use
>>>>>> them
>>>>>>>> ,
>>>>>>>>>>>>>> put
>>>>>>>>>>>>>>>> code
>>>>>>>>>>>>>>>>> in
>>>> org.apache.http.client.protocol.TestResponseProcessCookies.
>>>>>>>>>>>>>>>>> They worked with HC3 but it does not mean they should work
>>>> with
>>>>>>>>>>>>>> HC4, but
>>>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>>>> would like a confirmation:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I cannot get the tests to compile due to missing instance
>>>>>>>> variables
>>>>>>>>>>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another
>>>> look
>>>>>>>> if
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>> post the complete class.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>>>>>>>> HttpClientContext.create();
>>  context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>>>
>>  context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>>>         List<Header> lstHdr =
>>>>>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>>>>>         }
>>>>>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>>>>>>>>>> test2=2;secure");
>>>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>>>>>>>> HttpClientContext.create();
>>  context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>>>
>>  context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>>>         List<Header> lstHdr =
>>>>>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>>>>>         }
>>>>>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>> Created
>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>>>>>>>>>> with a
>>>>>>>>>>>>>>>> Test
>>>>>>>>>>>>>>>>>> case in it to show issue with Domain starting with ".".
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>>>>>>> Created
>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>>>>>>>>>> to show
>>>>>>>>>>>>>>>>>>> issue with Cookie Header ordering.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>>>>  I created
>>>>>>>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>>>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>>>>>>> JUnit test case so that you understand the difference we
>>>>>> have.
>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>>>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad
>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>> Thanks Oleg.
>>>>>>>>>>>>>>>>>>>>>> But look at
>>>>>>>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>>>>>>>>>>>>>>>>>>>> ,
>>>>>>>>>>>>>>>>>>>>>> it concerns IGNORE_POLICY
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> I really think there is at least one bug.
>>>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in
>>>> HC.
>>>>>>>>>>>>>> Could
>>>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>>>>>> please though reproduce them with unit tests that do
>> not
>>>>>>>>>>>>>> involve
>>>>>>>>>>>>>>>> JMeter
>>>>>>>>>>>>>>>>>>>>> specific code?
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>>>>>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>>>>>>>>>>>> Thanks for answer.
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>> Find my answers inline.
>>>>>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>>>>>>>>>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>>>>>>>>> Any answer on this question ?
>>>>>>>>>>>>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad
>> <
>>>>>>>>>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
>>>>>>>>>>>>>>>> HttpClient
>>>>>>>>>>>>>>>>>>>>> 4.5.1.
>>>>>>>>>>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
>>>>>>>>>>>>>> all
>>>>>>>>>>>>>>>>>>>>> deprecated
>>>>>>>>>>>>>>>>>>>>>>> code.
>>>>>>>>>>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>>>>>>>>>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
>>>>>>>>>>>>>> version.
>>>>>>>>>>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
>>>>>>>>>>>>>>>> failures:
>>>>>>>>>>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>>>>>>>>>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use
>>>> HC4
>>>>>>>>>>>>>>>>>>>>> Implementation
>>>>>>>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
>>>>>>>>>>>>>> compared to
>>>>>>>>>>>>>>>>>>>>> HC3.
>>>>>>>>>>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got
>>>> other
>>>>>>>>>>>>>>>> failures
>>>>>>>>>>>>>>>>>>>>> all
>>>>>>>>>>>>>>>>>>>>>>>> detailed in initial mail.
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>> What policy does
>>>>>>>>>>>>>>>>>>>>>>>>> CookeManager use internally?
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
>>>>>>>>>>>>>> depending on
>>>>>>>>>>>>>>>>>>>>> test
>>>>>>>>>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>>>>>>>>>>> we set different Policy to test them.
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict
>>>> or
>>>>>>>>>>>>>> relaxed
>>>>>>>>>>>>>>>>>>>>> mode
>>>>>>>>>>>>>>>>>>>>>>> and nothing else. All other policies have been marked
>>>> as
>>>>>>>>>>>>>>>> obsolete
>>>>>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>
>



Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
I finalized with the great help of Oleg K. the work on CookieManager and
the validation of TestCookieManager:
- https://github.com/apache/jmeter/pull/64

@Andrei, I added 2 tests for the ".bt.com" case:
- testAddCookieFromHeaderWithWildcard
- testAddCookieFromHeaderWithWildcard2

Can you have a look and see if it answers your issue ?

@Oleg, if you read this mailing list, and can have a look at the code it
would be great.

Thanks


On Wed, Dec 16, 2015 at 9:01 AM, Andrey Pokhilko <ap...@ya.ru> wrote:

> I reviewed the code for test case in the PR, looks fine.
>
> Andrey Pokhilko
>
> On 12/16/2015 01:06 AM, Philippe Mouawad wrote:
> > Hi ,
> > I think that's what I wrote no ?
> > It's failing because at step 2 , as the domain is "bt.com" not ".bt.com
> ",
> > we don't send the cookie , so I suppose we break the test.
> >
> > I think in HC4.5 (as per answer of Oleg on ) , domain matching occurs
> based
> > on (((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR))
> as
> > per BasicDomainHandler#match method used by NetscapeDraftSpec policy.
> > So I think we need to modify the Cookie JMeter class to preserve this
> > information which is used to match cookies to URL.
> >
> > Regards
> >
> >
> > On Tue, Dec 15, 2015 at 10:48 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >
> >> No.
> >>
> >> Right test case is:
> >> 1. we get cookie for domain .bt.com
> >> 2. We do request to sub.bt.com and expect to send the cookie
> >>
> >> That's the case that was broken with upgrading to 0.4.5 in our field
> tries.
> >>
> >> Andrey Pokhilko
> >>
> >> On 12/16/2015 12:44 AM, Philippe Mouawad wrote:
> >>> Hi Andrei,
> >>> I  am not sure to understand.
> >>>
> >>> If you look at my test case sent to HTTPCLIENT, the cookie is
> transmitted
> >>> for subdomain.bt.com except that domain has value bt.com not ".bt.com
> ".
> >>>
> >>> Do you mean that as on jmeter side , we get "bt.com" as domain, we
> don't
> >>> transmit in next request the cookie for subdomain.bt.com ?
> >>>
> >>> Thanks
> >>>
> >>> On Tue, Dec 15, 2015 at 10:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >>>
> >>>> The impact of it is broken test plans. When cookie is set for .bt.com
> ,
> >>>> it means that subdomain.bt.com must receive that cookie. That's by
> RFC
> >>>> AFAIK.
> >>>>
> >>>> Andrey Pokhilko
> >>>>
> >>>> On 12/15/2015 11:41 PM, Philippe Mouawad wrote:
> >>>>> Hi Andrey,
> >>>>> Test case is failing, but it seems to be a regular HC4.5 behaviour.
> >>>>>
> >>>>> What was the impact of this failing test case on JMeter side ?
> >>>>> It's not clear for me from your mail, if you can give a full example
> >> with
> >>>>> each step it wil help me understand.
> >>>>>
> >>>>> Thanks
> >>>>>
> >>>>> On Tue, Dec 15, 2015 at 5:56 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >>>>>
> >>>>>> It's one from 10/27/2015 06:32 PM:
> >>>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> Today we've found an issue in using HTTPClient 4.5 in JMeter. If we
> >> just
> >>>>>> replace the libraries with no change to JMeter code, it stops
> >> processing
> >>>>>> wildcard domains for cookies. I've failed to understand if it is
> >>>>>> regression in HTTPClient or something else.
> >>>>>>
> >>>>>> I've managed to write a unit test for it, I can commit it into trunk
> >> if
> >>>>>> needed. Unit test works fine on old libraries, but fails with 4.5:
> >>>>>>
> >>>>>> package org.apache.jmeter.protocol.http.control;
> >>>>>>
> >>>>>> import org.apache.http.cookie.Cookie;
> >>>>>> import org.apache.jmeter.testelement.property.CollectionProperty;
> >>>>>> import org.junit.Assert;
> >>>>>> import org.junit.Test;
> >>>>>>
> >>>>>> import java.net.URL;
> >>>>>> import java.util.List;
> >>>>>>
> >>>>>> public class HC4CookieHandlerTest {
> >>>>>>
> >>>>>>     @Test public void testAddCookieFromHeader_wildcard() throws
> >>>> Exception {
> >>>>>>         HC4CookieHandler obj = new
> HC4CookieHandler("compatibility");
> >>>>>>         URL url = new URL("https://subdomain.bt.com/page");
> >>>>>>         CookieManager mgr = new CookieManager();
> >>>>>>         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
> >>>>>>         obj.addCookieFromHeader(mgr, true, headerLine, url);
> >>>>>>         CollectionProperty cp = mgr.getCookies();
> >>>>>>         List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
> >>>>>>         Assert.assertEquals(1, res.size());
> >>>>>>         for (Cookie cookie : res) {
> >>>>>>             Assert.assertEquals(".bt.com", cookie.getDomain());
> >>>>>>         }
> >>>>>>     }
> >>>>>> }
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> Andrey Pokhilko
> >>>>>>
> >>>>>> On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
> >>>>>>> I was searching in my mails for it :-) Andrei
> >>>>>>>
> >>>>>>> On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru>
> wrote:
> >>>>>>>
> >>>>>>>> Hi,
> >>>>>>>>
> >>>>>>>> First of all - you've made awesome job on coordinating all this
> >>>> tedious
> >>>>>>>> communications with Oleg. Thanks, your contribution is invaluable
> in
> >>>> my
> >>>>>>>> eyes.
> >>>>>>>>
> >>>>>>>> Just a note - don't you want to include the test case I provided
> >> some
> >>>>>>>> time ago into this PR? To make sure the initial  case that
> revealed
> >>>>>>>> issues finally works...
> >>>>>>>>
> >>>>>>>> Andrey Pokhilko
> >>>>>>>>
> >>>>>>>> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
> >>>>>>>>> Hi,
> >>>>>>>>> I submitted a PR https://github.com/apache/jmeter/pull/62  after
> >>>>>> fixing
> >>>>>>>> the
> >>>>>>>>> remaining issues I think.
> >>>>>>>>> I still have one failing test , related to
> >>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I
> >>>> reopened.
> >>>>>>>>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we
> >>>> need
> >>>>>>>> 4.5.2
> >>>>>>>>> I changed testCookies2 as per Oleg note and added testCookies3.
> >>>>>>>>>
> >>>>>>>>> Please review as this is very sensitive and I would really like a
> >>>>>> second
> >>>>>>>>> eye on it.
> >>>>>>>>>
> >>>>>>>>> Thanks
> >>>>>>>>> Regards
> >>>>>>>>>
> >>>>>>>>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
> >>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>
> >>>>>>>>>> Hi ,
> >>>>>>>>>> One last question, when is release of 4.5.2 expected as it
> fixes 2
> >>>>>> bugs
> >>>>>>>> we
> >>>>>>>>>> are facing in JMeter.
> >>>>>>>>>>
> >>>>>>>>>> Thanks
> >>>>>>>>>> Regards
> >>>>>>>>>>
> >>>>>>>>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> >>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>
> >>>>>>>>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <
> >>>> olegk@apache.org
> >>>>>>>>>>> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>>>> Hello Oleg,
> >>>>>>>>>>>>> Thanks .
> >>>>>>>>>>>>>
> >>>>>>>>>>>> Test case #testParseCookies
> >>>>>>>>>>>>
> >>>>>>>>>>>> The rest case does not look right to me. I am not sure I
> >>>> understand
> >>>>>>>> what
> >>>>>>>>>>>> you are trying to test here.
> >>>>>>>>>>>>
> >>>>>>>>>>> Indeed, bad copy paste.
> >>>>>>>>>>>
> >>>>>>>>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue
> is
> >>>> on
> >>>>>>>>>>> JMeter side.
> >>>>>>>>>>>
> >>>>>>>>>>>> Test case #testParseCookies
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> The cookie in question does not have a version attribute
> >> mandatory
> >>>>>> for
> >>>>>>>>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is
> parsed
> >>>> as
> >>>>>>>>>>>> Netscape style cookie in which case comma is not considered a
> >>>> valid
> >>>>>>>>>>>> header element delimiter and is treated as normal character.
> >>>>>>>>>>>>
> >>>>>>>>>>> Thanks for explanation.
> >>>>>>>>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> Oleg
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>> Here it is:
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> /*
> >>>>>>>>>>>>>  *
> >>>>>>>>
> ====================================================================
> >>>>>>>>>>>>>  * 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
> >>>>>>>>>>>>>  * "License"); 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
> >>>>>>>>>>>>>  * "AS IS" 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.
> >>>>>>>>>>>>>  *
> >>>>>>>>
> ====================================================================
> >>>>>>>>>>>>>  *
> >>>>>>>>>>>>>  * This software consists of voluntary contributions made by
> >> many
> >>>>>>>>>>>>>  * individuals on behalf of the Apache Software Foundation.
> >> For
> >>>>>> more
> >>>>>>>>>>>>>  * information on the Apache Software Foundation, please see
> >>>>>>>>>>>>>  * <http://www.apache.org/>.
> >>>>>>>>>>>>>  *
> >>>>>>>>>>>>>  */
> >>>>>>>>>>>>> package org.apache.http.client.protocol;
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> import java.util.List;
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> import org.apache.http.Header;
> >>>>>>>>>>>>> import org.apache.http.HttpResponse;
> >>>>>>>>>>>>> import org.apache.http.HttpResponseInterceptor;
> >>>>>>>>>>>>> import org.apache.http.HttpVersion;
> >>>>>>>>>>>>> import org.apache.http.client.CookieStore;
> >>>>>>>>>>>>> import org.apache.http.cookie.Cookie;
> >>>>>>>>>>>>> import org.apache.http.cookie.CookieOrigin;
> >>>>>>>>>>>>> import org.apache.http.cookie.CookieSpec;
> >>>>>>>>>>>>> import org.apache.http.cookie.SM;
> >>>>>>>>>>>>> import org.apache.http.impl.client.BasicCookieStore;
> >>>>>>>>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
> >>>>>>>>>>>>> import org.apache.http.message.BasicHttpResponse;
> >>>>>>>>>>>>> import org.apache.http.util.Asserts;
> >>>>>>>>>>>>> import org.junit.Assert;
> >>>>>>>>>>>>> import org.junit.Before;
> >>>>>>>>>>>>> import org.junit.Test;
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> public class TestResponseProcessCookies {
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     private CookieOrigin cookieOrigin;
> >>>>>>>>>>>>>     private CookieSpec cookieSpec;
> >>>>>>>>>>>>>     private CookieStore cookieStore;
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Before
> >>>>>>>>>>>>>     public void setUp() throws Exception {
> >>>>>>>>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80,
> >>>> "/",
> >>>>>>>>>>>> false);
> >>>>>>>>>>>>>         this.cookieSpec = new DefaultCookieSpec();
> >>>>>>>>>>>>>         this.cookieStore = new BasicCookieStore();
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>>>>>>>>>     public void testResponseParameterCheck() throws
> Exception {
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(null, context);
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>>>>>>>>>     public void testContextParameterCheck() throws Exception
> {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, null);
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testParseMultipleCookies() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
> >>>>>>>>>>>> comment=\"how,now\",
> >>>>>>>>>>>>> test2=2; version=1");
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>>>>>>>>>         final Cookie cookie = cookies.get(0);
> >>>>>>>>>>>>>         Assert.assertEquals(0, cookie.getVersion());
> >>>>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>>>>>>>>>         Assert.assertEquals("value1", cookie.getValue());
> >>>>>>>>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
> >>>>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         List<Header> lstHdr =
> >> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>>>         }
> >>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>>>>>>>> test2=2;secure");
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         List<Header> lstHdr =
> >> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>>>         }
> >>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testNoCookieOrigin() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>> null);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testNoCookieSpec() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>> null);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testNoCookieStore() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>> null);
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testSetCookie2OverrideSetCookie() throws
> >>>> Exception
> >>>>>> {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> >>>>>>>> Version=1");
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>>>>>>>>>         final Cookie cookie = cookies.get(0);
> >>>>>>>>>>>>>         Assert.assertEquals(1, cookie.getVersion());
> >>>>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>>>>>>>>>         Assert.assertEquals("value2", cookie.getValue());
> >>>>>>>>>>>>>         Assert.assertEquals("localhost.local",
> >>>> cookie.getDomain());
> >>>>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testInvalidHeader() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
> >>>>>>>> Version=crap");
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testCookieRejected() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
> Domain=
> >>>>>>>>>>>>> www.somedomain.com; Version=1");
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> >>>>>> olegk@apache.org
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use
> >>>> them
> >>>>>> ,
> >>>>>>>>>>>> put
> >>>>>>>>>>>>>> code
> >>>>>>>>>>>>>>> in
> >> org.apache.http.client.protocol.TestResponseProcessCookies.
> >>>>>>>>>>>>>>> They worked with HC3 but it does not mean they should work
> >> with
> >>>>>>>>>>>> HC4, but
> >>>>>>>>>>>>>> I
> >>>>>>>>>>>>>>> would like a confirmation:
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> I cannot get the tests to compile due to missing instance
> >>>>>> variables
> >>>>>>>>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another
> >> look
> >>>>>> if
> >>>>>>>>>>>> you
> >>>>>>>>>>>>>> post the complete class.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>>>>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>>>
>  context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>>>
>  context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>>>         List<Header> lstHdr =
> >>>> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>>>>>         }
> >>>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>>>>>     }
> >>>>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>>>>>>>>>> test2=2;secure");
> >>>>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>>>>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>>>
>  context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>>>
>  context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>>>         List<Header> lstHdr =
> >>>> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>>>>>         }
> >>>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>>>>>     }
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Thanks
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> >>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Hi,
> >>>>>>>>>>>>>>>> Created
> >> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>>>>>>>>>> with a
> >>>>>>>>>>>>>> Test
> >>>>>>>>>>>>>>>> case in it to show issue with Domain starting with ".".
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> >>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>>>>>>>> Created
> >>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>>>>>>>>>> to show
> >>>>>>>>>>>>>>>>> issue with Cookie Header ordering.
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> Hi,
> >>>>>>>>>>>>>>>>>>  I created
> >>>>>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> >>>>>>>>>>>>>> with
> >>>>>>>>>>>>>>>>>> JUnit test case so that you understand the difference we
> >>>> have.
> >>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> >>>>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad
> >> wrote:
> >>>>>>>>>>>>>>>>>>>> Thanks Oleg.
> >>>>>>>>>>>>>>>>>>>> But look at
> >>>>>>>>>>>>>>>>>>>>
> >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >>>>>>>>>>>>>>>>>>> ,
> >>>>>>>>>>>>>>>>>>>> it concerns IGNORE_POLICY
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> I really think there is at least one bug.
> >>>>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in
> >> HC.
> >>>>>>>>>>>> Could
> >>>>>>>>>>>>>> you
> >>>>>>>>>>>>>>>>>>> please though reproduce them with unit tests that do
> not
> >>>>>>>>>>>> involve
> >>>>>>>>>>>>>> JMeter
> >>>>>>>>>>>>>>>>>>> specific code?
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> >>>>>>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> >>>> wrote:
> >>>>>>>>>>>>>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>>>>>>>>>>>>> Thanks for answer.
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> Find my answers inline.
> >>>>>>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >>>>>>>>>>>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>>>>>>>>> Any answer on this question ?
> >>>>>>>>>>>>>>>>>>>>>>>> Thanks
> >>>>>>>>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad
> <
> >>>>>>>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
> >>>>>>>>>>>>>> HttpClient
> >>>>>>>>>>>>>>>>>>> 4.5.1.
> >>>>>>>>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
> >>>>>>>>>>>> all
> >>>>>>>>>>>>>>>>>>> deprecated
> >>>>>>>>>>>>>>>>>>>>> code.
> >>>>>>>>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>>>
> >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >>>>>>>>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
> >>>>>>>>>>>> version.
> >>>>>>>>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
> >>>>>>>>>>>>>> failures:
> >>>>>>>>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >>>>>>>>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use
> >> HC4
> >>>>>>>>>>>>>>>>>>> Implementation
> >>>>>>>>>>>>>>>>>>>>> of
> >>>>>>>>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
> >>>>>>>>>>>> compared to
> >>>>>>>>>>>>>>>>>>> HC3.
> >>>>>>>>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got
> >> other
> >>>>>>>>>>>>>> failures
> >>>>>>>>>>>>>>>>>>> all
> >>>>>>>>>>>>>>>>>>>>>> detailed in initial mail.
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> What policy does
> >>>>>>>>>>>>>>>>>>>>>>> CookeManager use internally?
> >>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
> >>>>>>>>>>>> depending on
> >>>>>>>>>>>>>>>>>>> test
> >>>>>>>>>>>>>>>>>>>>> method
> >>>>>>>>>>>>>>>>>>>>>> we set different Policy to test them.
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict
> >> or
> >>>>>>>>>>>> relaxed
> >>>>>>>>>>>>>>>>>>> mode
> >>>>>>>>>>>>>>>>>>>>> and nothing else. All other policies have been marked
> >> as
> >>>>>>>>>>>>>> obsolete
> >>>>>>>>>>>>>>>>>>> and
> >>>>>>>>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>
> >> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>
> >> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>>>>>>>> --
> >>>>>>>>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> --
> >>>>>>>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> --
> >>>>>>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>> --
> >>>>>>>>>>> Cordialement.
> >>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> --
> >>>>>>>>>> Cordialement.
> >>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>
> >
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Andrey Pokhilko <ap...@ya.ru>.
I reviewed the code for test case in the PR, looks fine.

Andrey Pokhilko

On 12/16/2015 01:06 AM, Philippe Mouawad wrote:
> Hi ,
> I think that's what I wrote no ?
> It's failing because at step 2 , as the domain is "bt.com" not ".bt.com",
> we don't send the cookie , so I suppose we break the test.
>
> I think in HC4.5 (as per answer of Oleg on ) , domain matching occurs based
> on (((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) as
> per BasicDomainHandler#match method used by NetscapeDraftSpec policy.
> So I think we need to modify the Cookie JMeter class to preserve this
> information which is used to match cookies to URL.
>
> Regards
>
>
> On Tue, Dec 15, 2015 at 10:48 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>
>> No.
>>
>> Right test case is:
>> 1. we get cookie for domain .bt.com
>> 2. We do request to sub.bt.com and expect to send the cookie
>>
>> That's the case that was broken with upgrading to 0.4.5 in our field tries.
>>
>> Andrey Pokhilko
>>
>> On 12/16/2015 12:44 AM, Philippe Mouawad wrote:
>>> Hi Andrei,
>>> I  am not sure to understand.
>>>
>>> If you look at my test case sent to HTTPCLIENT, the cookie is transmitted
>>> for subdomain.bt.com except that domain has value bt.com not ".bt.com".
>>>
>>> Do you mean that as on jmeter side , we get "bt.com" as domain, we don't
>>> transmit in next request the cookie for subdomain.bt.com ?
>>>
>>> Thanks
>>>
>>> On Tue, Dec 15, 2015 at 10:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>
>>>> The impact of it is broken test plans. When cookie is set for .bt.com,
>>>> it means that subdomain.bt.com must receive that cookie. That's by RFC
>>>> AFAIK.
>>>>
>>>> Andrey Pokhilko
>>>>
>>>> On 12/15/2015 11:41 PM, Philippe Mouawad wrote:
>>>>> Hi Andrey,
>>>>> Test case is failing, but it seems to be a regular HC4.5 behaviour.
>>>>>
>>>>> What was the impact of this failing test case on JMeter side ?
>>>>> It's not clear for me from your mail, if you can give a full example
>> with
>>>>> each step it wil help me understand.
>>>>>
>>>>> Thanks
>>>>>
>>>>> On Tue, Dec 15, 2015 at 5:56 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>>>
>>>>>> It's one from 10/27/2015 06:32 PM:
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Today we've found an issue in using HTTPClient 4.5 in JMeter. If we
>> just
>>>>>> replace the libraries with no change to JMeter code, it stops
>> processing
>>>>>> wildcard domains for cookies. I've failed to understand if it is
>>>>>> regression in HTTPClient or something else.
>>>>>>
>>>>>> I've managed to write a unit test for it, I can commit it into trunk
>> if
>>>>>> needed. Unit test works fine on old libraries, but fails with 4.5:
>>>>>>
>>>>>> package org.apache.jmeter.protocol.http.control;
>>>>>>
>>>>>> import org.apache.http.cookie.Cookie;
>>>>>> import org.apache.jmeter.testelement.property.CollectionProperty;
>>>>>> import org.junit.Assert;
>>>>>> import org.junit.Test;
>>>>>>
>>>>>> import java.net.URL;
>>>>>> import java.util.List;
>>>>>>
>>>>>> public class HC4CookieHandlerTest {
>>>>>>
>>>>>>     @Test public void testAddCookieFromHeader_wildcard() throws
>>>> Exception {
>>>>>>         HC4CookieHandler obj = new HC4CookieHandler("compatibility");
>>>>>>         URL url = new URL("https://subdomain.bt.com/page");
>>>>>>         CookieManager mgr = new CookieManager();
>>>>>>         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
>>>>>>         obj.addCookieFromHeader(mgr, true, headerLine, url);
>>>>>>         CollectionProperty cp = mgr.getCookies();
>>>>>>         List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
>>>>>>         Assert.assertEquals(1, res.size());
>>>>>>         for (Cookie cookie : res) {
>>>>>>             Assert.assertEquals(".bt.com", cookie.getDomain());
>>>>>>         }
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>>
>>>>>>
>>>>>> Andrey Pokhilko
>>>>>>
>>>>>> On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
>>>>>>> I was searching in my mails for it :-) Andrei
>>>>>>>
>>>>>>> On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> First of all - you've made awesome job on coordinating all this
>>>> tedious
>>>>>>>> communications with Oleg. Thanks, your contribution is invaluable in
>>>> my
>>>>>>>> eyes.
>>>>>>>>
>>>>>>>> Just a note - don't you want to include the test case I provided
>> some
>>>>>>>> time ago into this PR? To make sure the initial  case that revealed
>>>>>>>> issues finally works...
>>>>>>>>
>>>>>>>> Andrey Pokhilko
>>>>>>>>
>>>>>>>> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
>>>>>>>>> Hi,
>>>>>>>>> I submitted a PR https://github.com/apache/jmeter/pull/62  after
>>>>>> fixing
>>>>>>>> the
>>>>>>>>> remaining issues I think.
>>>>>>>>> I still have one failing test , related to
>>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I
>>>> reopened.
>>>>>>>>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we
>>>> need
>>>>>>>> 4.5.2
>>>>>>>>> I changed testCookies2 as per Oleg note and added testCookies3.
>>>>>>>>>
>>>>>>>>> Please review as this is very sensitive and I would really like a
>>>>>> second
>>>>>>>>> eye on it.
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>> Regards
>>>>>>>>>
>>>>>>>>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi ,
>>>>>>>>>> One last question, when is release of 4.5.2 expected as it fixes 2
>>>>>> bugs
>>>>>>>> we
>>>>>>>>>> are facing in JMeter.
>>>>>>>>>>
>>>>>>>>>> Thanks
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <
>>>> olegk@apache.org
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>> Hello Oleg,
>>>>>>>>>>>>> Thanks .
>>>>>>>>>>>>>
>>>>>>>>>>>> Test case #testParseCookies
>>>>>>>>>>>>
>>>>>>>>>>>> The rest case does not look right to me. I am not sure I
>>>> understand
>>>>>>>> what
>>>>>>>>>>>> you are trying to test here.
>>>>>>>>>>>>
>>>>>>>>>>> Indeed, bad copy paste.
>>>>>>>>>>>
>>>>>>>>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is
>>>> on
>>>>>>>>>>> JMeter side.
>>>>>>>>>>>
>>>>>>>>>>>> Test case #testParseCookies
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> The cookie in question does not have a version attribute
>> mandatory
>>>>>> for
>>>>>>>>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed
>>>> as
>>>>>>>>>>>> Netscape style cookie in which case comma is not considered a
>>>> valid
>>>>>>>>>>>> header element delimiter and is treated as normal character.
>>>>>>>>>>>>
>>>>>>>>>>> Thanks for explanation.
>>>>>>>>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> Oleg
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>> Here it is:
>>>>>>>>>>>>>
>>>>>>>>>>>>> /*
>>>>>>>>>>>>>  *
>>>>>>>> ====================================================================
>>>>>>>>>>>>>  * 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
>>>>>>>>>>>>>  * "License"); 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
>>>>>>>>>>>>>  * "AS IS" 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.
>>>>>>>>>>>>>  *
>>>>>>>> ====================================================================
>>>>>>>>>>>>>  *
>>>>>>>>>>>>>  * This software consists of voluntary contributions made by
>> many
>>>>>>>>>>>>>  * individuals on behalf of the Apache Software Foundation.
>> For
>>>>>> more
>>>>>>>>>>>>>  * information on the Apache Software Foundation, please see
>>>>>>>>>>>>>  * <http://www.apache.org/>.
>>>>>>>>>>>>>  *
>>>>>>>>>>>>>  */
>>>>>>>>>>>>> package org.apache.http.client.protocol;
>>>>>>>>>>>>>
>>>>>>>>>>>>> import java.util.List;
>>>>>>>>>>>>>
>>>>>>>>>>>>> import org.apache.http.Header;
>>>>>>>>>>>>> import org.apache.http.HttpResponse;
>>>>>>>>>>>>> import org.apache.http.HttpResponseInterceptor;
>>>>>>>>>>>>> import org.apache.http.HttpVersion;
>>>>>>>>>>>>> import org.apache.http.client.CookieStore;
>>>>>>>>>>>>> import org.apache.http.cookie.Cookie;
>>>>>>>>>>>>> import org.apache.http.cookie.CookieOrigin;
>>>>>>>>>>>>> import org.apache.http.cookie.CookieSpec;
>>>>>>>>>>>>> import org.apache.http.cookie.SM;
>>>>>>>>>>>>> import org.apache.http.impl.client.BasicCookieStore;
>>>>>>>>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
>>>>>>>>>>>>> import org.apache.http.message.BasicHttpResponse;
>>>>>>>>>>>>> import org.apache.http.util.Asserts;
>>>>>>>>>>>>> import org.junit.Assert;
>>>>>>>>>>>>> import org.junit.Before;
>>>>>>>>>>>>> import org.junit.Test;
>>>>>>>>>>>>>
>>>>>>>>>>>>> public class TestResponseProcessCookies {
>>>>>>>>>>>>>
>>>>>>>>>>>>>     private CookieOrigin cookieOrigin;
>>>>>>>>>>>>>     private CookieSpec cookieSpec;
>>>>>>>>>>>>>     private CookieStore cookieStore;
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Before
>>>>>>>>>>>>>     public void setUp() throws Exception {
>>>>>>>>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80,
>>>> "/",
>>>>>>>>>>>> false);
>>>>>>>>>>>>>         this.cookieSpec = new DefaultCookieSpec();
>>>>>>>>>>>>>         this.cookieStore = new BasicCookieStore();
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>>>>>>>     public void testResponseParameterCheck() throws Exception {
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(null, context);
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>>>>>>>     public void testContextParameterCheck() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, null);
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testParseMultipleCookies() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
>>>>>>>>>>>> comment=\"how,now\",
>>>>>>>>>>>>> test2=2; version=1");
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>>>>>>>         Assert.assertEquals(0, cookie.getVersion());
>>>>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>>>>>>>         Assert.assertEquals("value1", cookie.getValue());
>>>>>>>>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
>>>>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         List<Header> lstHdr =
>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>         }
>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>>>>>> test2=2;secure");
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         List<Header> lstHdr =
>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>         }
>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testNoCookieOrigin() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>> null);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testNoCookieSpec() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>> null);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testNoCookieStore() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>> null);
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testSetCookie2OverrideSetCookie() throws
>>>> Exception
>>>>>> {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
>>>>>>>> Version=1");
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>>>>>>>         Assert.assertEquals(1, cookie.getVersion());
>>>>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>>>>>>>         Assert.assertEquals("value2", cookie.getValue());
>>>>>>>>>>>>>         Assert.assertEquals("localhost.local",
>>>> cookie.getDomain());
>>>>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testInvalidHeader() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
>>>>>>>> Version=crap");
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testCookieRejected() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>>>>>>>>>>>>> www.somedomain.com; Version=1");
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>> }
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
>>>>>> olegk@apache.org
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use
>>>> them
>>>>>> ,
>>>>>>>>>>>> put
>>>>>>>>>>>>>> code
>>>>>>>>>>>>>>> in
>> org.apache.http.client.protocol.TestResponseProcessCookies.
>>>>>>>>>>>>>>> They worked with HC3 but it does not mean they should work
>> with
>>>>>>>>>>>> HC4, but
>>>>>>>>>>>>>> I
>>>>>>>>>>>>>>> would like a confirmation:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I cannot get the tests to compile due to missing instance
>>>>>> variables
>>>>>>>>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another
>> look
>>>>>> if
>>>>>>>>>>>> you
>>>>>>>>>>>>>> post the complete class.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         List<Header> lstHdr =
>>>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>>>         }
>>>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>>>>>>>> test2=2;secure");
>>>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>>>         List<Header> lstHdr =
>>>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>>>         }
>>>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>>>     }
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>> Created
>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>>>>>>>> with a
>>>>>>>>>>>>>> Test
>>>>>>>>>>>>>>>> case in it to show issue with Domain starting with ".".
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>>>>> Created
>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>>>>>>>> to show
>>>>>>>>>>>>>>>>> issue with Cookie Header ordering.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>>>  I created
>>>>>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>>>>>>>>>>>>>> with
>>>>>>>>>>>>>>>>>> JUnit test case so that you understand the difference we
>>>> have.
>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad
>> wrote:
>>>>>>>>>>>>>>>>>>>> Thanks Oleg.
>>>>>>>>>>>>>>>>>>>> But look at
>>>>>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>>>>>>>>>>>>>>>>>> ,
>>>>>>>>>>>>>>>>>>>> it concerns IGNORE_POLICY
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> I really think there is at least one bug.
>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in
>> HC.
>>>>>>>>>>>> Could
>>>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>>>> please though reproduce them with unit tests that do not
>>>>>>>>>>>> involve
>>>>>>>>>>>>>> JMeter
>>>>>>>>>>>>>>>>>>> specific code?
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>>>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>>>>>>>>>> Thanks for answer.
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> Find my answers inline.
>>>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>>>>>>>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>>>>>>> Any answer on this question ?
>>>>>>>>>>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
>>>>>>>>>>>>>> HttpClient
>>>>>>>>>>>>>>>>>>> 4.5.1.
>>>>>>>>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
>>>>>>>>>>>> all
>>>>>>>>>>>>>>>>>>> deprecated
>>>>>>>>>>>>>>>>>>>>> code.
>>>>>>>>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>>>>>>>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
>>>>>>>>>>>> version.
>>>>>>>>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
>>>>>>>>>>>>>> failures:
>>>>>>>>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>>>>>>>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use
>> HC4
>>>>>>>>>>>>>>>>>>> Implementation
>>>>>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
>>>>>>>>>>>> compared to
>>>>>>>>>>>>>>>>>>> HC3.
>>>>>>>>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got
>> other
>>>>>>>>>>>>>> failures
>>>>>>>>>>>>>>>>>>> all
>>>>>>>>>>>>>>>>>>>>>> detailed in initial mail.
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> What policy does
>>>>>>>>>>>>>>>>>>>>>>> CookeManager use internally?
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
>>>>>>>>>>>> depending on
>>>>>>>>>>>>>>>>>>> test
>>>>>>>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>>>>>>>>> we set different Policy to test them.
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict
>> or
>>>>>>>>>>>> relaxed
>>>>>>>>>>>>>>>>>>> mode
>>>>>>>>>>>>>>>>>>>>> and nothing else. All other policies have been marked
>> as
>>>>>>>>>>>>>> obsolete
>>>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Cordialement.
>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Cordialement.
>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>
>


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi ,
I think that's what I wrote no ?
It's failing because at step 2 , as the domain is "bt.com" not ".bt.com",
we don't send the cookie , so I suppose we break the test.

I think in HC4.5 (as per answer of Oleg on ) , domain matching occurs based
on (((ClientCookie) cookie).containsAttribute(ClientCookie.DOMAIN_ATTR)) as
per BasicDomainHandler#match method used by NetscapeDraftSpec policy.
So I think we need to modify the Cookie JMeter class to preserve this
information which is used to match cookies to URL.

Regards


On Tue, Dec 15, 2015 at 10:48 PM, Andrey Pokhilko <ap...@ya.ru> wrote:

> No.
>
> Right test case is:
> 1. we get cookie for domain .bt.com
> 2. We do request to sub.bt.com and expect to send the cookie
>
> That's the case that was broken with upgrading to 0.4.5 in our field tries.
>
> Andrey Pokhilko
>
> On 12/16/2015 12:44 AM, Philippe Mouawad wrote:
> > Hi Andrei,
> > I  am not sure to understand.
> >
> > If you look at my test case sent to HTTPCLIENT, the cookie is transmitted
> > for subdomain.bt.com except that domain has value bt.com not ".bt.com".
> >
> > Do you mean that as on jmeter side , we get "bt.com" as domain, we don't
> > transmit in next request the cookie for subdomain.bt.com ?
> >
> > Thanks
> >
> > On Tue, Dec 15, 2015 at 10:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >
> >> The impact of it is broken test plans. When cookie is set for .bt.com,
> >> it means that subdomain.bt.com must receive that cookie. That's by RFC
> >> AFAIK.
> >>
> >> Andrey Pokhilko
> >>
> >> On 12/15/2015 11:41 PM, Philippe Mouawad wrote:
> >>> Hi Andrey,
> >>> Test case is failing, but it seems to be a regular HC4.5 behaviour.
> >>>
> >>> What was the impact of this failing test case on JMeter side ?
> >>> It's not clear for me from your mail, if you can give a full example
> with
> >>> each step it wil help me understand.
> >>>
> >>> Thanks
> >>>
> >>> On Tue, Dec 15, 2015 at 5:56 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >>>
> >>>> It's one from 10/27/2015 06:32 PM:
> >>>>
> >>>> Hi,
> >>>>
> >>>> Today we've found an issue in using HTTPClient 4.5 in JMeter. If we
> just
> >>>> replace the libraries with no change to JMeter code, it stops
> processing
> >>>> wildcard domains for cookies. I've failed to understand if it is
> >>>> regression in HTTPClient or something else.
> >>>>
> >>>> I've managed to write a unit test for it, I can commit it into trunk
> if
> >>>> needed. Unit test works fine on old libraries, but fails with 4.5:
> >>>>
> >>>> package org.apache.jmeter.protocol.http.control;
> >>>>
> >>>> import org.apache.http.cookie.Cookie;
> >>>> import org.apache.jmeter.testelement.property.CollectionProperty;
> >>>> import org.junit.Assert;
> >>>> import org.junit.Test;
> >>>>
> >>>> import java.net.URL;
> >>>> import java.util.List;
> >>>>
> >>>> public class HC4CookieHandlerTest {
> >>>>
> >>>>     @Test public void testAddCookieFromHeader_wildcard() throws
> >> Exception {
> >>>>         HC4CookieHandler obj = new HC4CookieHandler("compatibility");
> >>>>         URL url = new URL("https://subdomain.bt.com/page");
> >>>>         CookieManager mgr = new CookieManager();
> >>>>         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
> >>>>         obj.addCookieFromHeader(mgr, true, headerLine, url);
> >>>>         CollectionProperty cp = mgr.getCookies();
> >>>>         List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
> >>>>         Assert.assertEquals(1, res.size());
> >>>>         for (Cookie cookie : res) {
> >>>>             Assert.assertEquals(".bt.com", cookie.getDomain());
> >>>>         }
> >>>>     }
> >>>> }
> >>>>
> >>>>
> >>>>
> >>>> Andrey Pokhilko
> >>>>
> >>>> On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
> >>>>> I was searching in my mails for it :-) Andrei
> >>>>>
> >>>>> On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >>>>>
> >>>>>> Hi,
> >>>>>>
> >>>>>> First of all - you've made awesome job on coordinating all this
> >> tedious
> >>>>>> communications with Oleg. Thanks, your contribution is invaluable in
> >> my
> >>>>>> eyes.
> >>>>>>
> >>>>>> Just a note - don't you want to include the test case I provided
> some
> >>>>>> time ago into this PR? To make sure the initial  case that revealed
> >>>>>> issues finally works...
> >>>>>>
> >>>>>> Andrey Pokhilko
> >>>>>>
> >>>>>> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
> >>>>>>> Hi,
> >>>>>>> I submitted a PR https://github.com/apache/jmeter/pull/62  after
> >>>> fixing
> >>>>>> the
> >>>>>>> remaining issues I think.
> >>>>>>> I still have one failing test , related to
> >>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I
> >> reopened.
> >>>>>>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we
> >> need
> >>>>>> 4.5.2
> >>>>>>> I changed testCookies2 as per Oleg note and added testCookies3.
> >>>>>>>
> >>>>>>> Please review as this is very sensitive and I would really like a
> >>>> second
> >>>>>>> eye on it.
> >>>>>>>
> >>>>>>> Thanks
> >>>>>>> Regards
> >>>>>>>
> >>>>>>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
> >>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>
> >>>>>>>> Hi ,
> >>>>>>>> One last question, when is release of 4.5.2 expected as it fixes 2
> >>>> bugs
> >>>>>> we
> >>>>>>>> are facing in JMeter.
> >>>>>>>>
> >>>>>>>> Thanks
> >>>>>>>> Regards
> >>>>>>>>
> >>>>>>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> >>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>
> >>>>>>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <
> >> olegk@apache.org
> >>>>>>>>> wrote:
> >>>>>>>>>
> >>>>>>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>> Hello Oleg,
> >>>>>>>>>>> Thanks .
> >>>>>>>>>>>
> >>>>>>>>>> Test case #testParseCookies
> >>>>>>>>>>
> >>>>>>>>>> The rest case does not look right to me. I am not sure I
> >> understand
> >>>>>> what
> >>>>>>>>>> you are trying to test here.
> >>>>>>>>>>
> >>>>>>>>> Indeed, bad copy paste.
> >>>>>>>>>
> >>>>>>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is
> >> on
> >>>>>>>>> JMeter side.
> >>>>>>>>>
> >>>>>>>>>> Test case #testParseCookies
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> The cookie in question does not have a version attribute
> mandatory
> >>>> for
> >>>>>>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed
> >> as
> >>>>>>>>>> Netscape style cookie in which case comma is not considered a
> >> valid
> >>>>>>>>>> header element delimiter and is treated as normal character.
> >>>>>>>>>>
> >>>>>>>>> Thanks for explanation.
> >>>>>>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>> Oleg
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>> Here it is:
> >>>>>>>>>>>
> >>>>>>>>>>> /*
> >>>>>>>>>>>  *
> >>>>>> ====================================================================
> >>>>>>>>>>>  * 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
> >>>>>>>>>>>  * "License"); 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
> >>>>>>>>>>>  * "AS IS" 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.
> >>>>>>>>>>>  *
> >>>>>> ====================================================================
> >>>>>>>>>>>  *
> >>>>>>>>>>>  * This software consists of voluntary contributions made by
> many
> >>>>>>>>>>>  * individuals on behalf of the Apache Software Foundation.
> For
> >>>> more
> >>>>>>>>>>>  * information on the Apache Software Foundation, please see
> >>>>>>>>>>>  * <http://www.apache.org/>.
> >>>>>>>>>>>  *
> >>>>>>>>>>>  */
> >>>>>>>>>>> package org.apache.http.client.protocol;
> >>>>>>>>>>>
> >>>>>>>>>>> import java.util.List;
> >>>>>>>>>>>
> >>>>>>>>>>> import org.apache.http.Header;
> >>>>>>>>>>> import org.apache.http.HttpResponse;
> >>>>>>>>>>> import org.apache.http.HttpResponseInterceptor;
> >>>>>>>>>>> import org.apache.http.HttpVersion;
> >>>>>>>>>>> import org.apache.http.client.CookieStore;
> >>>>>>>>>>> import org.apache.http.cookie.Cookie;
> >>>>>>>>>>> import org.apache.http.cookie.CookieOrigin;
> >>>>>>>>>>> import org.apache.http.cookie.CookieSpec;
> >>>>>>>>>>> import org.apache.http.cookie.SM;
> >>>>>>>>>>> import org.apache.http.impl.client.BasicCookieStore;
> >>>>>>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
> >>>>>>>>>>> import org.apache.http.message.BasicHttpResponse;
> >>>>>>>>>>> import org.apache.http.util.Asserts;
> >>>>>>>>>>> import org.junit.Assert;
> >>>>>>>>>>> import org.junit.Before;
> >>>>>>>>>>> import org.junit.Test;
> >>>>>>>>>>>
> >>>>>>>>>>> public class TestResponseProcessCookies {
> >>>>>>>>>>>
> >>>>>>>>>>>     private CookieOrigin cookieOrigin;
> >>>>>>>>>>>     private CookieSpec cookieSpec;
> >>>>>>>>>>>     private CookieStore cookieStore;
> >>>>>>>>>>>
> >>>>>>>>>>>     @Before
> >>>>>>>>>>>     public void setUp() throws Exception {
> >>>>>>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80,
> >> "/",
> >>>>>>>>>> false);
> >>>>>>>>>>>         this.cookieSpec = new DefaultCookieSpec();
> >>>>>>>>>>>         this.cookieStore = new BasicCookieStore();
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>>>>>>>     public void testResponseParameterCheck() throws Exception {
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(null, context);
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>>>>>>>     public void testContextParameterCheck() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, null);
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testParseMultipleCookies() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
> >>>>>>>>>> comment=\"how,now\",
> >>>>>>>>>>> test2=2; version=1");
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>>>>>>>         final Cookie cookie = cookies.get(0);
> >>>>>>>>>>>         Assert.assertEquals(0, cookie.getVersion());
> >>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>>>>>>>         Assert.assertEquals("value1", cookie.getValue());
> >>>>>>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
> >>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         List<Header> lstHdr =
> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>         }
> >>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>     }
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>>>>>> test2=2;secure");
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         List<Header> lstHdr =
> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>         }
> >>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testNoCookieOrigin() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>> null);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testNoCookieSpec() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> null);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testNoCookieStore() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> null);
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testSetCookie2OverrideSetCookie() throws
> >> Exception
> >>>> {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> >>>>>> Version=1");
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>>>>>>>         final Cookie cookie = cookies.get(0);
> >>>>>>>>>>>         Assert.assertEquals(1, cookie.getVersion());
> >>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>>>>>>>         Assert.assertEquals("value2", cookie.getValue());
> >>>>>>>>>>>         Assert.assertEquals("localhost.local",
> >> cookie.getDomain());
> >>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testInvalidHeader() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
> >>>>>> Version=crap");
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testCookieRejected() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> >>>>>>>>>>> www.somedomain.com; Version=1");
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>> }
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> >>>> olegk@apache.org
> >>>>>>>>>> wrote:
> >>>>>>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use
> >> them
> >>>> ,
> >>>>>>>>>> put
> >>>>>>>>>>>> code
> >>>>>>>>>>>>> in
> org.apache.http.client.protocol.TestResponseProcessCookies.
> >>>>>>>>>>>>> They worked with HC3 but it does not mean they should work
> with
> >>>>>>>>>> HC4, but
> >>>>>>>>>>>> I
> >>>>>>>>>>>>> would like a confirmation:
> >>>>>>>>>>>>>
> >>>>>>>>>>>> I cannot get the tests to compile due to missing instance
> >>>> variables
> >>>>>>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another
> look
> >>>> if
> >>>>>>>>>> you
> >>>>>>>>>>>> post the complete class.
> >>>>>>>>>>>>
> >>>>>>>>>>>> Oleg
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         List<Header> lstHdr =
> >> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>>>         }
> >>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>     @Test
> >>>>>>>>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>>>>>>>> test2=2;secure");
> >>>>>>>>>>>>>         final HttpClientContext context =
> >>>>>>>>>> HttpClientContext.create();
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>         final List<Cookie> cookies =
> >>>> this.cookieStore.getCookies();
> >>>>>>>>>>>>>         List<Header> lstHdr =
> >> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>>>         }
> >>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>>>     }
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Thanks
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> >>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> Hi,
> >>>>>>>>>>>>>> Created
> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>>>>>>>> with a
> >>>>>>>>>>>> Test
> >>>>>>>>>>>>>> case in it to show issue with Domain starting with ".".
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> >>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>>>>>> Created
> >> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>>>>>>>> to show
> >>>>>>>>>>>>>>> issue with Cookie Header ordering.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Hi,
> >>>>>>>>>>>>>>>>  I created
> >>>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> >>>>>>>>>>>> with
> >>>>>>>>>>>>>>>> JUnit test case so that you understand the difference we
> >> have.
> >>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> >>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad
> wrote:
> >>>>>>>>>>>>>>>>>> Thanks Oleg.
> >>>>>>>>>>>>>>>>>> But look at
> >>>>>>>>>>>>>>>>>>
> >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >>>>>>>>>>>>>>>>> ,
> >>>>>>>>>>>>>>>>>> it concerns IGNORE_POLICY
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> I really think there is at least one bug.
> >>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in
> HC.
> >>>>>>>>>> Could
> >>>>>>>>>>>> you
> >>>>>>>>>>>>>>>>> please though reproduce them with unit tests that do not
> >>>>>>>>>> involve
> >>>>>>>>>>>> JMeter
> >>>>>>>>>>>>>>>>> specific code?
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> >>>>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> >> wrote:
> >>>>>>>>>>>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>>>>>>>>>>> Thanks for answer.
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> Find my answers inline.
> >>>>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >>>>>>>>>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> >>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>>>>>>> Any answer on this question ?
> >>>>>>>>>>>>>>>>>>>>>> Thanks
> >>>>>>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> >>>>>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
> >>>>>>>>>>>> HttpClient
> >>>>>>>>>>>>>>>>> 4.5.1.
> >>>>>>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
> >>>>>>>>>> all
> >>>>>>>>>>>>>>>>> deprecated
> >>>>>>>>>>>>>>>>>>> code.
> >>>>>>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
> >>>>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>>>
> >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >>>>>>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
> >>>>>>>>>> version.
> >>>>>>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
> >>>>>>>>>>>> failures:
> >>>>>>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >>>>>>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use
> HC4
> >>>>>>>>>>>>>>>>> Implementation
> >>>>>>>>>>>>>>>>>>> of
> >>>>>>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
> >>>>>>>>>> compared to
> >>>>>>>>>>>>>>>>> HC3.
> >>>>>>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got
> other
> >>>>>>>>>>>> failures
> >>>>>>>>>>>>>>>>> all
> >>>>>>>>>>>>>>>>>>>> detailed in initial mail.
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> What policy does
> >>>>>>>>>>>>>>>>>>>>> CookeManager use internally?
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
> >>>>>>>>>> depending on
> >>>>>>>>>>>>>>>>> test
> >>>>>>>>>>>>>>>>>>> method
> >>>>>>>>>>>>>>>>>>>> we set different Policy to test them.
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict
> or
> >>>>>>>>>> relaxed
> >>>>>>>>>>>>>>>>> mode
> >>>>>>>>>>>>>>>>>>> and nothing else. All other policies have been marked
> as
> >>>>>>>>>>>> obsolete
> >>>>>>>>>>>>>>>>> and
> >>>>>>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>>>>>> --
> >>>>>>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> --
> >>>>>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> --
> >>>>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>> --
> >>>>>>>>> Cordialement.
> >>>>>>>>> Philippe Mouawad.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>> --
> >>>>>>>> Cordialement.
> >>>>>>>> Philippe Mouawad.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>
> >
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Andrey Pokhilko <ap...@ya.ru>.
No.

Right test case is:
1. we get cookie for domain .bt.com
2. We do request to sub.bt.com and expect to send the cookie

That's the case that was broken with upgrading to 0.4.5 in our field tries.

Andrey Pokhilko

On 12/16/2015 12:44 AM, Philippe Mouawad wrote:
> Hi Andrei,
> I  am not sure to understand.
>
> If you look at my test case sent to HTTPCLIENT, the cookie is transmitted
> for subdomain.bt.com except that domain has value bt.com not ".bt.com".
>
> Do you mean that as on jmeter side , we get "bt.com" as domain, we don't
> transmit in next request the cookie for subdomain.bt.com ?
>
> Thanks
>
> On Tue, Dec 15, 2015 at 10:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>
>> The impact of it is broken test plans. When cookie is set for .bt.com,
>> it means that subdomain.bt.com must receive that cookie. That's by RFC
>> AFAIK.
>>
>> Andrey Pokhilko
>>
>> On 12/15/2015 11:41 PM, Philippe Mouawad wrote:
>>> Hi Andrey,
>>> Test case is failing, but it seems to be a regular HC4.5 behaviour.
>>>
>>> What was the impact of this failing test case on JMeter side ?
>>> It's not clear for me from your mail, if you can give a full example with
>>> each step it wil help me understand.
>>>
>>> Thanks
>>>
>>> On Tue, Dec 15, 2015 at 5:56 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>
>>>> It's one from 10/27/2015 06:32 PM:
>>>>
>>>> Hi,
>>>>
>>>> Today we've found an issue in using HTTPClient 4.5 in JMeter. If we just
>>>> replace the libraries with no change to JMeter code, it stops processing
>>>> wildcard domains for cookies. I've failed to understand if it is
>>>> regression in HTTPClient or something else.
>>>>
>>>> I've managed to write a unit test for it, I can commit it into trunk if
>>>> needed. Unit test works fine on old libraries, but fails with 4.5:
>>>>
>>>> package org.apache.jmeter.protocol.http.control;
>>>>
>>>> import org.apache.http.cookie.Cookie;
>>>> import org.apache.jmeter.testelement.property.CollectionProperty;
>>>> import org.junit.Assert;
>>>> import org.junit.Test;
>>>>
>>>> import java.net.URL;
>>>> import java.util.List;
>>>>
>>>> public class HC4CookieHandlerTest {
>>>>
>>>>     @Test public void testAddCookieFromHeader_wildcard() throws
>> Exception {
>>>>         HC4CookieHandler obj = new HC4CookieHandler("compatibility");
>>>>         URL url = new URL("https://subdomain.bt.com/page");
>>>>         CookieManager mgr = new CookieManager();
>>>>         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
>>>>         obj.addCookieFromHeader(mgr, true, headerLine, url);
>>>>         CollectionProperty cp = mgr.getCookies();
>>>>         List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
>>>>         Assert.assertEquals(1, res.size());
>>>>         for (Cookie cookie : res) {
>>>>             Assert.assertEquals(".bt.com", cookie.getDomain());
>>>>         }
>>>>     }
>>>> }
>>>>
>>>>
>>>>
>>>> Andrey Pokhilko
>>>>
>>>> On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
>>>>> I was searching in my mails for it :-) Andrei
>>>>>
>>>>> On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> First of all - you've made awesome job on coordinating all this
>> tedious
>>>>>> communications with Oleg. Thanks, your contribution is invaluable in
>> my
>>>>>> eyes.
>>>>>>
>>>>>> Just a note - don't you want to include the test case I provided some
>>>>>> time ago into this PR? To make sure the initial  case that revealed
>>>>>> issues finally works...
>>>>>>
>>>>>> Andrey Pokhilko
>>>>>>
>>>>>> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
>>>>>>> Hi,
>>>>>>> I submitted a PR https://github.com/apache/jmeter/pull/62  after
>>>> fixing
>>>>>> the
>>>>>>> remaining issues I think.
>>>>>>> I still have one failing test , related to
>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I
>> reopened.
>>>>>>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we
>> need
>>>>>> 4.5.2
>>>>>>> I changed testCookies2 as per Oleg note and added testCookies3.
>>>>>>>
>>>>>>> Please review as this is very sensitive and I would really like a
>>>> second
>>>>>>> eye on it.
>>>>>>>
>>>>>>> Thanks
>>>>>>> Regards
>>>>>>>
>>>>>>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>
>>>>>>>> Hi ,
>>>>>>>> One last question, when is release of 4.5.2 expected as it fixes 2
>>>> bugs
>>>>>> we
>>>>>>>> are facing in JMeter.
>>>>>>>>
>>>>>>>> Thanks
>>>>>>>> Regards
>>>>>>>>
>>>>>>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <
>> olegk@apache.org
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>>>>>>>>>>> Hello Oleg,
>>>>>>>>>>> Thanks .
>>>>>>>>>>>
>>>>>>>>>> Test case #testParseCookies
>>>>>>>>>>
>>>>>>>>>> The rest case does not look right to me. I am not sure I
>> understand
>>>>>> what
>>>>>>>>>> you are trying to test here.
>>>>>>>>>>
>>>>>>>>> Indeed, bad copy paste.
>>>>>>>>>
>>>>>>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is
>> on
>>>>>>>>> JMeter side.
>>>>>>>>>
>>>>>>>>>> Test case #testParseCookies
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> The cookie in question does not have a version attribute mandatory
>>>> for
>>>>>>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed
>> as
>>>>>>>>>> Netscape style cookie in which case comma is not considered a
>> valid
>>>>>>>>>> header element delimiter and is treated as normal character.
>>>>>>>>>>
>>>>>>>>> Thanks for explanation.
>>>>>>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>> Oleg
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>> Here it is:
>>>>>>>>>>>
>>>>>>>>>>> /*
>>>>>>>>>>>  *
>>>>>> ====================================================================
>>>>>>>>>>>  * 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
>>>>>>>>>>>  * "License"); 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
>>>>>>>>>>>  * "AS IS" 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.
>>>>>>>>>>>  *
>>>>>> ====================================================================
>>>>>>>>>>>  *
>>>>>>>>>>>  * This software consists of voluntary contributions made by many
>>>>>>>>>>>  * individuals on behalf of the Apache Software Foundation.  For
>>>> more
>>>>>>>>>>>  * information on the Apache Software Foundation, please see
>>>>>>>>>>>  * <http://www.apache.org/>.
>>>>>>>>>>>  *
>>>>>>>>>>>  */
>>>>>>>>>>> package org.apache.http.client.protocol;
>>>>>>>>>>>
>>>>>>>>>>> import java.util.List;
>>>>>>>>>>>
>>>>>>>>>>> import org.apache.http.Header;
>>>>>>>>>>> import org.apache.http.HttpResponse;
>>>>>>>>>>> import org.apache.http.HttpResponseInterceptor;
>>>>>>>>>>> import org.apache.http.HttpVersion;
>>>>>>>>>>> import org.apache.http.client.CookieStore;
>>>>>>>>>>> import org.apache.http.cookie.Cookie;
>>>>>>>>>>> import org.apache.http.cookie.CookieOrigin;
>>>>>>>>>>> import org.apache.http.cookie.CookieSpec;
>>>>>>>>>>> import org.apache.http.cookie.SM;
>>>>>>>>>>> import org.apache.http.impl.client.BasicCookieStore;
>>>>>>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
>>>>>>>>>>> import org.apache.http.message.BasicHttpResponse;
>>>>>>>>>>> import org.apache.http.util.Asserts;
>>>>>>>>>>> import org.junit.Assert;
>>>>>>>>>>> import org.junit.Before;
>>>>>>>>>>> import org.junit.Test;
>>>>>>>>>>>
>>>>>>>>>>> public class TestResponseProcessCookies {
>>>>>>>>>>>
>>>>>>>>>>>     private CookieOrigin cookieOrigin;
>>>>>>>>>>>     private CookieSpec cookieSpec;
>>>>>>>>>>>     private CookieStore cookieStore;
>>>>>>>>>>>
>>>>>>>>>>>     @Before
>>>>>>>>>>>     public void setUp() throws Exception {
>>>>>>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80,
>> "/",
>>>>>>>>>> false);
>>>>>>>>>>>         this.cookieSpec = new DefaultCookieSpec();
>>>>>>>>>>>         this.cookieStore = new BasicCookieStore();
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>>>>>     public void testResponseParameterCheck() throws Exception {
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(null, context);
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>>>>>     public void testContextParameterCheck() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, null);
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testParseMultipleCookies() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
>>>>>>>>>> comment=\"how,now\",
>>>>>>>>>>> test2=2; version=1");
>>>>>>>>>>>
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>>>>>         Assert.assertEquals(0, cookie.getVersion());
>>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>>>>>         Assert.assertEquals("value1", cookie.getValue());
>>>>>>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
>>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>         }
>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>     }
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>>>> test2=2;secure");
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>         }
>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testNoCookieOrigin() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>> null);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testNoCookieSpec() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> null);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testNoCookieStore() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> null);
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testSetCookie2OverrideSetCookie() throws
>> Exception
>>>> {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
>>>>>> Version=1");
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>>>>>         Assert.assertEquals(1, cookie.getVersion());
>>>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>>>>>         Assert.assertEquals("value2", cookie.getValue());
>>>>>>>>>>>         Assert.assertEquals("localhost.local",
>> cookie.getDomain());
>>>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testInvalidHeader() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
>>>>>> Version=crap");
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testCookieRejected() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>>>>>>>>>>> www.somedomain.com; Version=1");
>>>>>>>>>>>
>>>>>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
>>>> olegk@apache.org
>>>>>>>>>> wrote:
>>>>>>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use
>> them
>>>> ,
>>>>>>>>>> put
>>>>>>>>>>>> code
>>>>>>>>>>>>> in org.apache.http.client.protocol.TestResponseProcessCookies.
>>>>>>>>>>>>> They worked with HC3 but it does not mean they should work with
>>>>>>>>>> HC4, but
>>>>>>>>>>>> I
>>>>>>>>>>>>> would like a confirmation:
>>>>>>>>>>>>>
>>>>>>>>>>>> I cannot get the tests to compile due to missing instance
>>>> variables
>>>>>>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another look
>>>> if
>>>>>>>>>> you
>>>>>>>>>>>> post the complete class.
>>>>>>>>>>>>
>>>>>>>>>>>> Oleg
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         List<Header> lstHdr =
>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>         }
>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>     @Test
>>>>>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>>>>>> test2=2;secure");
>>>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>>>
>>>>>>>>>>>>>         final List<Cookie> cookies =
>>>> this.cookieStore.getCookies();
>>>>>>>>>>>>>         List<Header> lstHdr =
>> cookieSpec.formatCookies(cookies);
>>>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>>>         }
>>>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>>>     }
>>>>>>>>>>>>>
>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>>>>>> with a
>>>>>>>>>>>> Test
>>>>>>>>>>>>>> case in it to show issue with Domain starting with ".".
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>>> Created
>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>>>>>> to show
>>>>>>>>>>>>>>> issue with Cookie Header ordering.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>>>  I created
>>>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>>>>>>>>>>>> with
>>>>>>>>>>>>>>>> JUnit test case so that you understand the difference we
>> have.
>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>>>>>> Thanks Oleg.
>>>>>>>>>>>>>>>>>> But look at
>>>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>>>>>>>>>>>>>>>> ,
>>>>>>>>>>>>>>>>>> it concerns IGNORE_POLICY
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> I really think there is at least one bug.
>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in HC.
>>>>>>>>>> Could
>>>>>>>>>>>> you
>>>>>>>>>>>>>>>>> please though reproduce them with unit tests that do not
>>>>>>>>>> involve
>>>>>>>>>>>> JMeter
>>>>>>>>>>>>>>>>> specific code?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
>> wrote:
>>>>>>>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>>>>>>>> Thanks for answer.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> Find my answers inline.
>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>>>>>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>>>>> Any answer on this question ?
>>>>>>>>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
>>>>>>>>>>>> HttpClient
>>>>>>>>>>>>>>>>> 4.5.1.
>>>>>>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
>>>>>>>>>> all
>>>>>>>>>>>>>>>>> deprecated
>>>>>>>>>>>>>>>>>>> code.
>>>>>>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>>>>>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
>>>>>>>>>> version.
>>>>>>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
>>>>>>>>>>>> failures:
>>>>>>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>>>>>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use HC4
>>>>>>>>>>>>>>>>> Implementation
>>>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
>>>>>>>>>> compared to
>>>>>>>>>>>>>>>>> HC3.
>>>>>>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>>>>>>>>>>>> failures
>>>>>>>>>>>>>>>>> all
>>>>>>>>>>>>>>>>>>>> detailed in initial mail.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> What policy does
>>>>>>>>>>>>>>>>>>>>> CookeManager use internally?
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
>>>>>>>>>> depending on
>>>>>>>>>>>>>>>>> test
>>>>>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>>>>>>> we set different Policy to test them.
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict or
>>>>>>>>>> relaxed
>>>>>>>>>>>>>>>>> mode
>>>>>>>>>>>>>>>>>>> and nothing else. All other policies have been marked as
>>>>>>>>>>>> obsolete
>>>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> --
>>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Cordialement.
>>>>>>>>> Philippe Mouawad.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>> --
>>>>>>>> Cordialement.
>>>>>>>> Philippe Mouawad.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>
>


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Andrei,
I  am not sure to understand.

If you look at my test case sent to HTTPCLIENT, the cookie is transmitted
for subdomain.bt.com except that domain has value bt.com not ".bt.com".

Do you mean that as on jmeter side , we get "bt.com" as domain, we don't
transmit in next request the cookie for subdomain.bt.com ?

Thanks

On Tue, Dec 15, 2015 at 10:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:

> The impact of it is broken test plans. When cookie is set for .bt.com,
> it means that subdomain.bt.com must receive that cookie. That's by RFC
> AFAIK.
>
> Andrey Pokhilko
>
> On 12/15/2015 11:41 PM, Philippe Mouawad wrote:
> > Hi Andrey,
> > Test case is failing, but it seems to be a regular HC4.5 behaviour.
> >
> > What was the impact of this failing test case on JMeter side ?
> > It's not clear for me from your mail, if you can give a full example with
> > each step it wil help me understand.
> >
> > Thanks
> >
> > On Tue, Dec 15, 2015 at 5:56 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >
> >> It's one from 10/27/2015 06:32 PM:
> >>
> >> Hi,
> >>
> >> Today we've found an issue in using HTTPClient 4.5 in JMeter. If we just
> >> replace the libraries with no change to JMeter code, it stops processing
> >> wildcard domains for cookies. I've failed to understand if it is
> >> regression in HTTPClient or something else.
> >>
> >> I've managed to write a unit test for it, I can commit it into trunk if
> >> needed. Unit test works fine on old libraries, but fails with 4.5:
> >>
> >> package org.apache.jmeter.protocol.http.control;
> >>
> >> import org.apache.http.cookie.Cookie;
> >> import org.apache.jmeter.testelement.property.CollectionProperty;
> >> import org.junit.Assert;
> >> import org.junit.Test;
> >>
> >> import java.net.URL;
> >> import java.util.List;
> >>
> >> public class HC4CookieHandlerTest {
> >>
> >>     @Test public void testAddCookieFromHeader_wildcard() throws
> Exception {
> >>         HC4CookieHandler obj = new HC4CookieHandler("compatibility");
> >>         URL url = new URL("https://subdomain.bt.com/page");
> >>         CookieManager mgr = new CookieManager();
> >>         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
> >>         obj.addCookieFromHeader(mgr, true, headerLine, url);
> >>         CollectionProperty cp = mgr.getCookies();
> >>         List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
> >>         Assert.assertEquals(1, res.size());
> >>         for (Cookie cookie : res) {
> >>             Assert.assertEquals(".bt.com", cookie.getDomain());
> >>         }
> >>     }
> >> }
> >>
> >>
> >>
> >> Andrey Pokhilko
> >>
> >> On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
> >>> I was searching in my mails for it :-) Andrei
> >>>
> >>> On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> First of all - you've made awesome job on coordinating all this
> tedious
> >>>> communications with Oleg. Thanks, your contribution is invaluable in
> my
> >>>> eyes.
> >>>>
> >>>> Just a note - don't you want to include the test case I provided some
> >>>> time ago into this PR? To make sure the initial  case that revealed
> >>>> issues finally works...
> >>>>
> >>>> Andrey Pokhilko
> >>>>
> >>>> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
> >>>>> Hi,
> >>>>> I submitted a PR https://github.com/apache/jmeter/pull/62  after
> >> fixing
> >>>> the
> >>>>> remaining issues I think.
> >>>>> I still have one failing test , related to
> >>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I
> reopened.
> >>>>>
> >>>>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we
> need
> >>>> 4.5.2
> >>>>> I changed testCookies2 as per Oleg note and added testCookies3.
> >>>>>
> >>>>> Please review as this is very sensitive and I would really like a
> >> second
> >>>>> eye on it.
> >>>>>
> >>>>> Thanks
> >>>>> Regards
> >>>>>
> >>>>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
> >>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>
> >>>>>> Hi ,
> >>>>>> One last question, when is release of 4.5.2 expected as it fixes 2
> >> bugs
> >>>> we
> >>>>>> are facing in JMeter.
> >>>>>>
> >>>>>> Thanks
> >>>>>> Regards
> >>>>>>
> >>>>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> >>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>
> >>>>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <
> olegk@apache.org
> >>>>>>> wrote:
> >>>>>>>
> >>>>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> >>>>>>>>> Hello Oleg,
> >>>>>>>>> Thanks .
> >>>>>>>>>
> >>>>>>>> Test case #testParseCookies
> >>>>>>>>
> >>>>>>>> The rest case does not look right to me. I am not sure I
> understand
> >>>> what
> >>>>>>>> you are trying to test here.
> >>>>>>>>
> >>>>>>> Indeed, bad copy paste.
> >>>>>>>
> >>>>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is
> on
> >>>>>>> JMeter side.
> >>>>>>>
> >>>>>>>> Test case #testParseCookies
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> The cookie in question does not have a version attribute mandatory
> >> for
> >>>>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed
> as
> >>>>>>>> Netscape style cookie in which case comma is not considered a
> valid
> >>>>>>>> header element delimiter and is treated as normal character.
> >>>>>>>>
> >>>>>>> Thanks for explanation.
> >>>>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
> >>>>>>>
> >>>>>>>
> >>>>>>>> Oleg
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>> Here it is:
> >>>>>>>>>
> >>>>>>>>> /*
> >>>>>>>>>  *
> >>>> ====================================================================
> >>>>>>>>>  * 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
> >>>>>>>>>  * "License"); 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
> >>>>>>>>>  * "AS IS" 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.
> >>>>>>>>>  *
> >>>> ====================================================================
> >>>>>>>>>  *
> >>>>>>>>>  * This software consists of voluntary contributions made by many
> >>>>>>>>>  * individuals on behalf of the Apache Software Foundation.  For
> >> more
> >>>>>>>>>  * information on the Apache Software Foundation, please see
> >>>>>>>>>  * <http://www.apache.org/>.
> >>>>>>>>>  *
> >>>>>>>>>  */
> >>>>>>>>> package org.apache.http.client.protocol;
> >>>>>>>>>
> >>>>>>>>> import java.util.List;
> >>>>>>>>>
> >>>>>>>>> import org.apache.http.Header;
> >>>>>>>>> import org.apache.http.HttpResponse;
> >>>>>>>>> import org.apache.http.HttpResponseInterceptor;
> >>>>>>>>> import org.apache.http.HttpVersion;
> >>>>>>>>> import org.apache.http.client.CookieStore;
> >>>>>>>>> import org.apache.http.cookie.Cookie;
> >>>>>>>>> import org.apache.http.cookie.CookieOrigin;
> >>>>>>>>> import org.apache.http.cookie.CookieSpec;
> >>>>>>>>> import org.apache.http.cookie.SM;
> >>>>>>>>> import org.apache.http.impl.client.BasicCookieStore;
> >>>>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
> >>>>>>>>> import org.apache.http.message.BasicHttpResponse;
> >>>>>>>>> import org.apache.http.util.Asserts;
> >>>>>>>>> import org.junit.Assert;
> >>>>>>>>> import org.junit.Before;
> >>>>>>>>> import org.junit.Test;
> >>>>>>>>>
> >>>>>>>>> public class TestResponseProcessCookies {
> >>>>>>>>>
> >>>>>>>>>     private CookieOrigin cookieOrigin;
> >>>>>>>>>     private CookieSpec cookieSpec;
> >>>>>>>>>     private CookieStore cookieStore;
> >>>>>>>>>
> >>>>>>>>>     @Before
> >>>>>>>>>     public void setUp() throws Exception {
> >>>>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80,
> "/",
> >>>>>>>> false);
> >>>>>>>>>         this.cookieSpec = new DefaultCookieSpec();
> >>>>>>>>>         this.cookieStore = new BasicCookieStore();
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>>>>>     public void testResponseParameterCheck() throws Exception {
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(null, context);
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>>>>>     public void testContextParameterCheck() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, null);
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testParseMultipleCookies() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
> >>>>>>>> comment=\"how,now\",
> >>>>>>>>> test2=2; version=1");
> >>>>>>>>>
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>>>>>         final Cookie cookie = cookies.get(0);
> >>>>>>>>>         Assert.assertEquals(0, cookie.getVersion());
> >>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>>>>>         Assert.assertEquals("value1", cookie.getValue());
> >>>>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
> >>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>         }
> >>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>> sbHdr.toString());
> >>>>>>>>>     }
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>>>> test2=2;secure");
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>         }
> >>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>> sbHdr.toString());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testNoCookieOrigin() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> null);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testNoCookieSpec() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> null);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testNoCookieStore() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> null);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testSetCookie2OverrideSetCookie() throws
> Exception
> >> {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> >>>> Version=1");
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>>>>>         final Cookie cookie = cookies.get(0);
> >>>>>>>>>         Assert.assertEquals(1, cookie.getVersion());
> >>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>>>>>         Assert.assertEquals("value2", cookie.getValue());
> >>>>>>>>>         Assert.assertEquals("localhost.local",
> cookie.getDomain());
> >>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testInvalidHeader() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
> >>>> Version=crap");
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testCookieRejected() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> >>>>>>>>> www.somedomain.com; Version=1");
> >>>>>>>>>
> >>>>>>>>>         final HttpClientContext context =
> >> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>> }
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> >> olegk@apache.org
> >>>>>>>> wrote:
> >>>>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use
> them
> >> ,
> >>>>>>>> put
> >>>>>>>>>> code
> >>>>>>>>>>> in org.apache.http.client.protocol.TestResponseProcessCookies.
> >>>>>>>>>>> They worked with HC3 but it does not mean they should work with
> >>>>>>>> HC4, but
> >>>>>>>>>> I
> >>>>>>>>>>> would like a confirmation:
> >>>>>>>>>>>
> >>>>>>>>>> I cannot get the tests to compile due to missing instance
> >> variables
> >>>>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another look
> >> if
> >>>>>>>> you
> >>>>>>>>>> post the complete class.
> >>>>>>>>>>
> >>>>>>>>>> Oleg
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpClientContext context =
> >>>>>>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         List<Header> lstHdr =
> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>         }
> >>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>     }
> >>>>>>>>>>>     @Test
> >>>>>>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>>>>>         final HttpResponse response = new
> >>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>>>>>> test2=2;secure");
> >>>>>>>>>>>         final HttpClientContext context =
> >>>>>>>> HttpClientContext.create();
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>>>> this.cookieOrigin);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>>>> this.cookieSpec);
> >>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>>>> this.cookieStore);
> >>>>>>>>>>>
> >>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>>>
> >>>>>>>>>>>         final List<Cookie> cookies =
> >> this.cookieStore.getCookies();
> >>>>>>>>>>>         List<Header> lstHdr =
> cookieSpec.formatCookies(cookies);
> >>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>>>         }
> >>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>>>> sbHdr.toString());
> >>>>>>>>>>>     }
> >>>>>>>>>>>
> >>>>>>>>>>> Thanks
> >>>>>>>>>>>
> >>>>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> >>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>> Hi,
> >>>>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>>>>>> with a
> >>>>>>>>>> Test
> >>>>>>>>>>>> case in it to show issue with Domain starting with ".".
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>> Regards
> >>>>>>>>>>>>
> >>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> >>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>>>> Created
> https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>>>>>> to show
> >>>>>>>>>>>>> issue with Cookie Header ordering.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> Hi,
> >>>>>>>>>>>>>>  I created
> >>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> >>>>>>>>>> with
> >>>>>>>>>>>>>> JUnit test case so that you understand the difference we
> have.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> >>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>>>>>>> Thanks Oleg.
> >>>>>>>>>>>>>>>> But look at
> >>>>>>>>>>>>>>>>
> >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >>>>>>>>>>>>>>> ,
> >>>>>>>>>>>>>>>> it concerns IGNORE_POLICY
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> I really think there is at least one bug.
> >>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in HC.
> >>>>>>>> Could
> >>>>>>>>>> you
> >>>>>>>>>>>>>>> please though reproduce them with unit tests that do not
> >>>>>>>> involve
> >>>>>>>>>> JMeter
> >>>>>>>>>>>>>>> specific code?
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> >>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad
> wrote:
> >>>>>>>>>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>>>>>>>>> Thanks for answer.
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> Find my answers inline.
> >>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >>>>>>>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> >>>>>>>> wrote:
> >>>>>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>>>>> Any answer on this question ?
> >>>>>>>>>>>>>>>>>>>> Thanks
> >>>>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> >>>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
> >>>>>>>>>> HttpClient
> >>>>>>>>>>>>>>> 4.5.1.
> >>>>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
> >>>>>>>> all
> >>>>>>>>>>>>>>> deprecated
> >>>>>>>>>>>>>>>>> code.
> >>>>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
> >>>>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>>>
> >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >>>>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
> >>>>>>>> version.
> >>>>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
> >>>>>>>>>> failures:
> >>>>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >>>>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use HC4
> >>>>>>>>>>>>>>> Implementation
> >>>>>>>>>>>>>>>>> of
> >>>>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
> >>>>>>>> compared to
> >>>>>>>>>>>>>>> HC3.
> >>>>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> >>>>>>>>>> failures
> >>>>>>>>>>>>>>> all
> >>>>>>>>>>>>>>>>>> detailed in initial mail.
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> What policy does
> >>>>>>>>>>>>>>>>>>> CookeManager use internally?
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
> >>>>>>>> depending on
> >>>>>>>>>>>>>>> test
> >>>>>>>>>>>>>>>>> method
> >>>>>>>>>>>>>>>>>> we set different Policy to test them.
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict or
> >>>>>>>> relaxed
> >>>>>>>>>>>>>>> mode
> >>>>>>>>>>>>>>>>> and nothing else. All other policies have been marked as
> >>>>>>>>>> obsolete
> >>>>>>>>>>>>>>> and
> >>>>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>>>> --
> >>>>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> --
> >>>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>> --
> >>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>> --
> >>>>>>> Cordialement.
> >>>>>>> Philippe Mouawad.
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>> --
> >>>>>> Cordialement.
> >>>>>> Philippe Mouawad.
> >>>>>>
> >>>>>>
> >>>>>>
> >>
> >
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Andrey Pokhilko <ap...@ya.ru>.
The impact of it is broken test plans. When cookie is set for .bt.com,
it means that subdomain.bt.com must receive that cookie. That's by RFC
AFAIK.

Andrey Pokhilko

On 12/15/2015 11:41 PM, Philippe Mouawad wrote:
> Hi Andrey,
> Test case is failing, but it seems to be a regular HC4.5 behaviour.
>
> What was the impact of this failing test case on JMeter side ?
> It's not clear for me from your mail, if you can give a full example with
> each step it wil help me understand.
>
> Thanks
>
> On Tue, Dec 15, 2015 at 5:56 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>
>> It's one from 10/27/2015 06:32 PM:
>>
>> Hi,
>>
>> Today we've found an issue in using HTTPClient 4.5 in JMeter. If we just
>> replace the libraries with no change to JMeter code, it stops processing
>> wildcard domains for cookies. I've failed to understand if it is
>> regression in HTTPClient or something else.
>>
>> I've managed to write a unit test for it, I can commit it into trunk if
>> needed. Unit test works fine on old libraries, but fails with 4.5:
>>
>> package org.apache.jmeter.protocol.http.control;
>>
>> import org.apache.http.cookie.Cookie;
>> import org.apache.jmeter.testelement.property.CollectionProperty;
>> import org.junit.Assert;
>> import org.junit.Test;
>>
>> import java.net.URL;
>> import java.util.List;
>>
>> public class HC4CookieHandlerTest {
>>
>>     @Test public void testAddCookieFromHeader_wildcard() throws Exception {
>>         HC4CookieHandler obj = new HC4CookieHandler("compatibility");
>>         URL url = new URL("https://subdomain.bt.com/page");
>>         CookieManager mgr = new CookieManager();
>>         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
>>         obj.addCookieFromHeader(mgr, true, headerLine, url);
>>         CollectionProperty cp = mgr.getCookies();
>>         List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
>>         Assert.assertEquals(1, res.size());
>>         for (Cookie cookie : res) {
>>             Assert.assertEquals(".bt.com", cookie.getDomain());
>>         }
>>     }
>> }
>>
>>
>>
>> Andrey Pokhilko
>>
>> On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
>>> I was searching in my mails for it :-) Andrei
>>>
>>> On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>>>
>>>> Hi,
>>>>
>>>> First of all - you've made awesome job on coordinating all this tedious
>>>> communications with Oleg. Thanks, your contribution is invaluable in my
>>>> eyes.
>>>>
>>>> Just a note - don't you want to include the test case I provided some
>>>> time ago into this PR? To make sure the initial  case that revealed
>>>> issues finally works...
>>>>
>>>> Andrey Pokhilko
>>>>
>>>> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
>>>>> Hi,
>>>>> I submitted a PR https://github.com/apache/jmeter/pull/62  after
>> fixing
>>>> the
>>>>> remaining issues I think.
>>>>> I still have one failing test , related to
>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I reopened.
>>>>>
>>>>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we need
>>>> 4.5.2
>>>>> I changed testCookies2 as per Oleg note and added testCookies3.
>>>>>
>>>>> Please review as this is very sensitive and I would really like a
>> second
>>>>> eye on it.
>>>>>
>>>>> Thanks
>>>>> Regards
>>>>>
>>>>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>
>>>>>> Hi ,
>>>>>> One last question, when is release of 4.5.2 expected as it fixes 2
>> bugs
>>>> we
>>>>>> are facing in JMeter.
>>>>>>
>>>>>> Thanks
>>>>>> Regards
>>>>>>
>>>>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>
>>>>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <olegk@apache.org
>>>>>>> wrote:
>>>>>>>
>>>>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>>>>>>>>> Hello Oleg,
>>>>>>>>> Thanks .
>>>>>>>>>
>>>>>>>> Test case #testParseCookies
>>>>>>>>
>>>>>>>> The rest case does not look right to me. I am not sure I understand
>>>> what
>>>>>>>> you are trying to test here.
>>>>>>>>
>>>>>>> Indeed, bad copy paste.
>>>>>>>
>>>>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
>>>>>>> JMeter side.
>>>>>>>
>>>>>>>> Test case #testParseCookies
>>>>>>>>
>>>>>>>>
>>>>>>>> The cookie in question does not have a version attribute mandatory
>> for
>>>>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
>>>>>>>> Netscape style cookie in which case comma is not considered a valid
>>>>>>>> header element delimiter and is treated as normal character.
>>>>>>>>
>>>>>>> Thanks for explanation.
>>>>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>>>>>>>
>>>>>>>
>>>>>>>> Oleg
>>>>>>>>
>>>>>>>>
>>>>>>>>> Here it is:
>>>>>>>>>
>>>>>>>>> /*
>>>>>>>>>  *
>>>> ====================================================================
>>>>>>>>>  * 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
>>>>>>>>>  * "License"); 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
>>>>>>>>>  * "AS IS" 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.
>>>>>>>>>  *
>>>> ====================================================================
>>>>>>>>>  *
>>>>>>>>>  * This software consists of voluntary contributions made by many
>>>>>>>>>  * individuals on behalf of the Apache Software Foundation.  For
>> more
>>>>>>>>>  * information on the Apache Software Foundation, please see
>>>>>>>>>  * <http://www.apache.org/>.
>>>>>>>>>  *
>>>>>>>>>  */
>>>>>>>>> package org.apache.http.client.protocol;
>>>>>>>>>
>>>>>>>>> import java.util.List;
>>>>>>>>>
>>>>>>>>> import org.apache.http.Header;
>>>>>>>>> import org.apache.http.HttpResponse;
>>>>>>>>> import org.apache.http.HttpResponseInterceptor;
>>>>>>>>> import org.apache.http.HttpVersion;
>>>>>>>>> import org.apache.http.client.CookieStore;
>>>>>>>>> import org.apache.http.cookie.Cookie;
>>>>>>>>> import org.apache.http.cookie.CookieOrigin;
>>>>>>>>> import org.apache.http.cookie.CookieSpec;
>>>>>>>>> import org.apache.http.cookie.SM;
>>>>>>>>> import org.apache.http.impl.client.BasicCookieStore;
>>>>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
>>>>>>>>> import org.apache.http.message.BasicHttpResponse;
>>>>>>>>> import org.apache.http.util.Asserts;
>>>>>>>>> import org.junit.Assert;
>>>>>>>>> import org.junit.Before;
>>>>>>>>> import org.junit.Test;
>>>>>>>>>
>>>>>>>>> public class TestResponseProcessCookies {
>>>>>>>>>
>>>>>>>>>     private CookieOrigin cookieOrigin;
>>>>>>>>>     private CookieSpec cookieSpec;
>>>>>>>>>     private CookieStore cookieStore;
>>>>>>>>>
>>>>>>>>>     @Before
>>>>>>>>>     public void setUp() throws Exception {
>>>>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
>>>>>>>> false);
>>>>>>>>>         this.cookieSpec = new DefaultCookieSpec();
>>>>>>>>>         this.cookieStore = new BasicCookieStore();
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>>>     public void testResponseParameterCheck() throws Exception {
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(null, context);
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>>>     public void testContextParameterCheck() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, null);
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testParseMultipleCookies() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
>>>>>>>> comment=\"how,now\",
>>>>>>>>> test2=2; version=1");
>>>>>>>>>
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>>>         Assert.assertEquals(0, cookie.getVersion());
>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>>>         Assert.assertEquals("value1", cookie.getValue());
>>>>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>         }
>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>> sbHdr.toString());
>>>>>>>>>     }
>>>>>>>>>     @Test
>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>> test2=2;secure");
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>         }
>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>> sbHdr.toString());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testNoCookieOrigin() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> null);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testNoCookieSpec() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testNoCookieStore() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testSetCookie2OverrideSetCookie() throws Exception
>> {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
>>>> Version=1");
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>>>         Assert.assertEquals(1, cookie.getVersion());
>>>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>>>         Assert.assertEquals("value2", cookie.getValue());
>>>>>>>>>         Assert.assertEquals("localhost.local", cookie.getDomain());
>>>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testInvalidHeader() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
>>>> Version=crap");
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testCookieRejected() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>>>>>>>>> www.somedomain.com; Version=1");
>>>>>>>>>
>>>>>>>>>         final HttpClientContext context =
>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
>> olegk@apache.org
>>>>>>>> wrote:
>>>>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>>>>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use them
>> ,
>>>>>>>> put
>>>>>>>>>> code
>>>>>>>>>>> in org.apache.http.client.protocol.TestResponseProcessCookies.
>>>>>>>>>>> They worked with HC3 but it does not mean they should work with
>>>>>>>> HC4, but
>>>>>>>>>> I
>>>>>>>>>>> would like a confirmation:
>>>>>>>>>>>
>>>>>>>>>> I cannot get the tests to compile due to missing instance
>> variables
>>>>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another look
>> if
>>>>>>>> you
>>>>>>>>>> post the complete class.
>>>>>>>>>>
>>>>>>>>>> Oleg
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>>>
>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>         }
>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>     }
>>>>>>>>>>>     @Test
>>>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>>>         final HttpResponse response = new
>>>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>>>> test2=2;secure");
>>>>>>>>>>>         final HttpClientContext context =
>>>>>>>> HttpClientContext.create();
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>>>> this.cookieOrigin);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>>>> this.cookieSpec);
>>>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>>>> this.cookieStore);
>>>>>>>>>>>
>>>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>>>
>>>>>>>>>>>         final List<Cookie> cookies =
>> this.cookieStore.getCookies();
>>>>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>>>         }
>>>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>>>> sbHdr.toString());
>>>>>>>>>>>     }
>>>>>>>>>>>
>>>>>>>>>>> Thanks
>>>>>>>>>>>
>>>>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi,
>>>>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>>>> with a
>>>>>>>>>> Test
>>>>>>>>>>>> case in it to show issue with Domain starting with ".".
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Regards
>>>>>>>>>>>>
>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>>>> to show
>>>>>>>>>>>>> issue with Cookie Header ordering.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi,
>>>>>>>>>>>>>>  I created
>>>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>>>>>>>>>> with
>>>>>>>>>>>>>> JUnit test case so that you understand the difference we have.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>>>> Thanks Oleg.
>>>>>>>>>>>>>>>> But look at
>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>>>>>>>>>>>>>> ,
>>>>>>>>>>>>>>>> it concerns IGNORE_POLICY
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> I really think there is at least one bug.
>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in HC.
>>>>>>>> Could
>>>>>>>>>> you
>>>>>>>>>>>>>>> please though reproduce them with unit tests that do not
>>>>>>>> involve
>>>>>>>>>> JMeter
>>>>>>>>>>>>>>> specific code?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>>>>>> Thanks for answer.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> Find my answers inline.
>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>>>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>>>>>>>> wrote:
>>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>>> Any answer on this question ?
>>>>>>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
>>>>>>>>>> HttpClient
>>>>>>>>>>>>>>> 4.5.1.
>>>>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
>>>>>>>> all
>>>>>>>>>>>>>>> deprecated
>>>>>>>>>>>>>>>>> code.
>>>>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>>>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
>>>>>>>> version.
>>>>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
>>>>>>>>>> failures:
>>>>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>>>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use HC4
>>>>>>>>>>>>>>> Implementation
>>>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
>>>>>>>> compared to
>>>>>>>>>>>>>>> HC3.
>>>>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>>>>>>>>>> failures
>>>>>>>>>>>>>>> all
>>>>>>>>>>>>>>>>>> detailed in initial mail.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> What policy does
>>>>>>>>>>>>>>>>>>> CookeManager use internally?
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
>>>>>>>> depending on
>>>>>>>>>>>>>>> test
>>>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>>>>> we set different Policy to test them.
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict or
>>>>>>>> relaxed
>>>>>>>>>>>>>>> mode
>>>>>>>>>>>>>>>>> and nothing else. All other policies have been marked as
>>>>>>>>>> obsolete
>>>>>>>>>>>>>>> and
>>>>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>> --
>>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> --
>>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>> --
>>>>>>> Cordialement.
>>>>>>> Philippe Mouawad.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> Cordialement.
>>>>>> Philippe Mouawad.
>>>>>>
>>>>>>
>>>>>>
>>
>


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Andrey,
Test case is failing, but it seems to be a regular HC4.5 behaviour.

What was the impact of this failing test case on JMeter side ?
It's not clear for me from your mail, if you can give a full example with
each step it wil help me understand.

Thanks

On Tue, Dec 15, 2015 at 5:56 PM, Andrey Pokhilko <ap...@ya.ru> wrote:

> It's one from 10/27/2015 06:32 PM:
>
> Hi,
>
> Today we've found an issue in using HTTPClient 4.5 in JMeter. If we just
> replace the libraries with no change to JMeter code, it stops processing
> wildcard domains for cookies. I've failed to understand if it is
> regression in HTTPClient or something else.
>
> I've managed to write a unit test for it, I can commit it into trunk if
> needed. Unit test works fine on old libraries, but fails with 4.5:
>
> package org.apache.jmeter.protocol.http.control;
>
> import org.apache.http.cookie.Cookie;
> import org.apache.jmeter.testelement.property.CollectionProperty;
> import org.junit.Assert;
> import org.junit.Test;
>
> import java.net.URL;
> import java.util.List;
>
> public class HC4CookieHandlerTest {
>
>     @Test public void testAddCookieFromHeader_wildcard() throws Exception {
>         HC4CookieHandler obj = new HC4CookieHandler("compatibility");
>         URL url = new URL("https://subdomain.bt.com/page");
>         CookieManager mgr = new CookieManager();
>         String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
>         obj.addCookieFromHeader(mgr, true, headerLine, url);
>         CollectionProperty cp = mgr.getCookies();
>         List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
>         Assert.assertEquals(1, res.size());
>         for (Cookie cookie : res) {
>             Assert.assertEquals(".bt.com", cookie.getDomain());
>         }
>     }
> }
>
>
>
> Andrey Pokhilko
>
> On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
> > I was searching in my mails for it :-) Andrei
> >
> > On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
> >
> >> Hi,
> >>
> >> First of all - you've made awesome job on coordinating all this tedious
> >> communications with Oleg. Thanks, your contribution is invaluable in my
> >> eyes.
> >>
> >> Just a note - don't you want to include the test case I provided some
> >> time ago into this PR? To make sure the initial  case that revealed
> >> issues finally works...
> >>
> >> Andrey Pokhilko
> >>
> >> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
> >>> Hi,
> >>> I submitted a PR https://github.com/apache/jmeter/pull/62  after
> fixing
> >> the
> >>> remaining issues I think.
> >>> I still have one failing test , related to
> >>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I reopened.
> >>>
> >>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we need
> >> 4.5.2
> >>> I changed testCookies2 as per Oleg note and added testCookies3.
> >>>
> >>> Please review as this is very sensitive and I would really like a
> second
> >>> eye on it.
> >>>
> >>> Thanks
> >>> Regards
> >>>
> >>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
> >>> philippe.mouawad@gmail.com> wrote:
> >>>
> >>>> Hi ,
> >>>> One last question, when is release of 4.5.2 expected as it fixes 2
> bugs
> >> we
> >>>> are facing in JMeter.
> >>>>
> >>>> Thanks
> >>>> Regards
> >>>>
> >>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> >>>> philippe.mouawad@gmail.com> wrote:
> >>>>
> >>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <olegk@apache.org
> >
> >>>>> wrote:
> >>>>>
> >>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> >>>>>>> Hello Oleg,
> >>>>>>> Thanks .
> >>>>>>>
> >>>>>> Test case #testParseCookies
> >>>>>>
> >>>>>> The rest case does not look right to me. I am not sure I understand
> >> what
> >>>>>> you are trying to test here.
> >>>>>>
> >>>>> Indeed, bad copy paste.
> >>>>>
> >>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> >>>>> JMeter side.
> >>>>>
> >>>>>> Test case #testParseCookies
> >>>>>>
> >>>>>>
> >>>>>> The cookie in question does not have a version attribute mandatory
> for
> >>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> >>>>>> Netscape style cookie in which case comma is not considered a valid
> >>>>>> header element delimiter and is treated as normal character.
> >>>>>>
> >>>>> Thanks for explanation.
> >>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
> >>>>>
> >>>>>
> >>>>>> Oleg
> >>>>>>
> >>>>>>
> >>>>>>> Here it is:
> >>>>>>>
> >>>>>>> /*
> >>>>>>>  *
> >> ====================================================================
> >>>>>>>  * 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
> >>>>>>>  * "License"); 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
> >>>>>>>  * "AS IS" 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.
> >>>>>>>  *
> >> ====================================================================
> >>>>>>>  *
> >>>>>>>  * This software consists of voluntary contributions made by many
> >>>>>>>  * individuals on behalf of the Apache Software Foundation.  For
> more
> >>>>>>>  * information on the Apache Software Foundation, please see
> >>>>>>>  * <http://www.apache.org/>.
> >>>>>>>  *
> >>>>>>>  */
> >>>>>>> package org.apache.http.client.protocol;
> >>>>>>>
> >>>>>>> import java.util.List;
> >>>>>>>
> >>>>>>> import org.apache.http.Header;
> >>>>>>> import org.apache.http.HttpResponse;
> >>>>>>> import org.apache.http.HttpResponseInterceptor;
> >>>>>>> import org.apache.http.HttpVersion;
> >>>>>>> import org.apache.http.client.CookieStore;
> >>>>>>> import org.apache.http.cookie.Cookie;
> >>>>>>> import org.apache.http.cookie.CookieOrigin;
> >>>>>>> import org.apache.http.cookie.CookieSpec;
> >>>>>>> import org.apache.http.cookie.SM;
> >>>>>>> import org.apache.http.impl.client.BasicCookieStore;
> >>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
> >>>>>>> import org.apache.http.message.BasicHttpResponse;
> >>>>>>> import org.apache.http.util.Asserts;
> >>>>>>> import org.junit.Assert;
> >>>>>>> import org.junit.Before;
> >>>>>>> import org.junit.Test;
> >>>>>>>
> >>>>>>> public class TestResponseProcessCookies {
> >>>>>>>
> >>>>>>>     private CookieOrigin cookieOrigin;
> >>>>>>>     private CookieSpec cookieSpec;
> >>>>>>>     private CookieStore cookieStore;
> >>>>>>>
> >>>>>>>     @Before
> >>>>>>>     public void setUp() throws Exception {
> >>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> >>>>>> false);
> >>>>>>>         this.cookieSpec = new DefaultCookieSpec();
> >>>>>>>         this.cookieStore = new BasicCookieStore();
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>>>     public void testResponseParameterCheck() throws Exception {
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(null, context);
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>>>     public void testContextParameterCheck() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, null);
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testParseMultipleCookies() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
> >>>>>> comment=\"how,now\",
> >>>>>>> test2=2; version=1");
> >>>>>>>
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>>>         final Cookie cookie = cookies.get(0);
> >>>>>>>         Assert.assertEquals(0, cookie.getVersion());
> >>>>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>>>         Assert.assertEquals("value1", cookie.getValue());
> >>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
> >>>>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>         for (Header header : lstHdr) {
> >>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>         }
> >>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>> sbHdr.toString());
> >>>>>>>     }
> >>>>>>>     @Test
> >>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>> test2=2;secure");
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>         for (Header header : lstHdr) {
> >>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>         }
> >>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>> sbHdr.toString());
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testNoCookieOrigin() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> null);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testNoCookieSpec() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testNoCookieStore() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testSetCookie2OverrideSetCookie() throws Exception
> {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> >> Version=1");
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>>>         final Cookie cookie = cookies.get(0);
> >>>>>>>         Assert.assertEquals(1, cookie.getVersion());
> >>>>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>>>         Assert.assertEquals("value2", cookie.getValue());
> >>>>>>>         Assert.assertEquals("localhost.local", cookie.getDomain());
> >>>>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testInvalidHeader() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
> >> Version=crap");
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testCookieRejected() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> >>>>>>> www.somedomain.com; Version=1");
> >>>>>>>
> >>>>>>>         final HttpClientContext context =
> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         Assert.assertNotNull(cookies);
> >>>>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>>>     }
> >>>>>>>
> >>>>>>> }
> >>>>>>>
> >>>>>>>
> >>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <
> olegk@apache.org
> >>>>>> wrote:
> >>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> >>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use them
> ,
> >>>>>> put
> >>>>>>>> code
> >>>>>>>>> in org.apache.http.client.protocol.TestResponseProcessCookies.
> >>>>>>>>> They worked with HC3 but it does not mean they should work with
> >>>>>> HC4, but
> >>>>>>>> I
> >>>>>>>>> would like a confirmation:
> >>>>>>>>>
> >>>>>>>> I cannot get the tests to compile due to missing instance
> variables
> >>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another look
> if
> >>>>>> you
> >>>>>>>> post the complete class.
> >>>>>>>>
> >>>>>>>> Oleg
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>>>
> >>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>         }
> >>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>> sbHdr.toString());
> >>>>>>>>>     }
> >>>>>>>>>     @Test
> >>>>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>>>         final HttpResponse response = new
> >>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>>>> test2=2;secure");
> >>>>>>>>>         final HttpClientContext context =
> >>>>>> HttpClientContext.create();
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>>>> this.cookieOrigin);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>>>> this.cookieSpec);
> >>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>>>> this.cookieStore);
> >>>>>>>>>
> >>>>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>>>> ResponseProcessCookies();
> >>>>>>>>>         interceptor.process(response, context);
> >>>>>>>>>
> >>>>>>>>>         final List<Cookie> cookies =
> this.cookieStore.getCookies();
> >>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>>>         for (Header header : lstHdr) {
> >>>>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>>>         }
> >>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>>>> sbHdr.toString());
> >>>>>>>>>     }
> >>>>>>>>>
> >>>>>>>>> Thanks
> >>>>>>>>>
> >>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> >>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>
> >>>>>>>>>> Hi,
> >>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>>>> with a
> >>>>>>>> Test
> >>>>>>>>>> case in it to show issue with Domain starting with ".".
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> Regards
> >>>>>>>>>>
> >>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> >>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>
> >>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>>>> to show
> >>>>>>>>>>> issue with Cookie Header ordering.
> >>>>>>>>>>>
> >>>>>>>>>>> Regards
> >>>>>>>>>>>
> >>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>
> >>>>>>>>>>>> Hi,
> >>>>>>>>>>>>  I created
> >>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> >>>>>>>> with
> >>>>>>>>>>>> JUnit test case so that you understand the difference we have.
> >>>>>>>>>>>>
> >>>>>>>>>>>> Regards
> >>>>>>>>>>>>
> >>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> >>>>>> olegk@apache.org>
> >>>>>>>>>>>> wrote:
> >>>>>>>>>>>>
> >>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>>>>> Thanks Oleg.
> >>>>>>>>>>>>>> But look at
> >>>>>>>>>>>>>>
> >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >>>>>>>>>>>>> ,
> >>>>>>>>>>>>>> it concerns IGNORE_POLICY
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> I really think there is at least one bug.
> >>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in HC.
> >>>>>> Could
> >>>>>>>> you
> >>>>>>>>>>>>> please though reproduce them with unit tests that do not
> >>>>>> involve
> >>>>>>>> JMeter
> >>>>>>>>>>>>> specific code?
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> >>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>>>>>>> Thanks for answer.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> Find my answers inline.
> >>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >>>>>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> >>>>>> wrote:
> >>>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>>> Any answer on this question ?
> >>>>>>>>>>>>>>>>>> Thanks
> >>>>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> >>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
> >>>>>>>> HttpClient
> >>>>>>>>>>>>> 4.5.1.
> >>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
> >>>>>> all
> >>>>>>>>>>>>> deprecated
> >>>>>>>>>>>>>>> code.
> >>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
> >>>>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>>>
> >>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
> >>>>>> version.
> >>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
> >>>>>>>> failures:
> >>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use HC4
> >>>>>>>>>>>>> Implementation
> >>>>>>>>>>>>>>> of
> >>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
> >>>>>> compared to
> >>>>>>>>>>>>> HC3.
> >>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> >>>>>>>> failures
> >>>>>>>>>>>>> all
> >>>>>>>>>>>>>>>> detailed in initial mail.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> What policy does
> >>>>>>>>>>>>>>>>> CookeManager use internally?
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
> >>>>>> depending on
> >>>>>>>>>>>>> test
> >>>>>>>>>>>>>>> method
> >>>>>>>>>>>>>>>> we set different Policy to test them.
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict or
> >>>>>> relaxed
> >>>>>>>>>>>>> mode
> >>>>>>>>>>>>>>> and nothing else. All other policies have been marked as
> >>>>>>>> obsolete
> >>>>>>>>>>>>> and
> >>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>
> >> ---------------------------------------------------------------------
> >>>>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >> ---------------------------------------------------------------------
> >>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>> --
> >>>>>>>>>>>> Cordialement.
> >>>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>> --
> >>>>>>>>>>> Cordialement.
> >>>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>> --
> >>>>>>>>>> Cordialement.
> >>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>
> >>>>>>
> >>>>> --
> >>>>> Cordialement.
> >>>>> Philippe Mouawad.
> >>>>>
> >>>>>
> >>>>>
> >>>> --
> >>>> Cordialement.
> >>>> Philippe Mouawad.
> >>>>
> >>>>
> >>>>
> >>
> >
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Andrey Pokhilko <ap...@ya.ru>.
It's one from 10/27/2015 06:32 PM:

Hi,

Today we've found an issue in using HTTPClient 4.5 in JMeter. If we just
replace the libraries with no change to JMeter code, it stops processing
wildcard domains for cookies. I've failed to understand if it is
regression in HTTPClient or something else.

I've managed to write a unit test for it, I can commit it into trunk if
needed. Unit test works fine on old libraries, but fails with 4.5:

package org.apache.jmeter.protocol.http.control;

import org.apache.http.cookie.Cookie;
import org.apache.jmeter.testelement.property.CollectionProperty;
import org.junit.Assert;
import org.junit.Test;

import java.net.URL;
import java.util.List;

public class HC4CookieHandlerTest {

    @Test public void testAddCookieFromHeader_wildcard() throws Exception {
        HC4CookieHandler obj = new HC4CookieHandler("compatibility");
        URL url = new URL("https://subdomain.bt.com/page");
        CookieManager mgr = new CookieManager();
        String headerLine = "SMTRYNO=1; path=/; domain=.bt.com";
        obj.addCookieFromHeader(mgr, true, headerLine, url);
        CollectionProperty cp = mgr.getCookies();
        List<Cookie> res = obj.getCookiesForUrl(cp, url, false);
        Assert.assertEquals(1, res.size());
        for (Cookie cookie : res) {
            Assert.assertEquals(".bt.com", cookie.getDomain());
        }
    }
}



Andrey Pokhilko

On 12/15/2015 07:44 PM, Philippe Mouawad wrote:
> I was searching in my mails for it :-) Andrei
>
> On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:
>
>> Hi,
>>
>> First of all - you've made awesome job on coordinating all this tedious
>> communications with Oleg. Thanks, your contribution is invaluable in my
>> eyes.
>>
>> Just a note - don't you want to include the test case I provided some
>> time ago into this PR? To make sure the initial  case that revealed
>> issues finally works...
>>
>> Andrey Pokhilko
>>
>> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
>>> Hi,
>>> I submitted a PR https://github.com/apache/jmeter/pull/62  after fixing
>> the
>>> remaining issues I think.
>>> I still have one failing test , related to
>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I reopened.
>>>
>>> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we need
>> 4.5.2
>>> I changed testCookies2 as per Oleg note and added testCookies3.
>>>
>>> Please review as this is very sensitive and I would really like a second
>>> eye on it.
>>>
>>> Thanks
>>> Regards
>>>
>>> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
>>> philippe.mouawad@gmail.com> wrote:
>>>
>>>> Hi ,
>>>> One last question, when is release of 4.5.2 expected as it fixes 2 bugs
>> we
>>>> are facing in JMeter.
>>>>
>>>> Thanks
>>>> Regards
>>>>
>>>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
>>>> philippe.mouawad@gmail.com> wrote:
>>>>
>>>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
>>>>> wrote:
>>>>>
>>>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>>>>>>> Hello Oleg,
>>>>>>> Thanks .
>>>>>>>
>>>>>> Test case #testParseCookies
>>>>>>
>>>>>> The rest case does not look right to me. I am not sure I understand
>> what
>>>>>> you are trying to test here.
>>>>>>
>>>>> Indeed, bad copy paste.
>>>>>
>>>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
>>>>> JMeter side.
>>>>>
>>>>>> Test case #testParseCookies
>>>>>>
>>>>>>
>>>>>> The cookie in question does not have a version attribute mandatory for
>>>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
>>>>>> Netscape style cookie in which case comma is not considered a valid
>>>>>> header element delimiter and is treated as normal character.
>>>>>>
>>>>> Thanks for explanation.
>>>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>>>>>
>>>>>
>>>>>> Oleg
>>>>>>
>>>>>>
>>>>>>> Here it is:
>>>>>>>
>>>>>>> /*
>>>>>>>  *
>> ====================================================================
>>>>>>>  * 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
>>>>>>>  * "License"); 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
>>>>>>>  * "AS IS" 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.
>>>>>>>  *
>> ====================================================================
>>>>>>>  *
>>>>>>>  * This software consists of voluntary contributions made by many
>>>>>>>  * individuals on behalf of the Apache Software Foundation.  For more
>>>>>>>  * information on the Apache Software Foundation, please see
>>>>>>>  * <http://www.apache.org/>.
>>>>>>>  *
>>>>>>>  */
>>>>>>> package org.apache.http.client.protocol;
>>>>>>>
>>>>>>> import java.util.List;
>>>>>>>
>>>>>>> import org.apache.http.Header;
>>>>>>> import org.apache.http.HttpResponse;
>>>>>>> import org.apache.http.HttpResponseInterceptor;
>>>>>>> import org.apache.http.HttpVersion;
>>>>>>> import org.apache.http.client.CookieStore;
>>>>>>> import org.apache.http.cookie.Cookie;
>>>>>>> import org.apache.http.cookie.CookieOrigin;
>>>>>>> import org.apache.http.cookie.CookieSpec;
>>>>>>> import org.apache.http.cookie.SM;
>>>>>>> import org.apache.http.impl.client.BasicCookieStore;
>>>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
>>>>>>> import org.apache.http.message.BasicHttpResponse;
>>>>>>> import org.apache.http.util.Asserts;
>>>>>>> import org.junit.Assert;
>>>>>>> import org.junit.Before;
>>>>>>> import org.junit.Test;
>>>>>>>
>>>>>>> public class TestResponseProcessCookies {
>>>>>>>
>>>>>>>     private CookieOrigin cookieOrigin;
>>>>>>>     private CookieSpec cookieSpec;
>>>>>>>     private CookieStore cookieStore;
>>>>>>>
>>>>>>>     @Before
>>>>>>>     public void setUp() throws Exception {
>>>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
>>>>>> false);
>>>>>>>         this.cookieSpec = new DefaultCookieSpec();
>>>>>>>         this.cookieStore = new BasicCookieStore();
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>     public void testResponseParameterCheck() throws Exception {
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(null, context);
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>>>     public void testContextParameterCheck() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, null);
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testParseMultipleCookies() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
>>>>>> comment=\"how,now\",
>>>>>>> test2=2; version=1");
>>>>>>>
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>         Assert.assertEquals(0, cookie.getVersion());
>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>         Assert.assertEquals("value1", cookie.getValue());
>>>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>         for (Header header : lstHdr) {
>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>         }
>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>> sbHdr.toString());
>>>>>>>     }
>>>>>>>     @Test
>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>> test2=2;secure");
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>         for (Header header : lstHdr) {
>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>         }
>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>> sbHdr.toString());
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testNoCookieOrigin() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testNoCookieSpec() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testNoCookieStore() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testSetCookie2OverrideSetCookie() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
>> Version=1");
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>>>         final Cookie cookie = cookies.get(0);
>>>>>>>         Assert.assertEquals(1, cookie.getVersion());
>>>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>>>         Assert.assertEquals("value2", cookie.getValue());
>>>>>>>         Assert.assertEquals("localhost.local", cookie.getDomain());
>>>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testInvalidHeader() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
>> Version=crap");
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>     }
>>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testCookieRejected() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>>>>>>> www.somedomain.com; Version=1");
>>>>>>>
>>>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         Assert.assertNotNull(cookies);
>>>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>>>     }
>>>>>>>
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <olegk@apache.org
>>>>>> wrote:
>>>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>>>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use them ,
>>>>>> put
>>>>>>>> code
>>>>>>>>> in org.apache.http.client.protocol.TestResponseProcessCookies.
>>>>>>>>> They worked with HC3 but it does not mean they should work with
>>>>>> HC4, but
>>>>>>>> I
>>>>>>>>> would like a confirmation:
>>>>>>>>>
>>>>>>>> I cannot get the tests to compile due to missing instance variables
>>>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another look if
>>>>>> you
>>>>>>>> post the complete class.
>>>>>>>>
>>>>>>>> Oleg
>>>>>>>>
>>>>>>>>
>>>>>>>>>     @Test
>>>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>>>
>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>         }
>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>> sbHdr.toString());
>>>>>>>>>     }
>>>>>>>>>     @Test
>>>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>>>         final HttpResponse response = new
>>>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>>>> test2=2;secure");
>>>>>>>>>         final HttpClientContext context =
>>>>>> HttpClientContext.create();
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>>>> this.cookieOrigin);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>>>> this.cookieSpec);
>>>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>>>> this.cookieStore);
>>>>>>>>>
>>>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>>>> ResponseProcessCookies();
>>>>>>>>>         interceptor.process(response, context);
>>>>>>>>>
>>>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>>>         for (Header header : lstHdr) {
>>>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>>>         }
>>>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>>>> sbHdr.toString());
>>>>>>>>>     }
>>>>>>>>>
>>>>>>>>> Thanks
>>>>>>>>>
>>>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>> with a
>>>>>>>> Test
>>>>>>>>>> case in it to show issue with Domain starting with ".".
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>>>> to show
>>>>>>>>>>> issue with Cookie Header ordering.
>>>>>>>>>>>
>>>>>>>>>>> Regards
>>>>>>>>>>>
>>>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Hi,
>>>>>>>>>>>>  I created
>>>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>>>>>>>> with
>>>>>>>>>>>> JUnit test case so that you understand the difference we have.
>>>>>>>>>>>>
>>>>>>>>>>>> Regards
>>>>>>>>>>>>
>>>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>>>>>> olegk@apache.org>
>>>>>>>>>>>> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>> Thanks Oleg.
>>>>>>>>>>>>>> But look at
>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>>>>>>>>>>>> ,
>>>>>>>>>>>>>> it concerns IGNORE_POLICY
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> I really think there is at least one bug.
>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>
>>>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in HC.
>>>>>> Could
>>>>>>>> you
>>>>>>>>>>>>> please though reproduce them with unit tests that do not
>>>>>> involve
>>>>>>>> JMeter
>>>>>>>>>>>>> specific code?
>>>>>>>>>>>>>
>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>>>> Thanks for answer.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Find my answers inline.
>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>>>>>> wrote:
>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>> Any answer on this question ?
>>>>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
>>>>>>>> HttpClient
>>>>>>>>>>>>> 4.5.1.
>>>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
>>>>>> all
>>>>>>>>>>>>> deprecated
>>>>>>>>>>>>>>> code.
>>>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
>>>>>> version.
>>>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
>>>>>>>> failures:
>>>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use HC4
>>>>>>>>>>>>> Implementation
>>>>>>>>>>>>>>> of
>>>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
>>>>>> compared to
>>>>>>>>>>>>> HC3.
>>>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>>>>>>>> failures
>>>>>>>>>>>>> all
>>>>>>>>>>>>>>>> detailed in initial mail.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> What policy does
>>>>>>>>>>>>>>>>> CookeManager use internally?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> It depends on tests, you can see in the code that
>>>>>> depending on
>>>>>>>>>>>>> test
>>>>>>>>>>>>>>> method
>>>>>>>>>>>>>>>> we set different Policy to test them.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict or
>>>>>> relaxed
>>>>>>>>>>>>> mode
>>>>>>>>>>>>>>> and nothing else. All other policies have been marked as
>>>>>>>> obsolete
>>>>>>>>>>>>> and
>>>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>> ---------------------------------------------------------------------
>>>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>> ---------------------------------------------------------------------
>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>> --
>>>>>>>>>>>> Cordialement.
>>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Cordialement.
>>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Cordialement.
>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>
>>>>> --
>>>>> Cordialement.
>>>>> Philippe Mouawad.
>>>>>
>>>>>
>>>>>
>>>> --
>>>> Cordialement.
>>>> Philippe Mouawad.
>>>>
>>>>
>>>>
>>
>


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
I was searching in my mails for it :-) Andrei

On Tue, Dec 15, 2015 at 5:40 PM, Andrey Pokhilko <ap...@ya.ru> wrote:

> Hi,
>
> First of all - you've made awesome job on coordinating all this tedious
> communications with Oleg. Thanks, your contribution is invaluable in my
> eyes.
>
> Just a note - don't you want to include the test case I provided some
> time ago into this PR? To make sure the initial  case that revealed
> issues finally works...
>
> Andrey Pokhilko
>
> On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
> > Hi,
> > I submitted a PR https://github.com/apache/jmeter/pull/62  after fixing
> the
> > remaining issues I think.
> > I still have one failing test , related to
> > https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I reopened.
> >
> > I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we need
> 4.5.2
> > I changed testCookies2 as per Oleg note and added testCookies3.
> >
> > Please review as this is very sensitive and I would really like a second
> > eye on it.
> >
> > Thanks
> > Regards
> >
> > On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> >> Hi ,
> >> One last question, when is release of 4.5.2 expected as it fixes 2 bugs
> we
> >> are facing in JMeter.
> >>
> >> Thanks
> >> Regards
> >>
> >> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> >> philippe.mouawad@gmail.com> wrote:
> >>
> >>>
> >>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> >>> wrote:
> >>>
> >>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> >>>>> Hello Oleg,
> >>>>> Thanks .
> >>>>>
> >>>> Test case #testParseCookies
> >>>>
> >>>> The rest case does not look right to me. I am not sure I understand
> what
> >>>> you are trying to test here.
> >>>>
> >>> Indeed, bad copy paste.
> >>>
> >>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> >>> JMeter side.
> >>>
> >>>> Test case #testParseCookies
> >>>>
> >>>>
> >>>> The cookie in question does not have a version attribute mandatory for
> >>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> >>>> Netscape style cookie in which case comma is not considered a valid
> >>>> header element delimiter and is treated as normal character.
> >>>>
> >>> Thanks for explanation.
> >>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
> >>>
> >>>
> >>>> Oleg
> >>>>
> >>>>
> >>>>> Here it is:
> >>>>>
> >>>>> /*
> >>>>>  *
> ====================================================================
> >>>>>  * 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
> >>>>>  * "License"); 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
> >>>>>  * "AS IS" 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.
> >>>>>  *
> ====================================================================
> >>>>>  *
> >>>>>  * This software consists of voluntary contributions made by many
> >>>>>  * individuals on behalf of the Apache Software Foundation.  For more
> >>>>>  * information on the Apache Software Foundation, please see
> >>>>>  * <http://www.apache.org/>.
> >>>>>  *
> >>>>>  */
> >>>>> package org.apache.http.client.protocol;
> >>>>>
> >>>>> import java.util.List;
> >>>>>
> >>>>> import org.apache.http.Header;
> >>>>> import org.apache.http.HttpResponse;
> >>>>> import org.apache.http.HttpResponseInterceptor;
> >>>>> import org.apache.http.HttpVersion;
> >>>>> import org.apache.http.client.CookieStore;
> >>>>> import org.apache.http.cookie.Cookie;
> >>>>> import org.apache.http.cookie.CookieOrigin;
> >>>>> import org.apache.http.cookie.CookieSpec;
> >>>>> import org.apache.http.cookie.SM;
> >>>>> import org.apache.http.impl.client.BasicCookieStore;
> >>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
> >>>>> import org.apache.http.message.BasicHttpResponse;
> >>>>> import org.apache.http.util.Asserts;
> >>>>> import org.junit.Assert;
> >>>>> import org.junit.Before;
> >>>>> import org.junit.Test;
> >>>>>
> >>>>> public class TestResponseProcessCookies {
> >>>>>
> >>>>>     private CookieOrigin cookieOrigin;
> >>>>>     private CookieSpec cookieSpec;
> >>>>>     private CookieStore cookieStore;
> >>>>>
> >>>>>     @Before
> >>>>>     public void setUp() throws Exception {
> >>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> >>>> false);
> >>>>>         this.cookieSpec = new DefaultCookieSpec();
> >>>>>         this.cookieStore = new BasicCookieStore();
> >>>>>     }
> >>>>>
> >>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>     public void testResponseParameterCheck() throws Exception {
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(null, context);
> >>>>>     }
> >>>>>
> >>>>>     @Test(expected=IllegalArgumentException.class)
> >>>>>     public void testContextParameterCheck() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, null);
> >>>>>     }
> >>>>>
> >>>>>     @Test
> >>>>>     public void testParseMultipleCookies() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
> >>>> comment=\"how,now\",
> >>>>> test2=2; version=1");
> >>>>>
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>> this.cookieOrigin);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>> this.cookieSpec);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>> this.cookieStore);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         Assert.assertNotNull(cookies);
> >>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>         final Cookie cookie = cookies.get(0);
> >>>>>         Assert.assertEquals(0, cookie.getVersion());
> >>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>         Assert.assertEquals("value1", cookie.getValue());
> >>>>>         Assert.assertEquals("localhost", cookie.getDomain());
> >>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>     }
> >>>>>
> >>>>>     @Test
> >>>>>     public void testParseCookies() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>> this.cookieOrigin);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>> this.cookieSpec);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>> this.cookieStore);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>         for (Header header : lstHdr) {
> >>>>>             sbHdr.append(header.getValue());
> >>>>>         }
> >>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>> sbHdr.toString());
> >>>>>     }
> >>>>>     @Test
> >>>>>     public void testParseCookies2() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>> test2=2;secure");
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>> this.cookieOrigin);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>> this.cookieSpec);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>> this.cookieStore);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>         for (Header header : lstHdr) {
> >>>>>             sbHdr.append(header.getValue());
> >>>>>         }
> >>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>> sbHdr.toString());
> >>>>>     }
> >>>>>
> >>>>>     @Test
> >>>>>     public void testNoCookieOrigin() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>> this.cookieSpec);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>> this.cookieStore);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         Assert.assertNotNull(cookies);
> >>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>     }
> >>>>>
> >>>>>     @Test
> >>>>>     public void testNoCookieSpec() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>> this.cookieOrigin);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>> this.cookieStore);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         Assert.assertNotNull(cookies);
> >>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>     }
> >>>>>
> >>>>>     @Test
> >>>>>     public void testNoCookieStore() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>> this.cookieOrigin);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>> this.cookieSpec);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         Assert.assertNotNull(cookies);
> >>>>>         Assert.assertEquals(0, cookies.size());
> >>>>>     }
> >>>>>
> >>>>>     @Test
> >>>>>     public void testSetCookie2OverrideSetCookie() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2;
> Version=1");
> >>>>>
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>> this.cookieOrigin);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>> this.cookieSpec);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>> this.cookieStore);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         Assert.assertNotNull(cookies);
> >>>>>         Assert.assertEquals(1, cookies.size());
> >>>>>         final Cookie cookie = cookies.get(0);
> >>>>>         Assert.assertEquals(1, cookie.getVersion());
> >>>>>         Assert.assertEquals("name1", cookie.getName());
> >>>>>         Assert.assertEquals("value2", cookie.getValue());
> >>>>>         Assert.assertEquals("localhost.local", cookie.getDomain());
> >>>>>         Assert.assertEquals("/", cookie.getPath());
> >>>>>     }
> >>>>>
> >>>>>     @Test
> >>>>>     public void testInvalidHeader() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE2, "name=value;
> Version=crap");
> >>>>>
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>> this.cookieOrigin);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>> this.cookieSpec);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>> this.cookieStore);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         Assert.assertNotNull(cookies);
> >>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>     }
> >>>>>
> >>>>>     @Test
> >>>>>     public void testCookieRejected() throws Exception {
> >>>>>         final HttpResponse response = new
> >>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> >>>>> www.somedomain.com; Version=1");
> >>>>>
> >>>>>         final HttpClientContext context = HttpClientContext.create();
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>> this.cookieOrigin);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>> this.cookieSpec);
> >>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>> this.cookieStore);
> >>>>>
> >>>>>         final HttpResponseInterceptor interceptor = new
> >>>>> ResponseProcessCookies();
> >>>>>         interceptor.process(response, context);
> >>>>>
> >>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>         Assert.assertNotNull(cookies);
> >>>>>         Assert.assertTrue(cookies.isEmpty());
> >>>>>     }
> >>>>>
> >>>>> }
> >>>>>
> >>>>>
> >>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <olegk@apache.org
> >
> >>>> wrote:
> >>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> >>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use them ,
> >>>> put
> >>>>>> code
> >>>>>>> in org.apache.http.client.protocol.TestResponseProcessCookies.
> >>>>>>> They worked with HC3 but it does not mean they should work with
> >>>> HC4, but
> >>>>>> I
> >>>>>>> would like a confirmation:
> >>>>>>>
> >>>>>> I cannot get the tests to compile due to missing instance variables
> >>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another look if
> >>>> you
> >>>>>> post the complete class.
> >>>>>>
> >>>>>> Oleg
> >>>>>>
> >>>>>>
> >>>>>>>     @Test
> >>>>>>>     public void testParseCookies() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >>>>>>>
> >>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>         for (Header header : lstHdr) {
> >>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>         }
> >>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>> sbHdr.toString());
> >>>>>>>     }
> >>>>>>>     @Test
> >>>>>>>     public void testParseCookies2() throws Exception {
> >>>>>>>         final HttpResponse response = new
> >>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >>>>>> test2=2;secure");
> >>>>>>>         final HttpClientContext context =
> >>>> HttpClientContext.create();
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >>>>>>> this.cookieOrigin);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >>>>>>> this.cookieSpec);
> >>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >>>>>>> this.cookieStore);
> >>>>>>>
> >>>>>>>         final HttpResponseInterceptor interceptor = new
> >>>>>>> ResponseProcessCookies();
> >>>>>>>         interceptor.process(response, context);
> >>>>>>>
> >>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
> >>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >>>>>>>         StringBuilder sbHdr = new StringBuilder();
> >>>>>>>         for (Header header : lstHdr) {
> >>>>>>>             sbHdr.append(header.getValue());
> >>>>>>>         }
> >>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
> >>>>>> sbHdr.toString());
> >>>>>>>     }
> >>>>>>>
> >>>>>>> Thanks
> >>>>>>>
> >>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> >>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>
> >>>>>>>> Hi,
> >>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>> with a
> >>>>>> Test
> >>>>>>>> case in it to show issue with Domain starting with ".".
> >>>>>>>>
> >>>>>>>>
> >>>>>>>> Regards
> >>>>>>>>
> >>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> >>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>
> >>>>>>>>> Hi Oleg,
> >>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >>>> to show
> >>>>>>>>> issue with Cookie Header ordering.
> >>>>>>>>>
> >>>>>>>>> Regards
> >>>>>>>>>
> >>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>
> >>>>>>>>>> Hi,
> >>>>>>>>>>  I created
> >>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> >>>>>> with
> >>>>>>>>>> JUnit test case so that you understand the difference we have.
> >>>>>>>>>>
> >>>>>>>>>> Regards
> >>>>>>>>>>
> >>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> >>>> olegk@apache.org>
> >>>>>>>>>> wrote:
> >>>>>>>>>>
> >>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>>> Thanks Oleg.
> >>>>>>>>>>>> But look at
> >>>>>>>>>>>>
> >>>>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >>>>>>>>>>> ,
> >>>>>>>>>>>> it concerns IGNORE_POLICY
> >>>>>>>>>>>>
> >>>>>>>>>>>> I really think there is at least one bug.
> >>>>>>>>>>>> Regards
> >>>>>>>>>>>>
> >>>>>>>>>>> Sure thing. All these issues may well be due to bugs in HC.
> >>>> Could
> >>>>>> you
> >>>>>>>>>>> please though reproduce them with unit tests that do not
> >>>> involve
> >>>>>> JMeter
> >>>>>>>>>>> specific code?
> >>>>>>>>>>>
> >>>>>>>>>>> Oleg
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> >>>>>> olegk@apache.org>
> >>>>>>>>>>> wrote:
> >>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> >>>>>>>>>>>>>> Hi Oleg,
> >>>>>>>>>>>>>> Thanks for answer.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> Find my answers inline.
> >>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >>>>>>>>>>> olegk@apache.org>
> >>>>>>>>>>>>> wrote:
> >>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> >>>> wrote:
> >>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>> Any answer on this question ?
> >>>>>>>>>>>>>>>> Thanks
> >>>>>>>>>>>>>>>> Regards
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> >>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
> >>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>> Hello,
> >>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
> >>>>>> HttpClient
> >>>>>>>>>>> 4.5.1.
> >>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
> >>>> all
> >>>>>>>>>>> deprecated
> >>>>>>>>>>>>> code.
> >>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
> >>>>>>>>>>>>>>>>>
> >>>>>>>>>>>>>>>>>
> >>>>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
> >>>> version.
> >>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
> >>>>>> failures:
> >>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use HC4
> >>>>>>>>>>> Implementation
> >>>>>>>>>>>>> of
> >>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
> >>>> compared to
> >>>>>>>>>>> HC3.
> >>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> >>>>>> failures
> >>>>>>>>>>> all
> >>>>>>>>>>>>>> detailed in initial mail.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> What policy does
> >>>>>>>>>>>>>>> CookeManager use internally?
> >>>>>>>>>>>>>>>
> >>>>>>>>>>>>>> It depends on tests, you can see in the code that
> >>>> depending on
> >>>>>>>>>>> test
> >>>>>>>>>>>>> method
> >>>>>>>>>>>>>> we set different Policy to test them.
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict or
> >>>> relaxed
> >>>>>>>>>>> mode
> >>>>>>>>>>>>> and nothing else. All other policies have been marked as
> >>>>>> obsolete
> >>>>>>>>>>> and
> >>>>>>>>>>>>> have already been removed in 5.0 (trunk).
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> Oleg
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>>>>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>>>> To unsubscribe, e-mail:
> >>>>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>>>> For additional commands, e-mail:
> >>>>>>>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>>>
> >>>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>>>>>>> To unsubscribe, e-mail:
> >>>> httpclient-users-unsubscribe@hc.apache.org
> >>>>>>>>>>> For additional commands, e-mail:
> >>>>>> httpclient-users-help@hc.apache.org
> >>>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>> --
> >>>>>>>>>> Cordialement.
> >>>>>>>>>> Philippe Mouawad.
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> --
> >>>>>>>>> Cordialement.
> >>>>>>>>> Philippe Mouawad.
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>
> >>>>>>>> --
> >>>>>>>> Cordialement.
> >>>>>>>> Philippe Mouawad.
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>>
> >>>
> >>> --
> >>> Cordialement.
> >>> Philippe Mouawad.
> >>>
> >>>
> >>>
> >>
> >> --
> >> Cordialement.
> >> Philippe Mouawad.
> >>
> >>
> >>
> >
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Andrey Pokhilko <ap...@ya.ru>.
Hi,

First of all - you've made awesome job on coordinating all this tedious
communications with Oleg. Thanks, your contribution is invaluable in my
eyes.

Just a note - don't you want to include the test case I provided some
time ago into this PR? To make sure the initial  case that revealed
issues finally works...

Andrey Pokhilko

On 12/15/2015 07:31 PM, Philippe Mouawad wrote:
> Hi,
> I submitted a PR https://github.com/apache/jmeter/pull/62  after fixing the
> remaining issues I think.
> I still have one failing test , related to
> https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I reopened.
>
> I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we need 4.5.2
> I changed testCookies2 as per Oleg note and added testCookies3.
>
> Please review as this is very sensitive and I would really like a second
> eye on it.
>
> Thanks
> Regards
>
> On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
>
>> Hi ,
>> One last question, when is release of 4.5.2 expected as it fixes 2 bugs we
>> are facing in JMeter.
>>
>> Thanks
>> Regards
>>
>> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
>> philippe.mouawad@gmail.com> wrote:
>>
>>>
>>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
>>> wrote:
>>>
>>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>>>>> Hello Oleg,
>>>>> Thanks .
>>>>>
>>>> Test case #testParseCookies
>>>>
>>>> The rest case does not look right to me. I am not sure I understand what
>>>> you are trying to test here.
>>>>
>>> Indeed, bad copy paste.
>>>
>>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
>>> JMeter side.
>>>
>>>> Test case #testParseCookies
>>>>
>>>>
>>>> The cookie in question does not have a version attribute mandatory for
>>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
>>>> Netscape style cookie in which case comma is not considered a valid
>>>> header element delimiter and is treated as normal character.
>>>>
>>> Thanks for explanation.
>>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>>>
>>>
>>>> Oleg
>>>>
>>>>
>>>>> Here it is:
>>>>>
>>>>> /*
>>>>>  * ====================================================================
>>>>>  * 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
>>>>>  * "License"); 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
>>>>>  * "AS IS" 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.
>>>>>  * ====================================================================
>>>>>  *
>>>>>  * This software consists of voluntary contributions made by many
>>>>>  * individuals on behalf of the Apache Software Foundation.  For more
>>>>>  * information on the Apache Software Foundation, please see
>>>>>  * <http://www.apache.org/>.
>>>>>  *
>>>>>  */
>>>>> package org.apache.http.client.protocol;
>>>>>
>>>>> import java.util.List;
>>>>>
>>>>> import org.apache.http.Header;
>>>>> import org.apache.http.HttpResponse;
>>>>> import org.apache.http.HttpResponseInterceptor;
>>>>> import org.apache.http.HttpVersion;
>>>>> import org.apache.http.client.CookieStore;
>>>>> import org.apache.http.cookie.Cookie;
>>>>> import org.apache.http.cookie.CookieOrigin;
>>>>> import org.apache.http.cookie.CookieSpec;
>>>>> import org.apache.http.cookie.SM;
>>>>> import org.apache.http.impl.client.BasicCookieStore;
>>>>> import org.apache.http.impl.cookie.DefaultCookieSpec;
>>>>> import org.apache.http.message.BasicHttpResponse;
>>>>> import org.apache.http.util.Asserts;
>>>>> import org.junit.Assert;
>>>>> import org.junit.Before;
>>>>> import org.junit.Test;
>>>>>
>>>>> public class TestResponseProcessCookies {
>>>>>
>>>>>     private CookieOrigin cookieOrigin;
>>>>>     private CookieSpec cookieSpec;
>>>>>     private CookieStore cookieStore;
>>>>>
>>>>>     @Before
>>>>>     public void setUp() throws Exception {
>>>>>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
>>>> false);
>>>>>         this.cookieSpec = new DefaultCookieSpec();
>>>>>         this.cookieStore = new BasicCookieStore();
>>>>>     }
>>>>>
>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>     public void testResponseParameterCheck() throws Exception {
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(null, context);
>>>>>     }
>>>>>
>>>>>     @Test(expected=IllegalArgumentException.class)
>>>>>     public void testContextParameterCheck() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, null);
>>>>>     }
>>>>>
>>>>>     @Test
>>>>>     public void testParseMultipleCookies() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;
>>>> comment=\"how,now\",
>>>>> test2=2; version=1");
>>>>>
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>> this.cookieOrigin);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>> this.cookieSpec);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>> this.cookieStore);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         Assert.assertNotNull(cookies);
>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>         final Cookie cookie = cookies.get(0);
>>>>>         Assert.assertEquals(0, cookie.getVersion());
>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>         Assert.assertEquals("value1", cookie.getValue());
>>>>>         Assert.assertEquals("localhost", cookie.getDomain());
>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>     }
>>>>>
>>>>>     @Test
>>>>>     public void testParseCookies() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>> this.cookieOrigin);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>> this.cookieSpec);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>> this.cookieStore);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>         for (Header header : lstHdr) {
>>>>>             sbHdr.append(header.getValue());
>>>>>         }
>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>> sbHdr.toString());
>>>>>     }
>>>>>     @Test
>>>>>     public void testParseCookies2() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>> test2=2;secure");
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>> this.cookieOrigin);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>> this.cookieSpec);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>> this.cookieStore);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>         for (Header header : lstHdr) {
>>>>>             sbHdr.append(header.getValue());
>>>>>         }
>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>> sbHdr.toString());
>>>>>     }
>>>>>
>>>>>     @Test
>>>>>     public void testNoCookieOrigin() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>> this.cookieSpec);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>> this.cookieStore);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         Assert.assertNotNull(cookies);
>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>     }
>>>>>
>>>>>     @Test
>>>>>     public void testNoCookieSpec() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>> this.cookieOrigin);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>> this.cookieStore);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         Assert.assertNotNull(cookies);
>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>     }
>>>>>
>>>>>     @Test
>>>>>     public void testNoCookieStore() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>> this.cookieOrigin);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>> this.cookieSpec);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         Assert.assertNotNull(cookies);
>>>>>         Assert.assertEquals(0, cookies.size());
>>>>>     }
>>>>>
>>>>>     @Test
>>>>>     public void testSetCookie2OverrideSetCookie() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
>>>>>
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>> this.cookieOrigin);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>> this.cookieSpec);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>> this.cookieStore);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         Assert.assertNotNull(cookies);
>>>>>         Assert.assertEquals(1, cookies.size());
>>>>>         final Cookie cookie = cookies.get(0);
>>>>>         Assert.assertEquals(1, cookie.getVersion());
>>>>>         Assert.assertEquals("name1", cookie.getName());
>>>>>         Assert.assertEquals("value2", cookie.getValue());
>>>>>         Assert.assertEquals("localhost.local", cookie.getDomain());
>>>>>         Assert.assertEquals("/", cookie.getPath());
>>>>>     }
>>>>>
>>>>>     @Test
>>>>>     public void testInvalidHeader() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
>>>>>
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>> this.cookieOrigin);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>> this.cookieSpec);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>> this.cookieStore);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         Assert.assertNotNull(cookies);
>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>     }
>>>>>
>>>>>     @Test
>>>>>     public void testCookieRejected() throws Exception {
>>>>>         final HttpResponse response = new
>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>>>>> www.somedomain.com; Version=1");
>>>>>
>>>>>         final HttpClientContext context = HttpClientContext.create();
>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>> this.cookieOrigin);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>> this.cookieSpec);
>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>> this.cookieStore);
>>>>>
>>>>>         final HttpResponseInterceptor interceptor = new
>>>>> ResponseProcessCookies();
>>>>>         interceptor.process(response, context);
>>>>>
>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>         Assert.assertNotNull(cookies);
>>>>>         Assert.assertTrue(cookies.isEmpty());
>>>>>     }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
>>>> wrote:
>>>>>> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>>>>>>> Finally, for those  2 I am not sure  as per RFC6265, to use them ,
>>>> put
>>>>>> code
>>>>>>> in org.apache.http.client.protocol.TestResponseProcessCookies.
>>>>>>> They worked with HC3 but it does not mean they should work with
>>>> HC4, but
>>>>>> I
>>>>>>> would like a confirmation:
>>>>>>>
>>>>>> I cannot get the tests to compile due to missing instance variables
>>>>>> cookieOrigin, cookieSpec and cookieStore. I'll take another look if
>>>> you
>>>>>> post the complete class.
>>>>>>
>>>>>> Oleg
>>>>>>
>>>>>>
>>>>>>>     @Test
>>>>>>>     public void testParseCookies() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>>>>>>
>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>         for (Header header : lstHdr) {
>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>         }
>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>> sbHdr.toString());
>>>>>>>     }
>>>>>>>     @Test
>>>>>>>     public void testParseCookies2() throws Exception {
>>>>>>>         final HttpResponse response = new
>>>>>>> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>>>>>>         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>>>>> test2=2;secure");
>>>>>>>         final HttpClientContext context =
>>>> HttpClientContext.create();
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>>>>>> this.cookieOrigin);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>>>>>> this.cookieSpec);
>>>>>>>         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>>>>>> this.cookieStore);
>>>>>>>
>>>>>>>         final HttpResponseInterceptor interceptor = new
>>>>>>> ResponseProcessCookies();
>>>>>>>         interceptor.process(response, context);
>>>>>>>
>>>>>>>         final List<Cookie> cookies = this.cookieStore.getCookies();
>>>>>>>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>>>>>>         StringBuilder sbHdr = new StringBuilder();
>>>>>>>         for (Header header : lstHdr) {
>>>>>>>             sbHdr.append(header.getValue());
>>>>>>>         }
>>>>>>>         org.junit.Assert.assertEquals("test1=1; test2=2",
>>>>>> sbHdr.toString());
>>>>>>>     }
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>> with a
>>>>>> Test
>>>>>>>> case in it to show issue with Domain starting with ".".
>>>>>>>>
>>>>>>>>
>>>>>>>> Regards
>>>>>>>>
>>>>>>>> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>
>>>>>>>>> Hi Oleg,
>>>>>>>>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>>> to show
>>>>>>>>> issue with Cookie Header ordering.
>>>>>>>>>
>>>>>>>>> Regards
>>>>>>>>>
>>>>>>>>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>  I created
>>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>>>>>> with
>>>>>>>>>> JUnit test case so that you understand the difference we have.
>>>>>>>>>>
>>>>>>>>>> Regards
>>>>>>>>>>
>>>>>>>>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>>>> olegk@apache.org>
>>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>> Thanks Oleg.
>>>>>>>>>>>> But look at
>>>>>>>>>>>>
>>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>>>>>>>>>> ,
>>>>>>>>>>>> it concerns IGNORE_POLICY
>>>>>>>>>>>>
>>>>>>>>>>>> I really think there is at least one bug.
>>>>>>>>>>>> Regards
>>>>>>>>>>>>
>>>>>>>>>>> Sure thing. All these issues may well be due to bugs in HC.
>>>> Could
>>>>>> you
>>>>>>>>>>> please though reproduce them with unit tests that do not
>>>> involve
>>>>>> JMeter
>>>>>>>>>>> specific code?
>>>>>>>>>>>
>>>>>>>>>>> Oleg
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>>>>>> olegk@apache.org>
>>>>>>>>>>> wrote:
>>>>>>>>>>>>> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>>>>>>>>>>>>> Hi Oleg,
>>>>>>>>>>>>>> Thanks for answer.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Find my answers inline.
>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>>>>>>>>>> olegk@apache.org>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>>>> wrote:
>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>> Any answer on this question ?
>>>>>>>>>>>>>>>> Thanks
>>>>>>>>>>>>>>>> Regards
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>>>>>>>>>>>>>>> philippe.mouawad@gmail.com> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Hello,
>>>>>>>>>>>>>>>>> We're in the process of migrating JMeter to last
>>>>>> HttpClient
>>>>>>>>>>> 4.5.1.
>>>>>>>>>>>>>>>>> We are now migrating the CookieManager to remove
>>>> all
>>>>>>>>>>> deprecated
>>>>>>>>>>>>> code.
>>>>>>>>>>>>>>>>> To test this class, we had a JUNIT class :
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>
>>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>>>>>>>>>>>>>>>> Before migration, it was still testing HC3
>>>> version.
>>>>>>>>>>>>>>>>> So we first switched to HC4.23 and noticed some
>>>>>> failures:
>>>>>>>>>>>>>>> I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> As I wrote, first we switched our JUnit tests to use HC4
>>>>>>>>>>> Implementation
>>>>>>>>>>>>> of
>>>>>>>>>>>>>> CookieHandler and used 4.2.3, we got some failures
>>>> compared to
>>>>>>>>>>> HC3.
>>>>>>>>>>>>>> Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>>>>>> failures
>>>>>>>>>>> all
>>>>>>>>>>>>>> detailed in initial mail.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> What policy does
>>>>>>>>>>>>>>> CookeManager use internally?
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> It depends on tests, you can see in the code that
>>>> depending on
>>>>>>>>>>> test
>>>>>>>>>>>>> method
>>>>>>>>>>>>>> we set different Policy to test them.
>>>>>>>>>>>>>>
>>>>>>>>>>>>> You ought to be using RFC6265 policy either in strict or
>>>> relaxed
>>>>>>>>>>> mode
>>>>>>>>>>>>> and nothing else. All other policies have been marked as
>>>>>> obsolete
>>>>>>>>>>> and
>>>>>>>>>>>>> have already been removed in 5.0 (trunk).
>>>>>>>>>>>>>
>>>>>>>>>>>>> Oleg
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>>>> To unsubscribe, e-mail:
>>>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>>>> For additional commands, e-mail:
>>>>>>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>>>>>>> To unsubscribe, e-mail:
>>>> httpclient-users-unsubscribe@hc.apache.org
>>>>>>>>>>> For additional commands, e-mail:
>>>>>> httpclient-users-help@hc.apache.org
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Cordialement.
>>>>>>>>>> Philippe Mouawad.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Cordialement.
>>>>>>>>> Philippe Mouawad.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Cordialement.
>>>>>>>> Philippe Mouawad.
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>
>>>>
>>>
>>> --
>>> Cordialement.
>>> Philippe Mouawad.
>>>
>>>
>>>
>>
>> --
>> Cordialement.
>> Philippe Mouawad.
>>
>>
>>
>


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
I submitted a PR https://github.com/apache/jmeter/pull/62  after fixing the
remaining issues I think.
I still have one failing test , related to
https://issues.apache.org/jira/browse/HTTPCLIENT-1705 that I reopened.

I commented the IgnorePolicy (testCookiePolicyIgnore) test  as we need 4.5.2
I changed testCookies2 as per Oleg note and added testCookies3.

Please review as this is very sensitive and I would really like a second
eye on it.

Thanks
Regards

On Tue, Dec 15, 2015 at 2:16 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi ,
> One last question, when is release of 4.5.2 expected as it fixes 2 bugs we
> are facing in JMeter.
>
> Thanks
> Regards
>
> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
>
>>
>>
>> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>>
>>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>>> > Hello Oleg,
>>> > Thanks .
>>> >
>>>
>>> Test case #testParseCookies
>>>
>>> The rest case does not look right to me. I am not sure I understand what
>>> you are trying to test here.
>>>
>> Indeed, bad copy paste.
>>
>> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
>> JMeter side.
>>
>>>
>>> Test case #testParseCookies
>>>
>>>
>>
>>> The cookie in question does not have a version attribute mandatory for
>>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
>>> Netscape style cookie in which case comma is not considered a valid
>>> header element delimiter and is treated as normal character.
>>>
>>
>> Thanks for explanation.
>> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>>
>>
>>>
>>> Oleg
>>>
>>>
>>> > Here it is:
>>> >
>>> > /*
>>> >  * ====================================================================
>>> >  * 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
>>> >  * "License"); 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
>>> >  * "AS IS" 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.
>>> >  * ====================================================================
>>> >  *
>>> >  * This software consists of voluntary contributions made by many
>>> >  * individuals on behalf of the Apache Software Foundation.  For more
>>> >  * information on the Apache Software Foundation, please see
>>> >  * <http://www.apache.org/>.
>>> >  *
>>> >  */
>>> > package org.apache.http.client.protocol;
>>> >
>>> > import java.util.List;
>>> >
>>> > import org.apache.http.Header;
>>> > import org.apache.http.HttpResponse;
>>> > import org.apache.http.HttpResponseInterceptor;
>>> > import org.apache.http.HttpVersion;
>>> > import org.apache.http.client.CookieStore;
>>> > import org.apache.http.cookie.Cookie;
>>> > import org.apache.http.cookie.CookieOrigin;
>>> > import org.apache.http.cookie.CookieSpec;
>>> > import org.apache.http.cookie.SM;
>>> > import org.apache.http.impl.client.BasicCookieStore;
>>> > import org.apache.http.impl.cookie.DefaultCookieSpec;
>>> > import org.apache.http.message.BasicHttpResponse;
>>> > import org.apache.http.util.Asserts;
>>> > import org.junit.Assert;
>>> > import org.junit.Before;
>>> > import org.junit.Test;
>>> >
>>> > public class TestResponseProcessCookies {
>>> >
>>> >     private CookieOrigin cookieOrigin;
>>> >     private CookieSpec cookieSpec;
>>> >     private CookieStore cookieStore;
>>> >
>>> >     @Before
>>> >     public void setUp() throws Exception {
>>> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
>>> false);
>>> >         this.cookieSpec = new DefaultCookieSpec();
>>> >         this.cookieStore = new BasicCookieStore();
>>> >     }
>>> >
>>> >     @Test(expected=IllegalArgumentException.class)
>>> >     public void testResponseParameterCheck() throws Exception {
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(null, context);
>>> >     }
>>> >
>>> >     @Test(expected=IllegalArgumentException.class)
>>> >     public void testContextParameterCheck() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, null);
>>> >     }
>>> >
>>> >     @Test
>>> >     public void testParseMultipleCookies() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "test1=1;
>>> comment=\"how,now\",
>>> > test2=2; version=1");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         Assert.assertNotNull(cookies);
>>> >         Assert.assertEquals(1, cookies.size());
>>> >         final Cookie cookie = cookies.get(0);
>>> >         Assert.assertEquals(0, cookie.getVersion());
>>> >         Assert.assertEquals("name1", cookie.getName());
>>> >         Assert.assertEquals("value1", cookie.getValue());
>>> >         Assert.assertEquals("localhost", cookie.getDomain());
>>> >         Assert.assertEquals("/", cookie.getPath());
>>> >     }
>>> >
>>> >     @Test
>>> >     public void testParseCookies() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>> >         StringBuilder sbHdr = new StringBuilder();
>>> >         for (Header header : lstHdr) {
>>> >             sbHdr.append(header.getValue());
>>> >         }
>>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>>> sbHdr.toString());
>>> >     }
>>> >     @Test
>>> >     public void testParseCookies2() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>> test2=2;secure");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>> >         StringBuilder sbHdr = new StringBuilder();
>>> >         for (Header header : lstHdr) {
>>> >             sbHdr.append(header.getValue());
>>> >         }
>>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>>> sbHdr.toString());
>>> >     }
>>> >
>>> >     @Test
>>> >     public void testNoCookieOrigin() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         Assert.assertNotNull(cookies);
>>> >         Assert.assertEquals(0, cookies.size());
>>> >     }
>>> >
>>> >     @Test
>>> >     public void testNoCookieSpec() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         Assert.assertNotNull(cookies);
>>> >         Assert.assertEquals(0, cookies.size());
>>> >     }
>>> >
>>> >     @Test
>>> >     public void testNoCookieStore() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         Assert.assertNotNull(cookies);
>>> >         Assert.assertEquals(0, cookies.size());
>>> >     }
>>> >
>>> >     @Test
>>> >     public void testSetCookie2OverrideSetCookie() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>> >         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         Assert.assertNotNull(cookies);
>>> >         Assert.assertEquals(1, cookies.size());
>>> >         final Cookie cookie = cookies.get(0);
>>> >         Assert.assertEquals(1, cookie.getVersion());
>>> >         Assert.assertEquals("name1", cookie.getName());
>>> >         Assert.assertEquals("value2", cookie.getValue());
>>> >         Assert.assertEquals("localhost.local", cookie.getDomain());
>>> >         Assert.assertEquals("/", cookie.getPath());
>>> >     }
>>> >
>>> >     @Test
>>> >     public void testInvalidHeader() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         Assert.assertNotNull(cookies);
>>> >         Assert.assertTrue(cookies.isEmpty());
>>> >     }
>>> >
>>> >     @Test
>>> >     public void testCookieRejected() throws Exception {
>>> >         final HttpResponse response = new
>>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>>> > www.somedomain.com; Version=1");
>>> >
>>> >         final HttpClientContext context = HttpClientContext.create();
>>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > this.cookieOrigin);
>>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > this.cookieSpec);
>>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > this.cookieStore);
>>> >
>>> >         final HttpResponseInterceptor interceptor = new
>>> > ResponseProcessCookies();
>>> >         interceptor.process(response, context);
>>> >
>>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> >         Assert.assertNotNull(cookies);
>>> >         Assert.assertTrue(cookies.isEmpty());
>>> >     }
>>> >
>>> > }
>>> >
>>> >
>>> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
>>> wrote:
>>> >
>>> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>>> > > > Finally, for those  2 I am not sure  as per RFC6265, to use them ,
>>> put
>>> > > code
>>> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
>>> > > > They worked with HC3 but it does not mean they should work with
>>> HC4, but
>>> > > I
>>> > > > would like a confirmation:
>>> > > >
>>> > >
>>> > > I cannot get the tests to compile due to missing instance variables
>>> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look if
>>> you
>>> > > post the complete class.
>>> > >
>>> > > Oleg
>>> > >
>>> > >
>>> > > >
>>> > > >     @Test
>>> > > >     public void testParseCookies() throws Exception {
>>> > > >         final HttpResponse response = new
>>> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>>> > > >
>>> > > >         final HttpClientContext context =
>>> HttpClientContext.create();
>>> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > > > this.cookieOrigin);
>>> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > > > this.cookieSpec);
>>> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > > > this.cookieStore);
>>> > > >
>>> > > >         final HttpResponseInterceptor interceptor = new
>>> > > > ResponseProcessCookies();
>>> > > >         interceptor.process(response, context);
>>> > > >
>>> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>> > > >         StringBuilder sbHdr = new StringBuilder();
>>> > > >         for (Header header : lstHdr) {
>>> > > >             sbHdr.append(header.getValue());
>>> > > >         }
>>> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
>>> > > sbHdr.toString());
>>> > > >     }
>>> > > >     @Test
>>> > > >     public void testParseCookies2() throws Exception {
>>> > > >         final HttpResponse response = new
>>> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>>> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>>> > > test2=2;secure");
>>> > > >
>>> > > >         final HttpClientContext context =
>>> HttpClientContext.create();
>>> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>>> > > > this.cookieOrigin);
>>> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>>> > > > this.cookieSpec);
>>> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>>> > > > this.cookieStore);
>>> > > >
>>> > > >         final HttpResponseInterceptor interceptor = new
>>> > > > ResponseProcessCookies();
>>> > > >         interceptor.process(response, context);
>>> > > >
>>> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
>>> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>>> > > >         StringBuilder sbHdr = new StringBuilder();
>>> > > >         for (Header header : lstHdr) {
>>> > > >             sbHdr.append(header.getValue());
>>> > > >         }
>>> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
>>> > > sbHdr.toString());
>>> > > >     }
>>> > > >
>>> > > > Thanks
>>> > > >
>>> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>>> > > > philippe.mouawad@gmail.com> wrote:
>>> > > >
>>> > > > > Hi,
>>> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>> with a
>>> > > Test
>>> > > > > case in it to show issue with Domain starting with ".".
>>> > > > >
>>> > > > >
>>> > > > > Regards
>>> > > > >
>>> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>>> > > > > philippe.mouawad@gmail.com> wrote:
>>> > > > >
>>> > > > >> Hi Oleg,
>>> > > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>>> to show
>>> > > > >> issue with Cookie Header ordering.
>>> > > > >>
>>> > > > >> Regards
>>> > > > >>
>>> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>>> > > > >> philippe.mouawad@gmail.com> wrote:
>>> > > > >>
>>> > > > >>> Hi,
>>> > > > >>>  I created
>>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>>> > > with
>>> > > > >>> JUnit test case so that you understand the difference we have.
>>> > > > >>>
>>> > > > >>> Regards
>>> > > > >>>
>>> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>>> olegk@apache.org>
>>> > > > >>> wrote:
>>> > > > >>>
>>> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>> > > > >>>> > Thanks Oleg.
>>> > > > >>>> > But look at
>>> > > > >>>> >
>>> > > > >>>>
>>> > >
>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>> > > > >>>> ,
>>> > > > >>>> > it concerns IGNORE_POLICY
>>> > > > >>>> >
>>> > > > >>>> > I really think there is at least one bug.
>>> > > > >>>> > Regards
>>> > > > >>>> >
>>> > > > >>>>
>>> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
>>> Could
>>> > > you
>>> > > > >>>> please though reproduce them with unit tests that do not
>>> involve
>>> > > JMeter
>>> > > > >>>> specific code?
>>> > > > >>>>
>>> > > > >>>> Oleg
>>> > > > >>>>
>>> > > > >>>>
>>> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>>> > > olegk@apache.org>
>>> > > > >>>> wrote:
>>> > > > >>>> >
>>> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>> > > > >>>> > > > Hi Oleg,
>>> > > > >>>> > > > Thanks for answer.
>>> > > > >>>> > > >
>>> > > > >>>> > > > Find my answers inline.
>>> > > > >>>> > > > Regards
>>> > > > >>>> > > >
>>> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>> > > > >>>> olegk@apache.org>
>>> > > > >>>> > > wrote:
>>> > > > >>>> > > >
>>> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>>> wrote:
>>> > > > >>>> > > > > > Hello,
>>> > > > >>>> > > > > > Any answer on this question ?
>>> > > > >>>> > > > > > Thanks
>>> > > > >>>> > > > > > Regards
>>> > > > >>>> > > > > >
>>> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
>>> > > > >>>> > > > > >
>>> > > > >>>> > > > > > > Hello,
>>> > > > >>>> > > > > > > We're in the process of migrating JMeter to last
>>> > > HttpClient
>>> > > > >>>> 4.5.1.
>>> > > > >>>> > > > > > >
>>> > > > >>>> > > > > > > We are now migrating the CookieManager to remove
>>> all
>>> > > > >>>> deprecated
>>> > > > >>>> > > code.
>>> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
>>> > > > >>>> > > > > > >
>>> > > > >>>> > > > > > >
>>> > > > >>>> > > > >
>>> > > > >>>> > >
>>> > > > >>>>
>>> > >
>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>> > > > >>>> > > > > > >
>>> > > > >>>> > > > > > > Before migration, it was still testing HC3
>>> version.
>>> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
>>> > > failures:
>>> > > > >>>> > > > > > >
>>> > > > >>>> > > > >
>>> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>> > > > >>>> > > >
>>> > > > >>>> > > >
>>> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>>> > > > >>>> Implementation
>>> > > > >>>> > > of
>>> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
>>> compared to
>>> > > > >>>> HC3.
>>> > > > >>>> > > >
>>> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>>> > > failures
>>> > > > >>>> all
>>> > > > >>>> > > > detailed in initial mail.
>>> > > > >>>> > > >
>>> > > > >>>> > > >
>>> > > > >>>> > > > What policy does
>>> > > > >>>> > > > > CookeManager use internally?
>>> > > > >>>> > > > >
>>> > > > >>>> > > > It depends on tests, you can see in the code that
>>> depending on
>>> > > > >>>> test
>>> > > > >>>> > > method
>>> > > > >>>> > > > we set different Policy to test them.
>>> > > > >>>> > > >
>>> > > > >>>> > >
>>> > > > >>>> > > You ought to be using RFC6265 policy either in strict or
>>> relaxed
>>> > > > >>>> mode
>>> > > > >>>> > > and nothing else. All other policies have been marked as
>>> > > obsolete
>>> > > > >>>> and
>>> > > > >>>> > > have already been removed in 5.0 (trunk).
>>> > > > >>>> > >
>>> > > > >>>> > > Oleg
>>> > > > >>>> > >
>>> > > > >>>> > >
>>> > > > >>>> > >
>>> > > > >>>>
>>> > > ---------------------------------------------------------------------
>>> > > > >>>> > > To unsubscribe, e-mail:
>>> > > httpclient-users-unsubscribe@hc.apache.org
>>> > > > >>>> > > For additional commands, e-mail:
>>> > > > >>>> httpclient-users-help@hc.apache.org
>>> > > > >>>> > >
>>> > > > >>>> > >
>>> > > > >>>> >
>>> > > > >>>> >
>>> > > > >>>>
>>> > > > >>>>
>>> > > > >>>>
>>> > > > >>>>
>>> > > ---------------------------------------------------------------------
>>> > > > >>>> To unsubscribe, e-mail:
>>> httpclient-users-unsubscribe@hc.apache.org
>>> > > > >>>> For additional commands, e-mail:
>>> > > httpclient-users-help@hc.apache.org
>>> > > > >>>>
>>> > > > >>>>
>>> > > > >>>
>>> > > > >>>
>>> > > > >>> --
>>> > > > >>> Cordialement.
>>> > > > >>> Philippe Mouawad.
>>> > > > >>>
>>> > > > >>>
>>> > > > >>>
>>> > > > >>
>>> > > > >>
>>> > > > >> --
>>> > > > >> Cordialement.
>>> > > > >> Philippe Mouawad.
>>> > > > >>
>>> > > > >>
>>> > > > >>
>>> > > > >
>>> > > > >
>>> > > > > --
>>> > > > > Cordialement.
>>> > > > > Philippe Mouawad.
>>> > > > >
>>> > > > >
>>> > > > >
>>> > > >
>>> > > >
>>> > >
>>> > >
>>> > >
>>> >
>>> >
>>>
>>>
>>>
>>
>>
>> --
>> Cordialement.
>> Philippe Mouawad.
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2015-12-15 at 14:16 +0100, Philippe Mouawad wrote:
> Hi ,
> One last question, when is release of 4.5.2 expected as it fixes 2 bugs we
> are facing in JMeter.
> 
> Thanks
> Regards
> 

Philippe

I was not planning to do HC 4.5.2 any time soon. I would very much
rather get the first alpha of HC 5.0. How soon do you need it?

Oleg


> On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
> 
> >
> >
> > On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> >
> >> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> >> > Hello Oleg,
> >> > Thanks .
> >> >
> >>
> >> Test case #testParseCookies
> >>
> >> The rest case does not look right to me. I am not sure I understand what
> >> you are trying to test here.
> >>
> > Indeed, bad copy paste.
> >
> > The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> > JMeter side.
> >
> >>
> >> Test case #testParseCookies
> >>
> >>
> >
> >> The cookie in question does not have a version attribute mandatory for
> >> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> >> Netscape style cookie in which case comma is not considered a valid
> >> header element delimiter and is treated as normal character.
> >>
> >
> > Thanks for explanation.
> > Note that test case worked fine in HC3. Was it a bug in HC3 ?
> >
> >
> >>
> >> Oleg
> >>
> >>
> >> > Here it is:
> >> >
> >> > /*
> >> >  * ====================================================================
> >> >  * 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
> >> >  * "License"); 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
> >> >  * "AS IS" 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.
> >> >  * ====================================================================
> >> >  *
> >> >  * This software consists of voluntary contributions made by many
> >> >  * individuals on behalf of the Apache Software Foundation.  For more
> >> >  * information on the Apache Software Foundation, please see
> >> >  * <http://www.apache.org/>.
> >> >  *
> >> >  */
> >> > package org.apache.http.client.protocol;
> >> >
> >> > import java.util.List;
> >> >
> >> > import org.apache.http.Header;
> >> > import org.apache.http.HttpResponse;
> >> > import org.apache.http.HttpResponseInterceptor;
> >> > import org.apache.http.HttpVersion;
> >> > import org.apache.http.client.CookieStore;
> >> > import org.apache.http.cookie.Cookie;
> >> > import org.apache.http.cookie.CookieOrigin;
> >> > import org.apache.http.cookie.CookieSpec;
> >> > import org.apache.http.cookie.SM;
> >> > import org.apache.http.impl.client.BasicCookieStore;
> >> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> >> > import org.apache.http.message.BasicHttpResponse;
> >> > import org.apache.http.util.Asserts;
> >> > import org.junit.Assert;
> >> > import org.junit.Before;
> >> > import org.junit.Test;
> >> >
> >> > public class TestResponseProcessCookies {
> >> >
> >> >     private CookieOrigin cookieOrigin;
> >> >     private CookieSpec cookieSpec;
> >> >     private CookieStore cookieStore;
> >> >
> >> >     @Before
> >> >     public void setUp() throws Exception {
> >> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> >> false);
> >> >         this.cookieSpec = new DefaultCookieSpec();
> >> >         this.cookieStore = new BasicCookieStore();
> >> >     }
> >> >
> >> >     @Test(expected=IllegalArgumentException.class)
> >> >     public void testResponseParameterCheck() throws Exception {
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(null, context);
> >> >     }
> >> >
> >> >     @Test(expected=IllegalArgumentException.class)
> >> >     public void testContextParameterCheck() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, null);
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testParseMultipleCookies() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
> >> > test2=2; version=1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(1, cookies.size());
> >> >         final Cookie cookie = cookies.get(0);
> >> >         Assert.assertEquals(0, cookie.getVersion());
> >> >         Assert.assertEquals("name1", cookie.getName());
> >> >         Assert.assertEquals("value1", cookie.getValue());
> >> >         Assert.assertEquals("localhost", cookie.getDomain());
> >> >         Assert.assertEquals("/", cookie.getPath());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testParseCookies() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >> >         StringBuilder sbHdr = new StringBuilder();
> >> >         for (Header header : lstHdr) {
> >> >             sbHdr.append(header.getValue());
> >> >         }
> >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> >> sbHdr.toString());
> >> >     }
> >> >     @Test
> >> >     public void testParseCookies2() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >> test2=2;secure");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >> >         StringBuilder sbHdr = new StringBuilder();
> >> >         for (Header header : lstHdr) {
> >> >             sbHdr.append(header.getValue());
> >> >         }
> >> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> >> sbHdr.toString());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testNoCookieOrigin() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(0, cookies.size());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testNoCookieSpec() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(0, cookies.size());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testNoCookieStore() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(0, cookies.size());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testSetCookie2OverrideSetCookie() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> >         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertEquals(1, cookies.size());
> >> >         final Cookie cookie = cookies.get(0);
> >> >         Assert.assertEquals(1, cookie.getVersion());
> >> >         Assert.assertEquals("name1", cookie.getName());
> >> >         Assert.assertEquals("value2", cookie.getValue());
> >> >         Assert.assertEquals("localhost.local", cookie.getDomain());
> >> >         Assert.assertEquals("/", cookie.getPath());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testInvalidHeader() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertTrue(cookies.isEmpty());
> >> >     }
> >> >
> >> >     @Test
> >> >     public void testCookieRejected() throws Exception {
> >> >         final HttpResponse response = new
> >> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> >> > www.somedomain.com; Version=1");
> >> >
> >> >         final HttpClientContext context = HttpClientContext.create();
> >> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > this.cookieOrigin);
> >> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > this.cookieSpec);
> >> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > this.cookieStore);
> >> >
> >> >         final HttpResponseInterceptor interceptor = new
> >> > ResponseProcessCookies();
> >> >         interceptor.process(response, context);
> >> >
> >> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> >         Assert.assertNotNull(cookies);
> >> >         Assert.assertTrue(cookies.isEmpty());
> >> >     }
> >> >
> >> > }
> >> >
> >> >
> >> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
> >> wrote:
> >> >
> >> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> >> > > > Finally, for those  2 I am not sure  as per RFC6265, to use them ,
> >> put
> >> > > code
> >> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> >> > > > They worked with HC3 but it does not mean they should work with
> >> HC4, but
> >> > > I
> >> > > > would like a confirmation:
> >> > > >
> >> > >
> >> > > I cannot get the tests to compile due to missing instance variables
> >> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look if
> >> you
> >> > > post the complete class.
> >> > >
> >> > > Oleg
> >> > >
> >> > >
> >> > > >
> >> > > >     @Test
> >> > > >     public void testParseCookies() throws Exception {
> >> > > >         final HttpResponse response = new
> >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >> > > >
> >> > > >         final HttpClientContext context =
> >> HttpClientContext.create();
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > > > this.cookieOrigin);
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > > > this.cookieSpec);
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > > > this.cookieStore);
> >> > > >
> >> > > >         final HttpResponseInterceptor interceptor = new
> >> > > > ResponseProcessCookies();
> >> > > >         interceptor.process(response, context);
> >> > > >
> >> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >> > > >         StringBuilder sbHdr = new StringBuilder();
> >> > > >         for (Header header : lstHdr) {
> >> > > >             sbHdr.append(header.getValue());
> >> > > >         }
> >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> >> > > sbHdr.toString());
> >> > > >     }
> >> > > >     @Test
> >> > > >     public void testParseCookies2() throws Exception {
> >> > > >         final HttpResponse response = new
> >> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> >> > > test2=2;secure");
> >> > > >
> >> > > >         final HttpClientContext context =
> >> HttpClientContext.create();
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> >> > > > this.cookieOrigin);
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> >> > > > this.cookieSpec);
> >> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> >> > > > this.cookieStore);
> >> > > >
> >> > > >         final HttpResponseInterceptor interceptor = new
> >> > > > ResponseProcessCookies();
> >> > > >         interceptor.process(response, context);
> >> > > >
> >> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >> > > >         StringBuilder sbHdr = new StringBuilder();
> >> > > >         for (Header header : lstHdr) {
> >> > > >             sbHdr.append(header.getValue());
> >> > > >         }
> >> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> >> > > sbHdr.toString());
> >> > > >     }
> >> > > >
> >> > > > Thanks
> >> > > >
> >> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> >> > > > philippe.mouawad@gmail.com> wrote:
> >> > > >
> >> > > > > Hi,
> >> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >> with a
> >> > > Test
> >> > > > > case in it to show issue with Domain starting with ".".
> >> > > > >
> >> > > > >
> >> > > > > Regards
> >> > > > >
> >> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> >> > > > > philippe.mouawad@gmail.com> wrote:
> >> > > > >
> >> > > > >> Hi Oleg,
> >> > > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> >> to show
> >> > > > >> issue with Cookie Header ordering.
> >> > > > >>
> >> > > > >> Regards
> >> > > > >>
> >> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >> > > > >> philippe.mouawad@gmail.com> wrote:
> >> > > > >>
> >> > > > >>> Hi,
> >> > > > >>>  I created
> >> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> >> > > with
> >> > > > >>> JUnit test case so that you understand the difference we have.
> >> > > > >>>
> >> > > > >>> Regards
> >> > > > >>>
> >> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> >> olegk@apache.org>
> >> > > > >>> wrote:
> >> > > > >>>
> >> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> >> > > > >>>> > Thanks Oleg.
> >> > > > >>>> > But look at
> >> > > > >>>> >
> >> > > > >>>>
> >> > >
> >> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >> > > > >>>> ,
> >> > > > >>>> > it concerns IGNORE_POLICY
> >> > > > >>>> >
> >> > > > >>>> > I really think there is at least one bug.
> >> > > > >>>> > Regards
> >> > > > >>>> >
> >> > > > >>>>
> >> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
> >> Could
> >> > > you
> >> > > > >>>> please though reproduce them with unit tests that do not
> >> involve
> >> > > JMeter
> >> > > > >>>> specific code?
> >> > > > >>>>
> >> > > > >>>> Oleg
> >> > > > >>>>
> >> > > > >>>>
> >> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> >> > > olegk@apache.org>
> >> > > > >>>> wrote:
> >> > > > >>>> >
> >> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> >> > > > >>>> > > > Hi Oleg,
> >> > > > >>>> > > > Thanks for answer.
> >> > > > >>>> > > >
> >> > > > >>>> > > > Find my answers inline.
> >> > > > >>>> > > > Regards
> >> > > > >>>> > > >
> >> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >> > > > >>>> olegk@apache.org>
> >> > > > >>>> > > wrote:
> >> > > > >>>> > > >
> >> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> >> wrote:
> >> > > > >>>> > > > > > Hello,
> >> > > > >>>> > > > > > Any answer on this question ?
> >> > > > >>>> > > > > > Thanks
> >> > > > >>>> > > > > > Regards
> >> > > > >>>> > > > > >
> >> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> >> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> >> > > > >>>> > > > > >
> >> > > > >>>> > > > > > > Hello,
> >> > > > >>>> > > > > > > We're in the process of migrating JMeter to last
> >> > > HttpClient
> >> > > > >>>> 4.5.1.
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > > > > We are now migrating the CookieManager to remove
> >> all
> >> > > > >>>> deprecated
> >> > > > >>>> > > code.
> >> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > >
> >> > > > >>>> > >
> >> > > > >>>>
> >> > >
> >> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > > > > Before migration, it was still testing HC3 version.
> >> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> >> > > failures:
> >> > > > >>>> > > > > > >
> >> > > > >>>> > > > >
> >> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >> > > > >>>> > > >
> >> > > > >>>> > > >
> >> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> >> > > > >>>> Implementation
> >> > > > >>>> > > of
> >> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
> >> compared to
> >> > > > >>>> HC3.
> >> > > > >>>> > > >
> >> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> >> > > failures
> >> > > > >>>> all
> >> > > > >>>> > > > detailed in initial mail.
> >> > > > >>>> > > >
> >> > > > >>>> > > >
> >> > > > >>>> > > > What policy does
> >> > > > >>>> > > > > CookeManager use internally?
> >> > > > >>>> > > > >
> >> > > > >>>> > > > It depends on tests, you can see in the code that
> >> depending on
> >> > > > >>>> test
> >> > > > >>>> > > method
> >> > > > >>>> > > > we set different Policy to test them.
> >> > > > >>>> > > >
> >> > > > >>>> > >
> >> > > > >>>> > > You ought to be using RFC6265 policy either in strict or
> >> relaxed
> >> > > > >>>> mode
> >> > > > >>>> > > and nothing else. All other policies have been marked as
> >> > > obsolete
> >> > > > >>>> and
> >> > > > >>>> > > have already been removed in 5.0 (trunk).
> >> > > > >>>> > >
> >> > > > >>>> > > Oleg
> >> > > > >>>> > >
> >> > > > >>>> > >
> >> > > > >>>> > >
> >> > > > >>>>
> >> > > ---------------------------------------------------------------------
> >> > > > >>>> > > To unsubscribe, e-mail:
> >> > > httpclient-users-unsubscribe@hc.apache.org
> >> > > > >>>> > > For additional commands, e-mail:
> >> > > > >>>> httpclient-users-help@hc.apache.org
> >> > > > >>>> > >
> >> > > > >>>> > >
> >> > > > >>>> >
> >> > > > >>>> >
> >> > > > >>>>
> >> > > > >>>>
> >> > > > >>>>
> >> > > > >>>>
> >> > > ---------------------------------------------------------------------
> >> > > > >>>> To unsubscribe, e-mail:
> >> httpclient-users-unsubscribe@hc.apache.org
> >> > > > >>>> For additional commands, e-mail:
> >> > > httpclient-users-help@hc.apache.org
> >> > > > >>>>
> >> > > > >>>>
> >> > > > >>>
> >> > > > >>>
> >> > > > >>> --
> >> > > > >>> Cordialement.
> >> > > > >>> Philippe Mouawad.
> >> > > > >>>
> >> > > > >>>
> >> > > > >>>
> >> > > > >>
> >> > > > >>
> >> > > > >> --
> >> > > > >> Cordialement.
> >> > > > >> Philippe Mouawad.
> >> > > > >>
> >> > > > >>
> >> > > > >>
> >> > > > >
> >> > > > >
> >> > > > > --
> >> > > > > Cordialement.
> >> > > > > Philippe Mouawad.
> >> > > > >
> >> > > > >
> >> > > > >
> >> > > >
> >> > > >
> >> > >
> >> > >
> >> > >
> >> >
> >> >
> >>
> >>
> >>
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
> >
> >
> >
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi ,
One last question, when is release of 4.5.2 expected as it fixes 2 bugs we
are facing in JMeter.

Thanks
Regards

On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

>
>
> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>> > Hello Oleg,
>> > Thanks .
>> >
>>
>> Test case #testParseCookies
>>
>> The rest case does not look right to me. I am not sure I understand what
>> you are trying to test here.
>>
> Indeed, bad copy paste.
>
> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> JMeter side.
>
>>
>> Test case #testParseCookies
>>
>>
>
>> The cookie in question does not have a version attribute mandatory for
>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
>> Netscape style cookie in which case comma is not considered a valid
>> header element delimiter and is treated as normal character.
>>
>
> Thanks for explanation.
> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>
>
>>
>> Oleg
>>
>>
>> > Here it is:
>> >
>> > /*
>> >  * ====================================================================
>> >  * 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
>> >  * "License"); 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
>> >  * "AS IS" 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.
>> >  * ====================================================================
>> >  *
>> >  * This software consists of voluntary contributions made by many
>> >  * individuals on behalf of the Apache Software Foundation.  For more
>> >  * information on the Apache Software Foundation, please see
>> >  * <http://www.apache.org/>.
>> >  *
>> >  */
>> > package org.apache.http.client.protocol;
>> >
>> > import java.util.List;
>> >
>> > import org.apache.http.Header;
>> > import org.apache.http.HttpResponse;
>> > import org.apache.http.HttpResponseInterceptor;
>> > import org.apache.http.HttpVersion;
>> > import org.apache.http.client.CookieStore;
>> > import org.apache.http.cookie.Cookie;
>> > import org.apache.http.cookie.CookieOrigin;
>> > import org.apache.http.cookie.CookieSpec;
>> > import org.apache.http.cookie.SM;
>> > import org.apache.http.impl.client.BasicCookieStore;
>> > import org.apache.http.impl.cookie.DefaultCookieSpec;
>> > import org.apache.http.message.BasicHttpResponse;
>> > import org.apache.http.util.Asserts;
>> > import org.junit.Assert;
>> > import org.junit.Before;
>> > import org.junit.Test;
>> >
>> > public class TestResponseProcessCookies {
>> >
>> >     private CookieOrigin cookieOrigin;
>> >     private CookieSpec cookieSpec;
>> >     private CookieStore cookieStore;
>> >
>> >     @Before
>> >     public void setUp() throws Exception {
>> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
>> false);
>> >         this.cookieSpec = new DefaultCookieSpec();
>> >         this.cookieStore = new BasicCookieStore();
>> >     }
>> >
>> >     @Test(expected=IllegalArgumentException.class)
>> >     public void testResponseParameterCheck() throws Exception {
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(null, context);
>> >     }
>> >
>> >     @Test(expected=IllegalArgumentException.class)
>> >     public void testContextParameterCheck() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, null);
>> >     }
>> >
>> >     @Test
>> >     public void testParseMultipleCookies() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
>> > test2=2; version=1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(1, cookies.size());
>> >         final Cookie cookie = cookies.get(0);
>> >         Assert.assertEquals(0, cookie.getVersion());
>> >         Assert.assertEquals("name1", cookie.getName());
>> >         Assert.assertEquals("value1", cookie.getValue());
>> >         Assert.assertEquals("localhost", cookie.getDomain());
>> >         Assert.assertEquals("/", cookie.getPath());
>> >     }
>> >
>> >     @Test
>> >     public void testParseCookies() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> >         StringBuilder sbHdr = new StringBuilder();
>> >         for (Header header : lstHdr) {
>> >             sbHdr.append(header.getValue());
>> >         }
>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> sbHdr.toString());
>> >     }
>> >     @Test
>> >     public void testParseCookies2() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>> test2=2;secure");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> >         StringBuilder sbHdr = new StringBuilder();
>> >         for (Header header : lstHdr) {
>> >             sbHdr.append(header.getValue());
>> >         }
>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> sbHdr.toString());
>> >     }
>> >
>> >     @Test
>> >     public void testNoCookieOrigin() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(0, cookies.size());
>> >     }
>> >
>> >     @Test
>> >     public void testNoCookieSpec() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(0, cookies.size());
>> >     }
>> >
>> >     @Test
>> >     public void testNoCookieStore() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(0, cookies.size());
>> >     }
>> >
>> >     @Test
>> >     public void testSetCookie2OverrideSetCookie() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(1, cookies.size());
>> >         final Cookie cookie = cookies.get(0);
>> >         Assert.assertEquals(1, cookie.getVersion());
>> >         Assert.assertEquals("name1", cookie.getName());
>> >         Assert.assertEquals("value2", cookie.getValue());
>> >         Assert.assertEquals("localhost.local", cookie.getDomain());
>> >         Assert.assertEquals("/", cookie.getPath());
>> >     }
>> >
>> >     @Test
>> >     public void testInvalidHeader() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertTrue(cookies.isEmpty());
>> >     }
>> >
>> >     @Test
>> >     public void testCookieRejected() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>> > www.somedomain.com; Version=1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertTrue(cookies.isEmpty());
>> >     }
>> >
>> > }
>> >
>> >
>> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>> >
>> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>> > > > Finally, for those  2 I am not sure  as per RFC6265, to use them ,
>> put
>> > > code
>> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
>> > > > They worked with HC3 but it does not mean they should work with
>> HC4, but
>> > > I
>> > > > would like a confirmation:
>> > > >
>> > >
>> > > I cannot get the tests to compile due to missing instance variables
>> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look if
>> you
>> > > post the complete class.
>> > >
>> > > Oleg
>> > >
>> > >
>> > > >
>> > > >     @Test
>> > > >     public void testParseCookies() throws Exception {
>> > > >         final HttpResponse response = new
>> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> > > >
>> > > >         final HttpClientContext context =
>> HttpClientContext.create();
>> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > > > this.cookieOrigin);
>> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > > > this.cookieSpec);
>> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > > > this.cookieStore);
>> > > >
>> > > >         final HttpResponseInterceptor interceptor = new
>> > > > ResponseProcessCookies();
>> > > >         interceptor.process(response, context);
>> > > >
>> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> > > >         StringBuilder sbHdr = new StringBuilder();
>> > > >         for (Header header : lstHdr) {
>> > > >             sbHdr.append(header.getValue());
>> > > >         }
>> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> > > sbHdr.toString());
>> > > >     }
>> > > >     @Test
>> > > >     public void testParseCookies2() throws Exception {
>> > > >         final HttpResponse response = new
>> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>> > > test2=2;secure");
>> > > >
>> > > >         final HttpClientContext context =
>> HttpClientContext.create();
>> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > > > this.cookieOrigin);
>> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > > > this.cookieSpec);
>> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > > > this.cookieStore);
>> > > >
>> > > >         final HttpResponseInterceptor interceptor = new
>> > > > ResponseProcessCookies();
>> > > >         interceptor.process(response, context);
>> > > >
>> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> > > >         StringBuilder sbHdr = new StringBuilder();
>> > > >         for (Header header : lstHdr) {
>> > > >             sbHdr.append(header.getValue());
>> > > >         }
>> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> > > sbHdr.toString());
>> > > >     }
>> > > >
>> > > > Thanks
>> > > >
>> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>> > > > philippe.mouawad@gmail.com> wrote:
>> > > >
>> > > > > Hi,
>> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>> with a
>> > > Test
>> > > > > case in it to show issue with Domain starting with ".".
>> > > > >
>> > > > >
>> > > > > Regards
>> > > > >
>> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>> > > > > philippe.mouawad@gmail.com> wrote:
>> > > > >
>> > > > >> Hi Oleg,
>> > > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>> to show
>> > > > >> issue with Cookie Header ordering.
>> > > > >>
>> > > > >> Regards
>> > > > >>
>> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>> > > > >> philippe.mouawad@gmail.com> wrote:
>> > > > >>
>> > > > >>> Hi,
>> > > > >>>  I created
>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>> > > with
>> > > > >>> JUnit test case so that you understand the difference we have.
>> > > > >>>
>> > > > >>> Regards
>> > > > >>>
>> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>> olegk@apache.org>
>> > > > >>> wrote:
>> > > > >>>
>> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>> > > > >>>> > Thanks Oleg.
>> > > > >>>> > But look at
>> > > > >>>> >
>> > > > >>>>
>> > >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>> > > > >>>> ,
>> > > > >>>> > it concerns IGNORE_POLICY
>> > > > >>>> >
>> > > > >>>> > I really think there is at least one bug.
>> > > > >>>> > Regards
>> > > > >>>> >
>> > > > >>>>
>> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
>> Could
>> > > you
>> > > > >>>> please though reproduce them with unit tests that do not
>> involve
>> > > JMeter
>> > > > >>>> specific code?
>> > > > >>>>
>> > > > >>>> Oleg
>> > > > >>>>
>> > > > >>>>
>> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>> > > olegk@apache.org>
>> > > > >>>> wrote:
>> > > > >>>> >
>> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>> > > > >>>> > > > Hi Oleg,
>> > > > >>>> > > > Thanks for answer.
>> > > > >>>> > > >
>> > > > >>>> > > > Find my answers inline.
>> > > > >>>> > > > Regards
>> > > > >>>> > > >
>> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>> > > > >>>> olegk@apache.org>
>> > > > >>>> > > wrote:
>> > > > >>>> > > >
>> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>> wrote:
>> > > > >>>> > > > > > Hello,
>> > > > >>>> > > > > > Any answer on this question ?
>> > > > >>>> > > > > > Thanks
>> > > > >>>> > > > > > Regards
>> > > > >>>> > > > > >
>> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
>> > > > >>>> > > > > >
>> > > > >>>> > > > > > > Hello,
>> > > > >>>> > > > > > > We're in the process of migrating JMeter to last
>> > > HttpClient
>> > > > >>>> 4.5.1.
>> > > > >>>> > > > > > >
>> > > > >>>> > > > > > > We are now migrating the CookieManager to remove
>> all
>> > > > >>>> deprecated
>> > > > >>>> > > code.
>> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
>> > > > >>>> > > > > > >
>> > > > >>>> > > > > > >
>> > > > >>>> > > > >
>> > > > >>>> > >
>> > > > >>>>
>> > >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>> > > > >>>> > > > > > >
>> > > > >>>> > > > > > > Before migration, it was still testing HC3 version.
>> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
>> > > failures:
>> > > > >>>> > > > > > >
>> > > > >>>> > > > >
>> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>> > > > >>>> > > >
>> > > > >>>> > > >
>> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>> > > > >>>> Implementation
>> > > > >>>> > > of
>> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
>> compared to
>> > > > >>>> HC3.
>> > > > >>>> > > >
>> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>> > > failures
>> > > > >>>> all
>> > > > >>>> > > > detailed in initial mail.
>> > > > >>>> > > >
>> > > > >>>> > > >
>> > > > >>>> > > > What policy does
>> > > > >>>> > > > > CookeManager use internally?
>> > > > >>>> > > > >
>> > > > >>>> > > > It depends on tests, you can see in the code that
>> depending on
>> > > > >>>> test
>> > > > >>>> > > method
>> > > > >>>> > > > we set different Policy to test them.
>> > > > >>>> > > >
>> > > > >>>> > >
>> > > > >>>> > > You ought to be using RFC6265 policy either in strict or
>> relaxed
>> > > > >>>> mode
>> > > > >>>> > > and nothing else. All other policies have been marked as
>> > > obsolete
>> > > > >>>> and
>> > > > >>>> > > have already been removed in 5.0 (trunk).
>> > > > >>>> > >
>> > > > >>>> > > Oleg
>> > > > >>>> > >
>> > > > >>>> > >
>> > > > >>>> > >
>> > > > >>>>
>> > > ---------------------------------------------------------------------
>> > > > >>>> > > To unsubscribe, e-mail:
>> > > httpclient-users-unsubscribe@hc.apache.org
>> > > > >>>> > > For additional commands, e-mail:
>> > > > >>>> httpclient-users-help@hc.apache.org
>> > > > >>>> > >
>> > > > >>>> > >
>> > > > >>>> >
>> > > > >>>> >
>> > > > >>>>
>> > > > >>>>
>> > > > >>>>
>> > > > >>>>
>> > > ---------------------------------------------------------------------
>> > > > >>>> To unsubscribe, e-mail:
>> httpclient-users-unsubscribe@hc.apache.org
>> > > > >>>> For additional commands, e-mail:
>> > > httpclient-users-help@hc.apache.org
>> > > > >>>>
>> > > > >>>>
>> > > > >>>
>> > > > >>>
>> > > > >>> --
>> > > > >>> Cordialement.
>> > > > >>> Philippe Mouawad.
>> > > > >>>
>> > > > >>>
>> > > > >>>
>> > > > >>
>> > > > >>
>> > > > >> --
>> > > > >> Cordialement.
>> > > > >> Philippe Mouawad.
>> > > > >>
>> > > > >>
>> > > > >>
>> > > > >
>> > > > >
>> > > > > --
>> > > > > Cordialement.
>> > > > > Philippe Mouawad.
>> > > > >
>> > > > >
>> > > > >
>> > > >
>> > > >
>> > >
>> > >
>> > >
>> >
>> >
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi ,
One last question, when is release of 4.5.2 expected as it fixes 2 bugs we
are facing in JMeter.

Thanks
Regards

On Tue, Dec 15, 2015 at 2:05 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

>
>
> On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
>> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
>> > Hello Oleg,
>> > Thanks .
>> >
>>
>> Test case #testParseCookies
>>
>> The rest case does not look right to me. I am not sure I understand what
>> you are trying to test here.
>>
> Indeed, bad copy paste.
>
> The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on
> JMeter side.
>
>>
>> Test case #testParseCookies
>>
>>
>
>> The cookie in question does not have a version attribute mandatory for
>> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
>> Netscape style cookie in which case comma is not considered a valid
>> header element delimiter and is treated as normal character.
>>
>
> Thanks for explanation.
> Note that test case worked fine in HC3. Was it a bug in HC3 ?
>
>
>>
>> Oleg
>>
>>
>> > Here it is:
>> >
>> > /*
>> >  * ====================================================================
>> >  * 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
>> >  * "License"); 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
>> >  * "AS IS" 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.
>> >  * ====================================================================
>> >  *
>> >  * This software consists of voluntary contributions made by many
>> >  * individuals on behalf of the Apache Software Foundation.  For more
>> >  * information on the Apache Software Foundation, please see
>> >  * <http://www.apache.org/>.
>> >  *
>> >  */
>> > package org.apache.http.client.protocol;
>> >
>> > import java.util.List;
>> >
>> > import org.apache.http.Header;
>> > import org.apache.http.HttpResponse;
>> > import org.apache.http.HttpResponseInterceptor;
>> > import org.apache.http.HttpVersion;
>> > import org.apache.http.client.CookieStore;
>> > import org.apache.http.cookie.Cookie;
>> > import org.apache.http.cookie.CookieOrigin;
>> > import org.apache.http.cookie.CookieSpec;
>> > import org.apache.http.cookie.SM;
>> > import org.apache.http.impl.client.BasicCookieStore;
>> > import org.apache.http.impl.cookie.DefaultCookieSpec;
>> > import org.apache.http.message.BasicHttpResponse;
>> > import org.apache.http.util.Asserts;
>> > import org.junit.Assert;
>> > import org.junit.Before;
>> > import org.junit.Test;
>> >
>> > public class TestResponseProcessCookies {
>> >
>> >     private CookieOrigin cookieOrigin;
>> >     private CookieSpec cookieSpec;
>> >     private CookieStore cookieStore;
>> >
>> >     @Before
>> >     public void setUp() throws Exception {
>> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
>> false);
>> >         this.cookieSpec = new DefaultCookieSpec();
>> >         this.cookieStore = new BasicCookieStore();
>> >     }
>> >
>> >     @Test(expected=IllegalArgumentException.class)
>> >     public void testResponseParameterCheck() throws Exception {
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(null, context);
>> >     }
>> >
>> >     @Test(expected=IllegalArgumentException.class)
>> >     public void testContextParameterCheck() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, null);
>> >     }
>> >
>> >     @Test
>> >     public void testParseMultipleCookies() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
>> > test2=2; version=1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(1, cookies.size());
>> >         final Cookie cookie = cookies.get(0);
>> >         Assert.assertEquals(0, cookie.getVersion());
>> >         Assert.assertEquals("name1", cookie.getName());
>> >         Assert.assertEquals("value1", cookie.getValue());
>> >         Assert.assertEquals("localhost", cookie.getDomain());
>> >         Assert.assertEquals("/", cookie.getPath());
>> >     }
>> >
>> >     @Test
>> >     public void testParseCookies() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> >         StringBuilder sbHdr = new StringBuilder();
>> >         for (Header header : lstHdr) {
>> >             sbHdr.append(header.getValue());
>> >         }
>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> sbHdr.toString());
>> >     }
>> >     @Test
>> >     public void testParseCookies2() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>> test2=2;secure");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> >         StringBuilder sbHdr = new StringBuilder();
>> >         for (Header header : lstHdr) {
>> >             sbHdr.append(header.getValue());
>> >         }
>> >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> sbHdr.toString());
>> >     }
>> >
>> >     @Test
>> >     public void testNoCookieOrigin() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(0, cookies.size());
>> >     }
>> >
>> >     @Test
>> >     public void testNoCookieSpec() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(0, cookies.size());
>> >     }
>> >
>> >     @Test
>> >     public void testNoCookieStore() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(0, cookies.size());
>> >     }
>> >
>> >     @Test
>> >     public void testSetCookie2OverrideSetCookie() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> >         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertEquals(1, cookies.size());
>> >         final Cookie cookie = cookies.get(0);
>> >         Assert.assertEquals(1, cookie.getVersion());
>> >         Assert.assertEquals("name1", cookie.getName());
>> >         Assert.assertEquals("value2", cookie.getValue());
>> >         Assert.assertEquals("localhost.local", cookie.getDomain());
>> >         Assert.assertEquals("/", cookie.getPath());
>> >     }
>> >
>> >     @Test
>> >     public void testInvalidHeader() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertTrue(cookies.isEmpty());
>> >     }
>> >
>> >     @Test
>> >     public void testCookieRejected() throws Exception {
>> >         final HttpResponse response = new
>> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
>> > www.somedomain.com; Version=1");
>> >
>> >         final HttpClientContext context = HttpClientContext.create();
>> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > this.cookieOrigin);
>> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > this.cookieSpec);
>> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > this.cookieStore);
>> >
>> >         final HttpResponseInterceptor interceptor = new
>> > ResponseProcessCookies();
>> >         interceptor.process(response, context);
>> >
>> >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> >         Assert.assertNotNull(cookies);
>> >         Assert.assertTrue(cookies.isEmpty());
>> >     }
>> >
>> > }
>> >
>> >
>> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>> >
>> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
>> > > > Finally, for those  2 I am not sure  as per RFC6265, to use them ,
>> put
>> > > code
>> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
>> > > > They worked with HC3 but it does not mean they should work with
>> HC4, but
>> > > I
>> > > > would like a confirmation:
>> > > >
>> > >
>> > > I cannot get the tests to compile due to missing instance variables
>> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look if
>> you
>> > > post the complete class.
>> > >
>> > > Oleg
>> > >
>> > >
>> > > >
>> > > >     @Test
>> > > >     public void testParseCookies() throws Exception {
>> > > >         final HttpResponse response = new
>> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
>> > > >
>> > > >         final HttpClientContext context =
>> HttpClientContext.create();
>> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > > > this.cookieOrigin);
>> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > > > this.cookieSpec);
>> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > > > this.cookieStore);
>> > > >
>> > > >         final HttpResponseInterceptor interceptor = new
>> > > > ResponseProcessCookies();
>> > > >         interceptor.process(response, context);
>> > > >
>> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> > > >         StringBuilder sbHdr = new StringBuilder();
>> > > >         for (Header header : lstHdr) {
>> > > >             sbHdr.append(header.getValue());
>> > > >         }
>> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> > > sbHdr.toString());
>> > > >     }
>> > > >     @Test
>> > > >     public void testParseCookies2() throws Exception {
>> > > >         final HttpResponse response = new
>> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
>> > > test2=2;secure");
>> > > >
>> > > >         final HttpClientContext context =
>> HttpClientContext.create();
>> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
>> > > > this.cookieOrigin);
>> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
>> > > > this.cookieSpec);
>> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
>> > > > this.cookieStore);
>> > > >
>> > > >         final HttpResponseInterceptor interceptor = new
>> > > > ResponseProcessCookies();
>> > > >         interceptor.process(response, context);
>> > > >
>> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
>> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>> > > >         StringBuilder sbHdr = new StringBuilder();
>> > > >         for (Header header : lstHdr) {
>> > > >             sbHdr.append(header.getValue());
>> > > >         }
>> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
>> > > sbHdr.toString());
>> > > >     }
>> > > >
>> > > > Thanks
>> > > >
>> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
>> > > > philippe.mouawad@gmail.com> wrote:
>> > > >
>> > > > > Hi,
>> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>> with a
>> > > Test
>> > > > > case in it to show issue with Domain starting with ".".
>> > > > >
>> > > > >
>> > > > > Regards
>> > > > >
>> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
>> > > > > philippe.mouawad@gmail.com> wrote:
>> > > > >
>> > > > >> Hi Oleg,
>> > > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
>> to show
>> > > > >> issue with Cookie Header ordering.
>> > > > >>
>> > > > >> Regards
>> > > > >>
>> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>> > > > >> philippe.mouawad@gmail.com> wrote:
>> > > > >>
>> > > > >>> Hi,
>> > > > >>>  I created
>> https://issues.apache.org/jira/browse/HTTPCLIENT-1704
>> > > with
>> > > > >>> JUnit test case so that you understand the difference we have.
>> > > > >>>
>> > > > >>> Regards
>> > > > >>>
>> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
>> olegk@apache.org>
>> > > > >>> wrote:
>> > > > >>>
>> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>> > > > >>>> > Thanks Oleg.
>> > > > >>>> > But look at
>> > > > >>>> >
>> > > > >>>>
>> > >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>> > > > >>>> ,
>> > > > >>>> > it concerns IGNORE_POLICY
>> > > > >>>> >
>> > > > >>>> > I really think there is at least one bug.
>> > > > >>>> > Regards
>> > > > >>>> >
>> > > > >>>>
>> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
>> Could
>> > > you
>> > > > >>>> please though reproduce them with unit tests that do not
>> involve
>> > > JMeter
>> > > > >>>> specific code?
>> > > > >>>>
>> > > > >>>> Oleg
>> > > > >>>>
>> > > > >>>>
>> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
>> > > olegk@apache.org>
>> > > > >>>> wrote:
>> > > > >>>> >
>> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>> > > > >>>> > > > Hi Oleg,
>> > > > >>>> > > > Thanks for answer.
>> > > > >>>> > > >
>> > > > >>>> > > > Find my answers inline.
>> > > > >>>> > > > Regards
>> > > > >>>> > > >
>> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>> > > > >>>> olegk@apache.org>
>> > > > >>>> > > wrote:
>> > > > >>>> > > >
>> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
>> wrote:
>> > > > >>>> > > > > > Hello,
>> > > > >>>> > > > > > Any answer on this question ?
>> > > > >>>> > > > > > Thanks
>> > > > >>>> > > > > > Regards
>> > > > >>>> > > > > >
>> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
>> > > > >>>> > > > > >
>> > > > >>>> > > > > > > Hello,
>> > > > >>>> > > > > > > We're in the process of migrating JMeter to last
>> > > HttpClient
>> > > > >>>> 4.5.1.
>> > > > >>>> > > > > > >
>> > > > >>>> > > > > > > We are now migrating the CookieManager to remove
>> all
>> > > > >>>> deprecated
>> > > > >>>> > > code.
>> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
>> > > > >>>> > > > > > >
>> > > > >>>> > > > > > >
>> > > > >>>> > > > >
>> > > > >>>> > >
>> > > > >>>>
>> > >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>> > > > >>>> > > > > > >
>> > > > >>>> > > > > > > Before migration, it was still testing HC3 version.
>> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
>> > > failures:
>> > > > >>>> > > > > > >
>> > > > >>>> > > > >
>> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>> > > > >>>> > > >
>> > > > >>>> > > >
>> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>> > > > >>>> Implementation
>> > > > >>>> > > of
>> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
>> compared to
>> > > > >>>> HC3.
>> > > > >>>> > > >
>> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
>> > > failures
>> > > > >>>> all
>> > > > >>>> > > > detailed in initial mail.
>> > > > >>>> > > >
>> > > > >>>> > > >
>> > > > >>>> > > > What policy does
>> > > > >>>> > > > > CookeManager use internally?
>> > > > >>>> > > > >
>> > > > >>>> > > > It depends on tests, you can see in the code that
>> depending on
>> > > > >>>> test
>> > > > >>>> > > method
>> > > > >>>> > > > we set different Policy to test them.
>> > > > >>>> > > >
>> > > > >>>> > >
>> > > > >>>> > > You ought to be using RFC6265 policy either in strict or
>> relaxed
>> > > > >>>> mode
>> > > > >>>> > > and nothing else. All other policies have been marked as
>> > > obsolete
>> > > > >>>> and
>> > > > >>>> > > have already been removed in 5.0 (trunk).
>> > > > >>>> > >
>> > > > >>>> > > Oleg
>> > > > >>>> > >
>> > > > >>>> > >
>> > > > >>>> > >
>> > > > >>>>
>> > > ---------------------------------------------------------------------
>> > > > >>>> > > To unsubscribe, e-mail:
>> > > httpclient-users-unsubscribe@hc.apache.org
>> > > > >>>> > > For additional commands, e-mail:
>> > > > >>>> httpclient-users-help@hc.apache.org
>> > > > >>>> > >
>> > > > >>>> > >
>> > > > >>>> >
>> > > > >>>> >
>> > > > >>>>
>> > > > >>>>
>> > > > >>>>
>> > > > >>>>
>> > > ---------------------------------------------------------------------
>> > > > >>>> To unsubscribe, e-mail:
>> httpclient-users-unsubscribe@hc.apache.org
>> > > > >>>> For additional commands, e-mail:
>> > > httpclient-users-help@hc.apache.org
>> > > > >>>>
>> > > > >>>>
>> > > > >>>
>> > > > >>>
>> > > > >>> --
>> > > > >>> Cordialement.
>> > > > >>> Philippe Mouawad.
>> > > > >>>
>> > > > >>>
>> > > > >>>
>> > > > >>
>> > > > >>
>> > > > >> --
>> > > > >> Cordialement.
>> > > > >> Philippe Mouawad.
>> > > > >>
>> > > > >>
>> > > > >>
>> > > > >
>> > > > >
>> > > > > --
>> > > > > Cordialement.
>> > > > > Philippe Mouawad.
>> > > > >
>> > > > >
>> > > > >
>> > > >
>> > > >
>> > >
>> > >
>> > >
>> >
>> >
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> > Hello Oleg,
> > Thanks .
> >
>
> Test case #testParseCookies
>
> The rest case does not look right to me. I am not sure I understand what
> you are trying to test here.
>
Indeed, bad copy paste.

The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on JMeter
side.

>
> Test case #testParseCookies
>
>

> The cookie in question does not have a version attribute mandatory for
> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> Netscape style cookie in which case comma is not considered a valid
> header element delimiter and is treated as normal character.
>

Thanks for explanation.
Note that test case worked fine in HC3. Was it a bug in HC3 ?


>
> Oleg
>
>
> > Here it is:
> >
> > /*
> >  * ====================================================================
> >  * 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
> >  * "License"); 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
> >  * "AS IS" 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.
> >  * ====================================================================
> >  *
> >  * This software consists of voluntary contributions made by many
> >  * individuals on behalf of the Apache Software Foundation.  For more
> >  * information on the Apache Software Foundation, please see
> >  * <http://www.apache.org/>.
> >  *
> >  */
> > package org.apache.http.client.protocol;
> >
> > import java.util.List;
> >
> > import org.apache.http.Header;
> > import org.apache.http.HttpResponse;
> > import org.apache.http.HttpResponseInterceptor;
> > import org.apache.http.HttpVersion;
> > import org.apache.http.client.CookieStore;
> > import org.apache.http.cookie.Cookie;
> > import org.apache.http.cookie.CookieOrigin;
> > import org.apache.http.cookie.CookieSpec;
> > import org.apache.http.cookie.SM;
> > import org.apache.http.impl.client.BasicCookieStore;
> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> > import org.apache.http.message.BasicHttpResponse;
> > import org.apache.http.util.Asserts;
> > import org.junit.Assert;
> > import org.junit.Before;
> > import org.junit.Test;
> >
> > public class TestResponseProcessCookies {
> >
> >     private CookieOrigin cookieOrigin;
> >     private CookieSpec cookieSpec;
> >     private CookieStore cookieStore;
> >
> >     @Before
> >     public void setUp() throws Exception {
> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> false);
> >         this.cookieSpec = new DefaultCookieSpec();
> >         this.cookieStore = new BasicCookieStore();
> >     }
> >
> >     @Test(expected=IllegalArgumentException.class)
> >     public void testResponseParameterCheck() throws Exception {
> >         final HttpClientContext context = HttpClientContext.create();
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(null, context);
> >     }
> >
> >     @Test(expected=IllegalArgumentException.class)
> >     public void testContextParameterCheck() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, null);
> >     }
> >
> >     @Test
> >     public void testParseMultipleCookies() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
> > test2=2; version=1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(1, cookies.size());
> >         final Cookie cookie = cookies.get(0);
> >         Assert.assertEquals(0, cookie.getVersion());
> >         Assert.assertEquals("name1", cookie.getName());
> >         Assert.assertEquals("value1", cookie.getValue());
> >         Assert.assertEquals("localhost", cookie.getDomain());
> >         Assert.assertEquals("/", cookie.getPath());
> >     }
> >
> >     @Test
> >     public void testParseCookies() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >         StringBuilder sbHdr = new StringBuilder();
> >         for (Header header : lstHdr) {
> >             sbHdr.append(header.getValue());
> >         }
> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
> >     }
> >     @Test
> >     public void testParseCookies2() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> test2=2;secure");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >         StringBuilder sbHdr = new StringBuilder();
> >         for (Header header : lstHdr) {
> >             sbHdr.append(header.getValue());
> >         }
> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
> >     }
> >
> >     @Test
> >     public void testNoCookieOrigin() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(0, cookies.size());
> >     }
> >
> >     @Test
> >     public void testNoCookieSpec() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(0, cookies.size());
> >     }
> >
> >     @Test
> >     public void testNoCookieStore() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(0, cookies.size());
> >     }
> >
> >     @Test
> >     public void testSetCookie2OverrideSetCookie() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(1, cookies.size());
> >         final Cookie cookie = cookies.get(0);
> >         Assert.assertEquals(1, cookie.getVersion());
> >         Assert.assertEquals("name1", cookie.getName());
> >         Assert.assertEquals("value2", cookie.getValue());
> >         Assert.assertEquals("localhost.local", cookie.getDomain());
> >         Assert.assertEquals("/", cookie.getPath());
> >     }
> >
> >     @Test
> >     public void testInvalidHeader() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertTrue(cookies.isEmpty());
> >     }
> >
> >     @Test
> >     public void testCookieRejected() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> > www.somedomain.com; Version=1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertTrue(cookies.isEmpty());
> >     }
> >
> > }
> >
> >
> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > > > Finally, for those  2 I am not sure  as per RFC6265, to use them ,
> put
> > > code
> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > > > They worked with HC3 but it does not mean they should work with HC4,
> but
> > > I
> > > > would like a confirmation:
> > > >
> > >
> > > I cannot get the tests to compile due to missing instance variables
> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
> > > post the complete class.
> > >
> > > Oleg
> > >
> > >
> > > >
> > > >     @Test
> > > >     public void testParseCookies() throws Exception {
> > > >         final HttpResponse response = new
> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >
> > > >         final HttpClientContext context = HttpClientContext.create();
> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > this.cookieOrigin);
> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > this.cookieSpec);
> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > this.cookieStore);
> > > >
> > > >         final HttpResponseInterceptor interceptor = new
> > > > ResponseProcessCookies();
> > > >         interceptor.process(response, context);
> > > >
> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >         StringBuilder sbHdr = new StringBuilder();
> > > >         for (Header header : lstHdr) {
> > > >             sbHdr.append(header.getValue());
> > > >         }
> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > sbHdr.toString());
> > > >     }
> > > >     @Test
> > > >     public void testParseCookies2() throws Exception {
> > > >         final HttpResponse response = new
> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > test2=2;secure");
> > > >
> > > >         final HttpClientContext context = HttpClientContext.create();
> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > this.cookieOrigin);
> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > this.cookieSpec);
> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > this.cookieStore);
> > > >
> > > >         final HttpResponseInterceptor interceptor = new
> > > > ResponseProcessCookies();
> > > >         interceptor.process(response, context);
> > > >
> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >         StringBuilder sbHdr = new StringBuilder();
> > > >         for (Header header : lstHdr) {
> > > >             sbHdr.append(header.getValue());
> > > >         }
> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > sbHdr.toString());
> > > >     }
> > > >
> > > > Thanks
> > > >
> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > > > philippe.mouawad@gmail.com> wrote:
> > > >
> > > > > Hi,
> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> with a
> > > Test
> > > > > case in it to show issue with Domain starting with ".".
> > > > >
> > > > >
> > > > > Regards
> > > > >
> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > > > philippe.mouawad@gmail.com> wrote:
> > > > >
> > > > >> Hi Oleg,
> > > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to
> show
> > > > >> issue with Cookie Header ordering.
> > > > >>
> > > > >> Regards
> > > > >>
> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > > > >> philippe.mouawad@gmail.com> wrote:
> > > > >>
> > > > >>> Hi,
> > > > >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > > with
> > > > >>> JUnit test case so that you understand the difference we have.
> > > > >>>
> > > > >>> Regards
> > > > >>>
> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> olegk@apache.org>
> > > > >>> wrote:
> > > > >>>
> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > > > >>>> > Thanks Oleg.
> > > > >>>> > But look at
> > > > >>>> >
> > > > >>>>
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > > > >>>> ,
> > > > >>>> > it concerns IGNORE_POLICY
> > > > >>>> >
> > > > >>>> > I really think there is at least one bug.
> > > > >>>> > Regards
> > > > >>>> >
> > > > >>>>
> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
> Could
> > > you
> > > > >>>> please though reproduce them with unit tests that do not involve
> > > JMeter
> > > > >>>> specific code?
> > > > >>>>
> > > > >>>> Oleg
> > > > >>>>
> > > > >>>>
> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > > olegk@apache.org>
> > > > >>>> wrote:
> > > > >>>> >
> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > > > >>>> > > > Hi Oleg,
> > > > >>>> > > > Thanks for answer.
> > > > >>>> > > >
> > > > >>>> > > > Find my answers inline.
> > > > >>>> > > > Regards
> > > > >>>> > > >
> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > > > >>>> olegk@apache.org>
> > > > >>>> > > wrote:
> > > > >>>> > > >
> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> wrote:
> > > > >>>> > > > > > Hello,
> > > > >>>> > > > > > Any answer on this question ?
> > > > >>>> > > > > > Thanks
> > > > >>>> > > > > > Regards
> > > > >>>> > > > > >
> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > > > >>>> > > > > >
> > > > >>>> > > > > > > Hello,
> > > > >>>> > > > > > > We're in the process of migrating JMeter to last
> > > HttpClient
> > > > >>>> 4.5.1.
> > > > >>>> > > > > > >
> > > > >>>> > > > > > > We are now migrating the CookieManager to remove all
> > > > >>>> deprecated
> > > > >>>> > > code.
> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > > > >>>> > > > > > >
> > > > >>>> > > > > > >
> > > > >>>> > > > >
> > > > >>>> > >
> > > > >>>>
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > > >>>> > > > > > >
> > > > >>>> > > > > > > Before migration, it was still testing HC3 version.
> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> > > failures:
> > > > >>>> > > > > > >
> > > > >>>> > > > >
> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > > > >>>> > > >
> > > > >>>> > > >
> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> > > > >>>> Implementation
> > > > >>>> > > of
> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
> compared to
> > > > >>>> HC3.
> > > > >>>> > > >
> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> > > failures
> > > > >>>> all
> > > > >>>> > > > detailed in initial mail.
> > > > >>>> > > >
> > > > >>>> > > >
> > > > >>>> > > > What policy does
> > > > >>>> > > > > CookeManager use internally?
> > > > >>>> > > > >
> > > > >>>> > > > It depends on tests, you can see in the code that
> depending on
> > > > >>>> test
> > > > >>>> > > method
> > > > >>>> > > > we set different Policy to test them.
> > > > >>>> > > >
> > > > >>>> > >
> > > > >>>> > > You ought to be using RFC6265 policy either in strict or
> relaxed
> > > > >>>> mode
> > > > >>>> > > and nothing else. All other policies have been marked as
> > > obsolete
> > > > >>>> and
> > > > >>>> > > have already been removed in 5.0 (trunk).
> > > > >>>> > >
> > > > >>>> > > Oleg
> > > > >>>> > >
> > > > >>>> > >
> > > > >>>> > >
> > > > >>>>
> > > ---------------------------------------------------------------------
> > > > >>>> > > To unsubscribe, e-mail:
> > > httpclient-users-unsubscribe@hc.apache.org
> > > > >>>> > > For additional commands, e-mail:
> > > > >>>> httpclient-users-help@hc.apache.org
> > > > >>>> > >
> > > > >>>> > >
> > > > >>>> >
> > > > >>>> >
> > > > >>>>
> > > > >>>>
> > > > >>>>
> > > > >>>>
> > > ---------------------------------------------------------------------
> > > > >>>> To unsubscribe, e-mail:
> httpclient-users-unsubscribe@hc.apache.org
> > > > >>>> For additional commands, e-mail:
> > > httpclient-users-help@hc.apache.org
> > > > >>>>
> > > > >>>>
> > > > >>>
> > > > >>>
> > > > >>> --
> > > > >>> Cordialement.
> > > > >>> Philippe Mouawad.
> > > > >>>
> > > > >>>
> > > > >>>
> > > > >>
> > > > >>
> > > > >> --
> > > > >> Cordialement.
> > > > >> Philippe Mouawad.
> > > > >>
> > > > >>
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > Cordialement.
> > > > > Philippe Mouawad.
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
On Tue, Dec 15, 2015 at 9:36 AM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> > Hello Oleg,
> > Thanks .
> >
>
> Test case #testParseCookies
>
> The rest case does not look right to me. I am not sure I understand what
> you are trying to test here.
>
Indeed, bad copy paste.

The test fixed below works fine with HTTPCLIENT 4.5.1 so issue is on JMeter
side.

>
> Test case #testParseCookies
>
>

> The cookie in question does not have a version attribute mandatory for
> standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
> Netscape style cookie in which case comma is not considered a valid
> header element delimiter and is treated as normal character.
>

Thanks for explanation.
Note that test case worked fine in HC3. Was it a bug in HC3 ?


>
> Oleg
>
>
> > Here it is:
> >
> > /*
> >  * ====================================================================
> >  * 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
> >  * "License"); 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
> >  * "AS IS" 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.
> >  * ====================================================================
> >  *
> >  * This software consists of voluntary contributions made by many
> >  * individuals on behalf of the Apache Software Foundation.  For more
> >  * information on the Apache Software Foundation, please see
> >  * <http://www.apache.org/>.
> >  *
> >  */
> > package org.apache.http.client.protocol;
> >
> > import java.util.List;
> >
> > import org.apache.http.Header;
> > import org.apache.http.HttpResponse;
> > import org.apache.http.HttpResponseInterceptor;
> > import org.apache.http.HttpVersion;
> > import org.apache.http.client.CookieStore;
> > import org.apache.http.cookie.Cookie;
> > import org.apache.http.cookie.CookieOrigin;
> > import org.apache.http.cookie.CookieSpec;
> > import org.apache.http.cookie.SM;
> > import org.apache.http.impl.client.BasicCookieStore;
> > import org.apache.http.impl.cookie.DefaultCookieSpec;
> > import org.apache.http.message.BasicHttpResponse;
> > import org.apache.http.util.Asserts;
> > import org.junit.Assert;
> > import org.junit.Before;
> > import org.junit.Test;
> >
> > public class TestResponseProcessCookies {
> >
> >     private CookieOrigin cookieOrigin;
> >     private CookieSpec cookieSpec;
> >     private CookieStore cookieStore;
> >
> >     @Before
> >     public void setUp() throws Exception {
> >         this.cookieOrigin = new CookieOrigin("localhost", 80, "/",
> false);
> >         this.cookieSpec = new DefaultCookieSpec();
> >         this.cookieStore = new BasicCookieStore();
> >     }
> >
> >     @Test(expected=IllegalArgumentException.class)
> >     public void testResponseParameterCheck() throws Exception {
> >         final HttpClientContext context = HttpClientContext.create();
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(null, context);
> >     }
> >
> >     @Test(expected=IllegalArgumentException.class)
> >     public void testContextParameterCheck() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, null);
> >     }
> >
> >     @Test
> >     public void testParseMultipleCookies() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
> > test2=2; version=1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(1, cookies.size());
> >         final Cookie cookie = cookies.get(0);
> >         Assert.assertEquals(0, cookie.getVersion());
> >         Assert.assertEquals("name1", cookie.getName());
> >         Assert.assertEquals("value1", cookie.getValue());
> >         Assert.assertEquals("localhost", cookie.getDomain());
> >         Assert.assertEquals("/", cookie.getPath());
> >     }
> >
> >     @Test
> >     public void testParseCookies() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >         StringBuilder sbHdr = new StringBuilder();
> >         for (Header header : lstHdr) {
> >             sbHdr.append(header.getValue());
> >         }
> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
> >     }
> >     @Test
> >     public void testParseCookies2() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> test2=2;secure");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >         StringBuilder sbHdr = new StringBuilder();
> >         for (Header header : lstHdr) {
> >             sbHdr.append(header.getValue());
> >         }
> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
> >     }
> >
> >     @Test
> >     public void testNoCookieOrigin() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(0, cookies.size());
> >     }
> >
> >     @Test
> >     public void testNoCookieSpec() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(0, cookies.size());
> >     }
> >
> >     @Test
> >     public void testNoCookieStore() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(0, cookies.size());
> >     }
> >
> >     @Test
> >     public void testSetCookie2OverrideSetCookie() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertEquals(1, cookies.size());
> >         final Cookie cookie = cookies.get(0);
> >         Assert.assertEquals(1, cookie.getVersion());
> >         Assert.assertEquals("name1", cookie.getName());
> >         Assert.assertEquals("value2", cookie.getValue());
> >         Assert.assertEquals("localhost.local", cookie.getDomain());
> >         Assert.assertEquals("/", cookie.getPath());
> >     }
> >
> >     @Test
> >     public void testInvalidHeader() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertTrue(cookies.isEmpty());
> >     }
> >
> >     @Test
> >     public void testCookieRejected() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> > www.somedomain.com; Version=1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         Assert.assertNotNull(cookies);
> >         Assert.assertTrue(cookies.isEmpty());
> >     }
> >
> > }
> >
> >
> > On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > > > Finally, for those  2 I am not sure  as per RFC6265, to use them ,
> put
> > > code
> > > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > > > They worked with HC3 but it does not mean they should work with HC4,
> but
> > > I
> > > > would like a confirmation:
> > > >
> > >
> > > I cannot get the tests to compile due to missing instance variables
> > > cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
> > > post the complete class.
> > >
> > > Oleg
> > >
> > >
> > > >
> > > >     @Test
> > > >     public void testParseCookies() throws Exception {
> > > >         final HttpResponse response = new
> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > > >
> > > >         final HttpClientContext context = HttpClientContext.create();
> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > this.cookieOrigin);
> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > this.cookieSpec);
> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > this.cookieStore);
> > > >
> > > >         final HttpResponseInterceptor interceptor = new
> > > > ResponseProcessCookies();
> > > >         interceptor.process(response, context);
> > > >
> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >         StringBuilder sbHdr = new StringBuilder();
> > > >         for (Header header : lstHdr) {
> > > >             sbHdr.append(header.getValue());
> > > >         }
> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > sbHdr.toString());
> > > >     }
> > > >     @Test
> > > >     public void testParseCookies2() throws Exception {
> > > >         final HttpResponse response = new
> > > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > > test2=2;secure");
> > > >
> > > >         final HttpClientContext context = HttpClientContext.create();
> > > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > > this.cookieOrigin);
> > > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > > this.cookieSpec);
> > > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > > this.cookieStore);
> > > >
> > > >         final HttpResponseInterceptor interceptor = new
> > > > ResponseProcessCookies();
> > > >         interceptor.process(response, context);
> > > >
> > > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > > >         StringBuilder sbHdr = new StringBuilder();
> > > >         for (Header header : lstHdr) {
> > > >             sbHdr.append(header.getValue());
> > > >         }
> > > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > > sbHdr.toString());
> > > >     }
> > > >
> > > > Thanks
> > > >
> > > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > > > philippe.mouawad@gmail.com> wrote:
> > > >
> > > > > Hi,
> > > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705
> with a
> > > Test
> > > > > case in it to show issue with Domain starting with ".".
> > > > >
> > > > >
> > > > > Regards
> > > > >
> > > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > > > philippe.mouawad@gmail.com> wrote:
> > > > >
> > > > >> Hi Oleg,
> > > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to
> show
> > > > >> issue with Cookie Header ordering.
> > > > >>
> > > > >> Regards
> > > > >>
> > > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > > > >> philippe.mouawad@gmail.com> wrote:
> > > > >>
> > > > >>> Hi,
> > > > >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > > with
> > > > >>> JUnit test case so that you understand the difference we have.
> > > > >>>
> > > > >>> Regards
> > > > >>>
> > > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <
> olegk@apache.org>
> > > > >>> wrote:
> > > > >>>
> > > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > > > >>>> > Thanks Oleg.
> > > > >>>> > But look at
> > > > >>>> >
> > > > >>>>
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > > > >>>> ,
> > > > >>>> > it concerns IGNORE_POLICY
> > > > >>>> >
> > > > >>>> > I really think there is at least one bug.
> > > > >>>> > Regards
> > > > >>>> >
> > > > >>>>
> > > > >>>> Sure thing. All these issues may well be due to bugs in HC.
> Could
> > > you
> > > > >>>> please though reproduce them with unit tests that do not involve
> > > JMeter
> > > > >>>> specific code?
> > > > >>>>
> > > > >>>> Oleg
> > > > >>>>
> > > > >>>>
> > > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > > olegk@apache.org>
> > > > >>>> wrote:
> > > > >>>> >
> > > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > > > >>>> > > > Hi Oleg,
> > > > >>>> > > > Thanks for answer.
> > > > >>>> > > >
> > > > >>>> > > > Find my answers inline.
> > > > >>>> > > > Regards
> > > > >>>> > > >
> > > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > > > >>>> olegk@apache.org>
> > > > >>>> > > wrote:
> > > > >>>> > > >
> > > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad
> wrote:
> > > > >>>> > > > > > Hello,
> > > > >>>> > > > > > Any answer on this question ?
> > > > >>>> > > > > > Thanks
> > > > >>>> > > > > > Regards
> > > > >>>> > > > > >
> > > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > > > >>>> > > > > >
> > > > >>>> > > > > > > Hello,
> > > > >>>> > > > > > > We're in the process of migrating JMeter to last
> > > HttpClient
> > > > >>>> 4.5.1.
> > > > >>>> > > > > > >
> > > > >>>> > > > > > > We are now migrating the CookieManager to remove all
> > > > >>>> deprecated
> > > > >>>> > > code.
> > > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > > > >>>> > > > > > >
> > > > >>>> > > > > > >
> > > > >>>> > > > >
> > > > >>>> > >
> > > > >>>>
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > > >>>> > > > > > >
> > > > >>>> > > > > > > Before migration, it was still testing HC3 version.
> > > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> > > failures:
> > > > >>>> > > > > > >
> > > > >>>> > > > >
> > > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > > > >>>> > > >
> > > > >>>> > > >
> > > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> > > > >>>> Implementation
> > > > >>>> > > of
> > > > >>>> > > > CookieHandler and used 4.2.3, we got some failures
> compared to
> > > > >>>> HC3.
> > > > >>>> > > >
> > > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> > > failures
> > > > >>>> all
> > > > >>>> > > > detailed in initial mail.
> > > > >>>> > > >
> > > > >>>> > > >
> > > > >>>> > > > What policy does
> > > > >>>> > > > > CookeManager use internally?
> > > > >>>> > > > >
> > > > >>>> > > > It depends on tests, you can see in the code that
> depending on
> > > > >>>> test
> > > > >>>> > > method
> > > > >>>> > > > we set different Policy to test them.
> > > > >>>> > > >
> > > > >>>> > >
> > > > >>>> > > You ought to be using RFC6265 policy either in strict or
> relaxed
> > > > >>>> mode
> > > > >>>> > > and nothing else. All other policies have been marked as
> > > obsolete
> > > > >>>> and
> > > > >>>> > > have already been removed in 5.0 (trunk).
> > > > >>>> > >
> > > > >>>> > > Oleg
> > > > >>>> > >
> > > > >>>> > >
> > > > >>>> > >
> > > > >>>>
> > > ---------------------------------------------------------------------
> > > > >>>> > > To unsubscribe, e-mail:
> > > httpclient-users-unsubscribe@hc.apache.org
> > > > >>>> > > For additional commands, e-mail:
> > > > >>>> httpclient-users-help@hc.apache.org
> > > > >>>> > >
> > > > >>>> > >
> > > > >>>> >
> > > > >>>> >
> > > > >>>>
> > > > >>>>
> > > > >>>>
> > > > >>>>
> > > ---------------------------------------------------------------------
> > > > >>>> To unsubscribe, e-mail:
> httpclient-users-unsubscribe@hc.apache.org
> > > > >>>> For additional commands, e-mail:
> > > httpclient-users-help@hc.apache.org
> > > > >>>>
> > > > >>>>
> > > > >>>
> > > > >>>
> > > > >>> --
> > > > >>> Cordialement.
> > > > >>> Philippe Mouawad.
> > > > >>>
> > > > >>>
> > > > >>>
> > > > >>
> > > > >>
> > > > >> --
> > > > >> Cordialement.
> > > > >> Philippe Mouawad.
> > > > >>
> > > > >>
> > > > >>
> > > > >
> > > > >
> > > > > --
> > > > > Cordialement.
> > > > > Philippe Mouawad.
> > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> Hello Oleg,
> Thanks .
> 

Test case #testParseCookies 

The rest case does not look right to me. I am not sure I understand what
you are trying to test here.

Test case #testParseCookies

The cookie in question does not have a version attribute mandatory for
standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
Netscape style cookie in which case comma is not considered a valid
header element delimiter and is treated as normal character.

Oleg  
 

> Here it is:
> 
> /*
>  * ====================================================================
>  * 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
>  * "License"); 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
>  * "AS IS" 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.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  */
> package org.apache.http.client.protocol;
> 
> import java.util.List;
> 
> import org.apache.http.Header;
> import org.apache.http.HttpResponse;
> import org.apache.http.HttpResponseInterceptor;
> import org.apache.http.HttpVersion;
> import org.apache.http.client.CookieStore;
> import org.apache.http.cookie.Cookie;
> import org.apache.http.cookie.CookieOrigin;
> import org.apache.http.cookie.CookieSpec;
> import org.apache.http.cookie.SM;
> import org.apache.http.impl.client.BasicCookieStore;
> import org.apache.http.impl.cookie.DefaultCookieSpec;
> import org.apache.http.message.BasicHttpResponse;
> import org.apache.http.util.Asserts;
> import org.junit.Assert;
> import org.junit.Before;
> import org.junit.Test;
> 
> public class TestResponseProcessCookies {
> 
>     private CookieOrigin cookieOrigin;
>     private CookieSpec cookieSpec;
>     private CookieStore cookieStore;
> 
>     @Before
>     public void setUp() throws Exception {
>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/", false);
>         this.cookieSpec = new DefaultCookieSpec();
>         this.cookieStore = new BasicCookieStore();
>     }
> 
>     @Test(expected=IllegalArgumentException.class)
>     public void testResponseParameterCheck() throws Exception {
>         final HttpClientContext context = HttpClientContext.create();
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(null, context);
>     }
> 
>     @Test(expected=IllegalArgumentException.class)
>     public void testContextParameterCheck() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, null);
>     }
> 
>     @Test
>     public void testParseMultipleCookies() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
> test2=2; version=1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(1, cookies.size());
>         final Cookie cookie = cookies.get(0);
>         Assert.assertEquals(0, cookie.getVersion());
>         Assert.assertEquals("name1", cookie.getName());
>         Assert.assertEquals("value1", cookie.getValue());
>         Assert.assertEquals("localhost", cookie.getDomain());
>         Assert.assertEquals("/", cookie.getPath());
>     }
> 
>     @Test
>     public void testParseCookies() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
>     }
>     @Test
>     public void testParseCookies2() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "test1=1;secure, test2=2;secure");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
>     }
> 
>     @Test
>     public void testNoCookieOrigin() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
> 
>     @Test
>     public void testNoCookieSpec() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
> 
>     @Test
>     public void testNoCookieStore() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
> 
>     @Test
>     public void testSetCookie2OverrideSetCookie() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(1, cookies.size());
>         final Cookie cookie = cookies.get(0);
>         Assert.assertEquals(1, cookie.getVersion());
>         Assert.assertEquals("name1", cookie.getName());
>         Assert.assertEquals("value2", cookie.getValue());
>         Assert.assertEquals("localhost.local", cookie.getDomain());
>         Assert.assertEquals("/", cookie.getPath());
>     }
> 
>     @Test
>     public void testInvalidHeader() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertTrue(cookies.isEmpty());
>     }
> 
>     @Test
>     public void testCookieRejected() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> www.somedomain.com; Version=1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertTrue(cookies.isEmpty());
>     }
> 
> }
> 
> 
> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > > Finally, for those  2 I am not sure  as per RFC6265, to use them , put
> > code
> > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > > They worked with HC3 but it does not mean they should work with HC4, but
> > I
> > > would like a confirmation:
> > >
> >
> > I cannot get the tests to compile due to missing instance variables
> > cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
> > post the complete class.
> >
> > Oleg
> >
> >
> > >
> > >     @Test
> > >     public void testParseCookies() throws Exception {
> > >         final HttpResponse response = new
> > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >
> > >         final HttpClientContext context = HttpClientContext.create();
> > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > this.cookieOrigin);
> > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > this.cookieSpec);
> > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > this.cookieStore);
> > >
> > >         final HttpResponseInterceptor interceptor = new
> > > ResponseProcessCookies();
> > >         interceptor.process(response, context);
> > >
> > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >         StringBuilder sbHdr = new StringBuilder();
> > >         for (Header header : lstHdr) {
> > >             sbHdr.append(header.getValue());
> > >         }
> > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > sbHdr.toString());
> > >     }
> > >     @Test
> > >     public void testParseCookies2() throws Exception {
> > >         final HttpResponse response = new
> > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > test2=2;secure");
> > >
> > >         final HttpClientContext context = HttpClientContext.create();
> > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > this.cookieOrigin);
> > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > this.cookieSpec);
> > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > this.cookieStore);
> > >
> > >         final HttpResponseInterceptor interceptor = new
> > > ResponseProcessCookies();
> > >         interceptor.process(response, context);
> > >
> > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >         StringBuilder sbHdr = new StringBuilder();
> > >         for (Header header : lstHdr) {
> > >             sbHdr.append(header.getValue());
> > >         }
> > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > sbHdr.toString());
> > >     }
> > >
> > > Thanks
> > >
> > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > > philippe.mouawad@gmail.com> wrote:
> > >
> > > > Hi,
> > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a
> > Test
> > > > case in it to show issue with Domain starting with ".".
> > > >
> > > >
> > > > Regards
> > > >
> > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > > philippe.mouawad@gmail.com> wrote:
> > > >
> > > >> Hi Oleg,
> > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
> > > >> issue with Cookie Header ordering.
> > > >>
> > > >> Regards
> > > >>
> > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > > >> philippe.mouawad@gmail.com> wrote:
> > > >>
> > > >>> Hi,
> > > >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > with
> > > >>> JUnit test case so that you understand the difference we have.
> > > >>>
> > > >>> Regards
> > > >>>
> > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
> > > >>> wrote:
> > > >>>
> > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > > >>>> > Thanks Oleg.
> > > >>>> > But look at
> > > >>>> >
> > > >>>>
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > > >>>> ,
> > > >>>> > it concerns IGNORE_POLICY
> > > >>>> >
> > > >>>> > I really think there is at least one bug.
> > > >>>> > Regards
> > > >>>> >
> > > >>>>
> > > >>>> Sure thing. All these issues may well be due to bugs in HC. Could
> > you
> > > >>>> please though reproduce them with unit tests that do not involve
> > JMeter
> > > >>>> specific code?
> > > >>>>
> > > >>>> Oleg
> > > >>>>
> > > >>>>
> > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > olegk@apache.org>
> > > >>>> wrote:
> > > >>>> >
> > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > > >>>> > > > Hi Oleg,
> > > >>>> > > > Thanks for answer.
> > > >>>> > > >
> > > >>>> > > > Find my answers inline.
> > > >>>> > > > Regards
> > > >>>> > > >
> > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > > >>>> olegk@apache.org>
> > > >>>> > > wrote:
> > > >>>> > > >
> > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > > >>>> > > > > > Hello,
> > > >>>> > > > > > Any answer on this question ?
> > > >>>> > > > > > Thanks
> > > >>>> > > > > > Regards
> > > >>>> > > > > >
> > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > > >>>> > > > > >
> > > >>>> > > > > > > Hello,
> > > >>>> > > > > > > We're in the process of migrating JMeter to last
> > HttpClient
> > > >>>> 4.5.1.
> > > >>>> > > > > > >
> > > >>>> > > > > > > We are now migrating the CookieManager to remove all
> > > >>>> deprecated
> > > >>>> > > code.
> > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > > >>>> > > > > > >
> > > >>>> > > > > > >
> > > >>>> > > > >
> > > >>>> > >
> > > >>>>
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > >>>> > > > > > >
> > > >>>> > > > > > > Before migration, it was still testing HC3 version.
> > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> > failures:
> > > >>>> > > > > > >
> > > >>>> > > > >
> > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > > >>>> > > >
> > > >>>> > > >
> > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> > > >>>> Implementation
> > > >>>> > > of
> > > >>>> > > > CookieHandler and used 4.2.3, we got some failures compared to
> > > >>>> HC3.
> > > >>>> > > >
> > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> > failures
> > > >>>> all
> > > >>>> > > > detailed in initial mail.
> > > >>>> > > >
> > > >>>> > > >
> > > >>>> > > > What policy does
> > > >>>> > > > > CookeManager use internally?
> > > >>>> > > > >
> > > >>>> > > > It depends on tests, you can see in the code that depending on
> > > >>>> test
> > > >>>> > > method
> > > >>>> > > > we set different Policy to test them.
> > > >>>> > > >
> > > >>>> > >
> > > >>>> > > You ought to be using RFC6265 policy either in strict or relaxed
> > > >>>> mode
> > > >>>> > > and nothing else. All other policies have been marked as
> > obsolete
> > > >>>> and
> > > >>>> > > have already been removed in 5.0 (trunk).
> > > >>>> > >
> > > >>>> > > Oleg
> > > >>>> > >
> > > >>>> > >
> > > >>>> > >
> > > >>>>
> > ---------------------------------------------------------------------
> > > >>>> > > To unsubscribe, e-mail:
> > httpclient-users-unsubscribe@hc.apache.org
> > > >>>> > > For additional commands, e-mail:
> > > >>>> httpclient-users-help@hc.apache.org
> > > >>>> > >
> > > >>>> > >
> > > >>>> >
> > > >>>> >
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > ---------------------------------------------------------------------
> > > >>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > >>>> For additional commands, e-mail:
> > httpclient-users-help@hc.apache.org
> > > >>>>
> > > >>>>
> > > >>>
> > > >>>
> > > >>> --
> > > >>> Cordialement.
> > > >>> Philippe Mouawad.
> > > >>>
> > > >>>
> > > >>>
> > > >>
> > > >>
> > > >> --
> > > >> Cordialement.
> > > >> Philippe Mouawad.
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > > > --
> > > > Cordialement.
> > > > Philippe Mouawad.
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Mon, 2015-12-14 at 21:41 +0100, Philippe Mouawad wrote:
> Hello Oleg,
> Thanks .
> 

Test case #testParseCookies 

The rest case does not look right to me. I am not sure I understand what
you are trying to test here.

Test case #testParseCookies

The cookie in question does not have a version attribute mandatory for
standard (RFC 2109 and RFC 2965) cookies. Therefore it is parsed as
Netscape style cookie in which case comma is not considered a valid
header element delimiter and is treated as normal character.

Oleg  
 

> Here it is:
> 
> /*
>  * ====================================================================
>  * 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
>  * "License"); 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
>  * "AS IS" 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.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  *
>  */
> package org.apache.http.client.protocol;
> 
> import java.util.List;
> 
> import org.apache.http.Header;
> import org.apache.http.HttpResponse;
> import org.apache.http.HttpResponseInterceptor;
> import org.apache.http.HttpVersion;
> import org.apache.http.client.CookieStore;
> import org.apache.http.cookie.Cookie;
> import org.apache.http.cookie.CookieOrigin;
> import org.apache.http.cookie.CookieSpec;
> import org.apache.http.cookie.SM;
> import org.apache.http.impl.client.BasicCookieStore;
> import org.apache.http.impl.cookie.DefaultCookieSpec;
> import org.apache.http.message.BasicHttpResponse;
> import org.apache.http.util.Asserts;
> import org.junit.Assert;
> import org.junit.Before;
> import org.junit.Test;
> 
> public class TestResponseProcessCookies {
> 
>     private CookieOrigin cookieOrigin;
>     private CookieSpec cookieSpec;
>     private CookieStore cookieStore;
> 
>     @Before
>     public void setUp() throws Exception {
>         this.cookieOrigin = new CookieOrigin("localhost", 80, "/", false);
>         this.cookieSpec = new DefaultCookieSpec();
>         this.cookieStore = new BasicCookieStore();
>     }
> 
>     @Test(expected=IllegalArgumentException.class)
>     public void testResponseParameterCheck() throws Exception {
>         final HttpClientContext context = HttpClientContext.create();
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(null, context);
>     }
> 
>     @Test(expected=IllegalArgumentException.class)
>     public void testContextParameterCheck() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, null);
>     }
> 
>     @Test
>     public void testParseMultipleCookies() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
> test2=2; version=1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(1, cookies.size());
>         final Cookie cookie = cookies.get(0);
>         Assert.assertEquals(0, cookie.getVersion());
>         Assert.assertEquals("name1", cookie.getName());
>         Assert.assertEquals("value1", cookie.getValue());
>         Assert.assertEquals("localhost", cookie.getDomain());
>         Assert.assertEquals("/", cookie.getPath());
>     }
> 
>     @Test
>     public void testParseCookies() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
>     }
>     @Test
>     public void testParseCookies2() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "test1=1;secure, test2=2;secure");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
>     }
> 
>     @Test
>     public void testNoCookieOrigin() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
> 
>     @Test
>     public void testNoCookieSpec() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
> 
>     @Test
>     public void testNoCookieStore() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE, null);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(0, cookies.size());
>     }
> 
>     @Test
>     public void testSetCookie2OverrideSetCookie() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
>         response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertEquals(1, cookies.size());
>         final Cookie cookie = cookies.get(0);
>         Assert.assertEquals(1, cookie.getVersion());
>         Assert.assertEquals("name1", cookie.getName());
>         Assert.assertEquals("value2", cookie.getValue());
>         Assert.assertEquals("localhost.local", cookie.getDomain());
>         Assert.assertEquals("/", cookie.getPath());
>     }
> 
>     @Test
>     public void testInvalidHeader() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertTrue(cookies.isEmpty());
>     }
> 
>     @Test
>     public void testCookieRejected() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
> www.somedomain.com; Version=1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         Assert.assertNotNull(cookies);
>         Assert.assertTrue(cookies.isEmpty());
>     }
> 
> }
> 
> 
> On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > > Finally, for those  2 I am not sure  as per RFC6265, to use them , put
> > code
> > > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > > They worked with HC3 but it does not mean they should work with HC4, but
> > I
> > > would like a confirmation:
> > >
> >
> > I cannot get the tests to compile due to missing instance variables
> > cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
> > post the complete class.
> >
> > Oleg
> >
> >
> > >
> > >     @Test
> > >     public void testParseCookies() throws Exception {
> > >         final HttpResponse response = new
> > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> > >
> > >         final HttpClientContext context = HttpClientContext.create();
> > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > this.cookieOrigin);
> > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > this.cookieSpec);
> > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > this.cookieStore);
> > >
> > >         final HttpResponseInterceptor interceptor = new
> > > ResponseProcessCookies();
> > >         interceptor.process(response, context);
> > >
> > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >         StringBuilder sbHdr = new StringBuilder();
> > >         for (Header header : lstHdr) {
> > >             sbHdr.append(header.getValue());
> > >         }
> > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > sbHdr.toString());
> > >     }
> > >     @Test
> > >     public void testParseCookies2() throws Exception {
> > >         final HttpResponse response = new
> > > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> > >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> > test2=2;secure");
> > >
> > >         final HttpClientContext context = HttpClientContext.create();
> > >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > > this.cookieOrigin);
> > >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > > this.cookieSpec);
> > >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > > this.cookieStore);
> > >
> > >         final HttpResponseInterceptor interceptor = new
> > > ResponseProcessCookies();
> > >         interceptor.process(response, context);
> > >
> > >         final List<Cookie> cookies = this.cookieStore.getCookies();
> > >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> > >         StringBuilder sbHdr = new StringBuilder();
> > >         for (Header header : lstHdr) {
> > >             sbHdr.append(header.getValue());
> > >         }
> > >         org.junit.Assert.assertEquals("test1=1; test2=2",
> > sbHdr.toString());
> > >     }
> > >
> > > Thanks
> > >
> > > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > > philippe.mouawad@gmail.com> wrote:
> > >
> > > > Hi,
> > > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a
> > Test
> > > > case in it to show issue with Domain starting with ".".
> > > >
> > > >
> > > > Regards
> > > >
> > > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > > philippe.mouawad@gmail.com> wrote:
> > > >
> > > >> Hi Oleg,
> > > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
> > > >> issue with Cookie Header ordering.
> > > >>
> > > >> Regards
> > > >>
> > > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > > >> philippe.mouawad@gmail.com> wrote:
> > > >>
> > > >>> Hi,
> > > >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> > with
> > > >>> JUnit test case so that you understand the difference we have.
> > > >>>
> > > >>> Regards
> > > >>>
> > > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
> > > >>> wrote:
> > > >>>
> > > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > > >>>> > Thanks Oleg.
> > > >>>> > But look at
> > > >>>> >
> > > >>>>
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > > >>>> ,
> > > >>>> > it concerns IGNORE_POLICY
> > > >>>> >
> > > >>>> > I really think there is at least one bug.
> > > >>>> > Regards
> > > >>>> >
> > > >>>>
> > > >>>> Sure thing. All these issues may well be due to bugs in HC. Could
> > you
> > > >>>> please though reproduce them with unit tests that do not involve
> > JMeter
> > > >>>> specific code?
> > > >>>>
> > > >>>> Oleg
> > > >>>>
> > > >>>>
> > > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> > olegk@apache.org>
> > > >>>> wrote:
> > > >>>> >
> > > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > > >>>> > > > Hi Oleg,
> > > >>>> > > > Thanks for answer.
> > > >>>> > > >
> > > >>>> > > > Find my answers inline.
> > > >>>> > > > Regards
> > > >>>> > > >
> > > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > > >>>> olegk@apache.org>
> > > >>>> > > wrote:
> > > >>>> > > >
> > > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > > >>>> > > > > > Hello,
> > > >>>> > > > > > Any answer on this question ?
> > > >>>> > > > > > Thanks
> > > >>>> > > > > > Regards
> > > >>>> > > > > >
> > > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > > >>>> > > > > >
> > > >>>> > > > > > > Hello,
> > > >>>> > > > > > > We're in the process of migrating JMeter to last
> > HttpClient
> > > >>>> 4.5.1.
> > > >>>> > > > > > >
> > > >>>> > > > > > > We are now migrating the CookieManager to remove all
> > > >>>> deprecated
> > > >>>> > > code.
> > > >>>> > > > > > > To test this class, we had a JUNIT class :
> > > >>>> > > > > > >
> > > >>>> > > > > > >
> > > >>>> > > > >
> > > >>>> > >
> > > >>>>
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > >>>> > > > > > >
> > > >>>> > > > > > > Before migration, it was still testing HC3 version.
> > > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> > failures:
> > > >>>> > > > > > >
> > > >>>> > > > >
> > > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > > >>>> > > >
> > > >>>> > > >
> > > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> > > >>>> Implementation
> > > >>>> > > of
> > > >>>> > > > CookieHandler and used 4.2.3, we got some failures compared to
> > > >>>> HC3.
> > > >>>> > > >
> > > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> > failures
> > > >>>> all
> > > >>>> > > > detailed in initial mail.
> > > >>>> > > >
> > > >>>> > > >
> > > >>>> > > > What policy does
> > > >>>> > > > > CookeManager use internally?
> > > >>>> > > > >
> > > >>>> > > > It depends on tests, you can see in the code that depending on
> > > >>>> test
> > > >>>> > > method
> > > >>>> > > > we set different Policy to test them.
> > > >>>> > > >
> > > >>>> > >
> > > >>>> > > You ought to be using RFC6265 policy either in strict or relaxed
> > > >>>> mode
> > > >>>> > > and nothing else. All other policies have been marked as
> > obsolete
> > > >>>> and
> > > >>>> > > have already been removed in 5.0 (trunk).
> > > >>>> > >
> > > >>>> > > Oleg
> > > >>>> > >
> > > >>>> > >
> > > >>>> > >
> > > >>>>
> > ---------------------------------------------------------------------
> > > >>>> > > To unsubscribe, e-mail:
> > httpclient-users-unsubscribe@hc.apache.org
> > > >>>> > > For additional commands, e-mail:
> > > >>>> httpclient-users-help@hc.apache.org
> > > >>>> > >
> > > >>>> > >
> > > >>>> >
> > > >>>> >
> > > >>>>
> > > >>>>
> > > >>>>
> > > >>>>
> > ---------------------------------------------------------------------
> > > >>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > >>>> For additional commands, e-mail:
> > httpclient-users-help@hc.apache.org
> > > >>>>
> > > >>>>
> > > >>>
> > > >>>
> > > >>> --
> > > >>> Cordialement.
> > > >>> Philippe Mouawad.
> > > >>>
> > > >>>
> > > >>>
> > > >>
> > > >>
> > > >> --
> > > >> Cordialement.
> > > >> Philippe Mouawad.
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > > > --
> > > > Cordialement.
> > > > Philippe Mouawad.
> > > >
> > > >
> > > >
> > >
> > >
> >
> >
> >
> 
> 



Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello Oleg,
Thanks .

Here it is:

/*
 * ====================================================================
 * 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
 * "License"); 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
 * "AS IS" 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.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 */
package org.apache.http.client.protocol;

import java.util.List;

import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.HttpVersion;
import org.apache.http.client.CookieStore;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieSpec;
import org.apache.http.cookie.SM;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.cookie.DefaultCookieSpec;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.util.Asserts;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class TestResponseProcessCookies {

    private CookieOrigin cookieOrigin;
    private CookieSpec cookieSpec;
    private CookieStore cookieStore;

    @Before
    public void setUp() throws Exception {
        this.cookieOrigin = new CookieOrigin("localhost", 80, "/", false);
        this.cookieSpec = new DefaultCookieSpec();
        this.cookieStore = new BasicCookieStore();
    }

    @Test(expected=IllegalArgumentException.class)
    public void testResponseParameterCheck() throws Exception {
        final HttpClientContext context = HttpClientContext.create();
        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(null, context);
    }

    @Test(expected=IllegalArgumentException.class)
    public void testContextParameterCheck() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, null);
    }

    @Test
    public void testParseMultipleCookies() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
test2=2; version=1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final Cookie cookie = cookies.get(0);
        Assert.assertEquals(0, cookie.getVersion());
        Assert.assertEquals("name1", cookie.getName());
        Assert.assertEquals("value1", cookie.getValue());
        Assert.assertEquals("localhost", cookie.getDomain());
        Assert.assertEquals("/", cookie.getPath());
    }

    @Test
    public void testParseCookies() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        List<Header> lstHdr = cookieSpec.formatCookies(cookies);
        StringBuilder sbHdr = new StringBuilder();
        for (Header header : lstHdr) {
            sbHdr.append(header.getValue());
        }
        org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
    }
    @Test
    public void testParseCookies2() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "test1=1;secure, test2=2;secure");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        List<Header> lstHdr = cookieSpec.formatCookies(cookies);
        StringBuilder sbHdr = new StringBuilder();
        for (Header header : lstHdr) {
            sbHdr.append(header.getValue());
        }
        org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
    }

    @Test
    public void testNoCookieOrigin() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(0, cookies.size());
    }

    @Test
    public void testNoCookieSpec() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(0, cookies.size());
    }

    @Test
    public void testNoCookieStore() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE, null);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(0, cookies.size());
    }

    @Test
    public void testSetCookie2OverrideSetCookie() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");
        response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final Cookie cookie = cookies.get(0);
        Assert.assertEquals(1, cookie.getVersion());
        Assert.assertEquals("name1", cookie.getName());
        Assert.assertEquals("value2", cookie.getValue());
        Assert.assertEquals("localhost.local", cookie.getDomain());
        Assert.assertEquals("/", cookie.getPath());
    }

    @Test
    public void testInvalidHeader() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertTrue(cookies.isEmpty());
    }

    @Test
    public void testCookieRejected() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
www.somedomain.com; Version=1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertTrue(cookies.isEmpty());
    }

}


On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > Finally, for those  2 I am not sure  as per RFC6265, to use them , put
> code
> > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > They worked with HC3 but it does not mean they should work with HC4, but
> I
> > would like a confirmation:
> >
>
> I cannot get the tests to compile due to missing instance variables
> cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
> post the complete class.
>
> Oleg
>
>
> >
> >     @Test
> >     public void testParseCookies() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >         StringBuilder sbHdr = new StringBuilder();
> >         for (Header header : lstHdr) {
> >             sbHdr.append(header.getValue());
> >         }
> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
> >     }
> >     @Test
> >     public void testParseCookies2() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> test2=2;secure");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >         StringBuilder sbHdr = new StringBuilder();
> >         for (Header header : lstHdr) {
> >             sbHdr.append(header.getValue());
> >         }
> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
> >     }
> >
> > Thanks
> >
> > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> > > Hi,
> > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a
> Test
> > > case in it to show issue with Domain starting with ".".
> > >
> > >
> > > Regards
> > >
> > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > philippe.mouawad@gmail.com> wrote:
> > >
> > >> Hi Oleg,
> > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
> > >> issue with Cookie Header ordering.
> > >>
> > >> Regards
> > >>
> > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > >> philippe.mouawad@gmail.com> wrote:
> > >>
> > >>> Hi,
> > >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> with
> > >>> JUnit test case so that you understand the difference we have.
> > >>>
> > >>> Regards
> > >>>
> > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
> > >>> wrote:
> > >>>
> > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > >>>> > Thanks Oleg.
> > >>>> > But look at
> > >>>> >
> > >>>>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > >>>> ,
> > >>>> > it concerns IGNORE_POLICY
> > >>>> >
> > >>>> > I really think there is at least one bug.
> > >>>> > Regards
> > >>>> >
> > >>>>
> > >>>> Sure thing. All these issues may well be due to bugs in HC. Could
> you
> > >>>> please though reproduce them with unit tests that do not involve
> JMeter
> > >>>> specific code?
> > >>>>
> > >>>> Oleg
> > >>>>
> > >>>>
> > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> olegk@apache.org>
> > >>>> wrote:
> > >>>> >
> > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > >>>> > > > Hi Oleg,
> > >>>> > > > Thanks for answer.
> > >>>> > > >
> > >>>> > > > Find my answers inline.
> > >>>> > > > Regards
> > >>>> > > >
> > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > >>>> olegk@apache.org>
> > >>>> > > wrote:
> > >>>> > > >
> > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > >>>> > > > > > Hello,
> > >>>> > > > > > Any answer on this question ?
> > >>>> > > > > > Thanks
> > >>>> > > > > > Regards
> > >>>> > > > > >
> > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > >>>> > > > > >
> > >>>> > > > > > > Hello,
> > >>>> > > > > > > We're in the process of migrating JMeter to last
> HttpClient
> > >>>> 4.5.1.
> > >>>> > > > > > >
> > >>>> > > > > > > We are now migrating the CookieManager to remove all
> > >>>> deprecated
> > >>>> > > code.
> > >>>> > > > > > > To test this class, we had a JUNIT class :
> > >>>> > > > > > >
> > >>>> > > > > > >
> > >>>> > > > >
> > >>>> > >
> > >>>>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > >>>> > > > > > >
> > >>>> > > > > > > Before migration, it was still testing HC3 version.
> > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> failures:
> > >>>> > > > > > >
> > >>>> > > > >
> > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > >>>> > > >
> > >>>> > > >
> > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> > >>>> Implementation
> > >>>> > > of
> > >>>> > > > CookieHandler and used 4.2.3, we got some failures compared to
> > >>>> HC3.
> > >>>> > > >
> > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> failures
> > >>>> all
> > >>>> > > > detailed in initial mail.
> > >>>> > > >
> > >>>> > > >
> > >>>> > > > What policy does
> > >>>> > > > > CookeManager use internally?
> > >>>> > > > >
> > >>>> > > > It depends on tests, you can see in the code that depending on
> > >>>> test
> > >>>> > > method
> > >>>> > > > we set different Policy to test them.
> > >>>> > > >
> > >>>> > >
> > >>>> > > You ought to be using RFC6265 policy either in strict or relaxed
> > >>>> mode
> > >>>> > > and nothing else. All other policies have been marked as
> obsolete
> > >>>> and
> > >>>> > > have already been removed in 5.0 (trunk).
> > >>>> > >
> > >>>> > > Oleg
> > >>>> > >
> > >>>> > >
> > >>>> > >
> > >>>>
> ---------------------------------------------------------------------
> > >>>> > > To unsubscribe, e-mail:
> httpclient-users-unsubscribe@hc.apache.org
> > >>>> > > For additional commands, e-mail:
> > >>>> httpclient-users-help@hc.apache.org
> > >>>> > >
> > >>>> > >
> > >>>> >
> > >>>> >
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> ---------------------------------------------------------------------
> > >>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > >>>> For additional commands, e-mail:
> httpclient-users-help@hc.apache.org
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>> --
> > >>> Cordialement.
> > >>> Philippe Mouawad.
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >> --
> > >> Cordialement.
> > >> Philippe Mouawad.
> > >>
> > >>
> > >>
> > >
> > >
> > > --
> > > Cordialement.
> > > Philippe Mouawad.
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hello Oleg,
Thanks .

Here it is:

/*
 * ====================================================================
 * 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
 * "License"); 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
 * "AS IS" 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.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 *
 */
package org.apache.http.client.protocol;

import java.util.List;

import org.apache.http.Header;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.HttpVersion;
import org.apache.http.client.CookieStore;
import org.apache.http.cookie.Cookie;
import org.apache.http.cookie.CookieOrigin;
import org.apache.http.cookie.CookieSpec;
import org.apache.http.cookie.SM;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.cookie.DefaultCookieSpec;
import org.apache.http.message.BasicHttpResponse;
import org.apache.http.util.Asserts;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class TestResponseProcessCookies {

    private CookieOrigin cookieOrigin;
    private CookieSpec cookieSpec;
    private CookieStore cookieStore;

    @Before
    public void setUp() throws Exception {
        this.cookieOrigin = new CookieOrigin("localhost", 80, "/", false);
        this.cookieSpec = new DefaultCookieSpec();
        this.cookieStore = new BasicCookieStore();
    }

    @Test(expected=IllegalArgumentException.class)
    public void testResponseParameterCheck() throws Exception {
        final HttpClientContext context = HttpClientContext.create();
        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(null, context);
    }

    @Test(expected=IllegalArgumentException.class)
    public void testContextParameterCheck() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, null);
    }

    @Test
    public void testParseMultipleCookies() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "test1=1; comment=\"how,now\",
test2=2; version=1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final Cookie cookie = cookies.get(0);
        Assert.assertEquals(0, cookie.getVersion());
        Assert.assertEquals("name1", cookie.getName());
        Assert.assertEquals("value1", cookie.getValue());
        Assert.assertEquals("localhost", cookie.getDomain());
        Assert.assertEquals("/", cookie.getPath());
    }

    @Test
    public void testParseCookies() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        List<Header> lstHdr = cookieSpec.formatCookies(cookies);
        StringBuilder sbHdr = new StringBuilder();
        for (Header header : lstHdr) {
            sbHdr.append(header.getValue());
        }
        org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
    }
    @Test
    public void testParseCookies2() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "test1=1;secure, test2=2;secure");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        List<Header> lstHdr = cookieSpec.formatCookies(cookies);
        StringBuilder sbHdr = new StringBuilder();
        for (Header header : lstHdr) {
            sbHdr.append(header.getValue());
        }
        org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
    }

    @Test
    public void testNoCookieOrigin() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(0, cookies.size());
    }

    @Test
    public void testNoCookieSpec() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(0, cookies.size());
    }

    @Test
    public void testNoCookieStore() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE, null);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(0, cookies.size());
    }

    @Test
    public void testSetCookie2OverrideSetCookie() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");
        response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertEquals(1, cookies.size());
        final Cookie cookie = cookies.get(0);
        Assert.assertEquals(1, cookie.getVersion());
        Assert.assertEquals("name1", cookie.getName());
        Assert.assertEquals("value2", cookie.getValue());
        Assert.assertEquals("localhost.local", cookie.getDomain());
        Assert.assertEquals("/", cookie.getPath());
    }

    @Test
    public void testInvalidHeader() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertTrue(cookies.isEmpty());
    }

    @Test
    public void testCookieRejected() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE2, "name=value; Domain=
www.somedomain.com; Version=1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        Assert.assertNotNull(cookies);
        Assert.assertTrue(cookies.isEmpty());
    }

}


On Mon, Dec 14, 2015 at 9:34 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> > Finally, for those  2 I am not sure  as per RFC6265, to use them , put
> code
> > in org.apache.http.client.protocol.TestResponseProcessCookies.
> > They worked with HC3 but it does not mean they should work with HC4, but
> I
> > would like a confirmation:
> >
>
> I cannot get the tests to compile due to missing instance variables
> cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
> post the complete class.
>
> Oleg
>
>
> >
> >     @Test
> >     public void testParseCookies() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "name1=value1");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >         StringBuilder sbHdr = new StringBuilder();
> >         for (Header header : lstHdr) {
> >             sbHdr.append(header.getValue());
> >         }
> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
> >     }
> >     @Test
> >     public void testParseCookies2() throws Exception {
> >         final HttpResponse response = new
> > BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
> >         response.addHeader(SM.SET_COOKIE, "test1=1;secure,
> test2=2;secure");
> >
> >         final HttpClientContext context = HttpClientContext.create();
> >         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> > this.cookieOrigin);
> >         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> > this.cookieSpec);
> >         context.setAttribute(HttpClientContext.COOKIE_STORE,
> > this.cookieStore);
> >
> >         final HttpResponseInterceptor interceptor = new
> > ResponseProcessCookies();
> >         interceptor.process(response, context);
> >
> >         final List<Cookie> cookies = this.cookieStore.getCookies();
> >         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
> >         StringBuilder sbHdr = new StringBuilder();
> >         for (Header header : lstHdr) {
> >             sbHdr.append(header.getValue());
> >         }
> >         org.junit.Assert.assertEquals("test1=1; test2=2",
> sbHdr.toString());
> >     }
> >
> > Thanks
> >
> > On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> > > Hi,
> > > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a
> Test
> > > case in it to show issue with Domain starting with ".".
> > >
> > >
> > > Regards
> > >
> > > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > > philippe.mouawad@gmail.com> wrote:
> > >
> > >> Hi Oleg,
> > >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
> > >> issue with Cookie Header ordering.
> > >>
> > >> Regards
> > >>
> > >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> > >> philippe.mouawad@gmail.com> wrote:
> > >>
> > >>> Hi,
> > >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704
> with
> > >>> JUnit test case so that you understand the difference we have.
> > >>>
> > >>> Regards
> > >>>
> > >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
> > >>> wrote:
> > >>>
> > >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > >>>> > Thanks Oleg.
> > >>>> > But look at
> > >>>> >
> > >>>>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> > >>>> ,
> > >>>> > it concerns IGNORE_POLICY
> > >>>> >
> > >>>> > I really think there is at least one bug.
> > >>>> > Regards
> > >>>> >
> > >>>>
> > >>>> Sure thing. All these issues may well be due to bugs in HC. Could
> you
> > >>>> please though reproduce them with unit tests that do not involve
> JMeter
> > >>>> specific code?
> > >>>>
> > >>>> Oleg
> > >>>>
> > >>>>
> > >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <
> olegk@apache.org>
> > >>>> wrote:
> > >>>> >
> > >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > >>>> > > > Hi Oleg,
> > >>>> > > > Thanks for answer.
> > >>>> > > >
> > >>>> > > > Find my answers inline.
> > >>>> > > > Regards
> > >>>> > > >
> > >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> > >>>> olegk@apache.org>
> > >>>> > > wrote:
> > >>>> > > >
> > >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > >>>> > > > > > Hello,
> > >>>> > > > > > Any answer on this question ?
> > >>>> > > > > > Thanks
> > >>>> > > > > > Regards
> > >>>> > > > > >
> > >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> > >>>> > > > > >
> > >>>> > > > > > > Hello,
> > >>>> > > > > > > We're in the process of migrating JMeter to last
> HttpClient
> > >>>> 4.5.1.
> > >>>> > > > > > >
> > >>>> > > > > > > We are now migrating the CookieManager to remove all
> > >>>> deprecated
> > >>>> > > code.
> > >>>> > > > > > > To test this class, we had a JUNIT class :
> > >>>> > > > > > >
> > >>>> > > > > > >
> > >>>> > > > >
> > >>>> > >
> > >>>>
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > >>>> > > > > > >
> > >>>> > > > > > > Before migration, it was still testing HC3 version.
> > >>>> > > > > > > So we first switched to HC4.23 and noticed some
> failures:
> > >>>> > > > > > >
> > >>>> > > > >
> > >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > >>>> > > >
> > >>>> > > >
> > >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> > >>>> Implementation
> > >>>> > > of
> > >>>> > > > CookieHandler and used 4.2.3, we got some failures compared to
> > >>>> HC3.
> > >>>> > > >
> > >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other
> failures
> > >>>> all
> > >>>> > > > detailed in initial mail.
> > >>>> > > >
> > >>>> > > >
> > >>>> > > > What policy does
> > >>>> > > > > CookeManager use internally?
> > >>>> > > > >
> > >>>> > > > It depends on tests, you can see in the code that depending on
> > >>>> test
> > >>>> > > method
> > >>>> > > > we set different Policy to test them.
> > >>>> > > >
> > >>>> > >
> > >>>> > > You ought to be using RFC6265 policy either in strict or relaxed
> > >>>> mode
> > >>>> > > and nothing else. All other policies have been marked as
> obsolete
> > >>>> and
> > >>>> > > have already been removed in 5.0 (trunk).
> > >>>> > >
> > >>>> > > Oleg
> > >>>> > >
> > >>>> > >
> > >>>> > >
> > >>>>
> ---------------------------------------------------------------------
> > >>>> > > To unsubscribe, e-mail:
> httpclient-users-unsubscribe@hc.apache.org
> > >>>> > > For additional commands, e-mail:
> > >>>> httpclient-users-help@hc.apache.org
> > >>>> > >
> > >>>> > >
> > >>>> >
> > >>>> >
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> ---------------------------------------------------------------------
> > >>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > >>>> For additional commands, e-mail:
> httpclient-users-help@hc.apache.org
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>> --
> > >>> Cordialement.
> > >>> Philippe Mouawad.
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >> --
> > >> Cordialement.
> > >> Philippe Mouawad.
> > >>
> > >>
> > >>
> > >
> > >
> > > --
> > > Cordialement.
> > > Philippe Mouawad.
> > >
> > >
> > >
> >
> >
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> Finally, for those  2 I am not sure  as per RFC6265, to use them , put code
> in org.apache.http.client.protocol.TestResponseProcessCookies.
> They worked with HC3 but it does not mean they should work with HC4, but I
> would like a confirmation:
> 

I cannot get the tests to compile due to missing instance variables
cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
post the complete class. 

Oleg


> 
>     @Test
>     public void testParseCookies() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
>     }
>     @Test
>     public void testParseCookies2() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "test1=1;secure, test2=2;secure");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
>     }
> 
> Thanks
> 
> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
> 
> > Hi,
> > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a Test
> > case in it to show issue with Domain starting with ".".
> >
> >
> > Regards
> >
> > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> >> Hi Oleg,
> >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
> >> issue with Cookie Header ordering.
> >>
> >> Regards
> >>
> >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >> philippe.mouawad@gmail.com> wrote:
> >>
> >>> Hi,
> >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with
> >>> JUnit test case so that you understand the difference we have.
> >>>
> >>> Regards
> >>>
> >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
> >>> wrote:
> >>>
> >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> >>>> > Thanks Oleg.
> >>>> > But look at
> >>>> >
> >>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >>>> ,
> >>>> > it concerns IGNORE_POLICY
> >>>> >
> >>>> > I really think there is at least one bug.
> >>>> > Regards
> >>>> >
> >>>>
> >>>> Sure thing. All these issues may well be due to bugs in HC. Could you
> >>>> please though reproduce them with unit tests that do not involve JMeter
> >>>> specific code?
> >>>>
> >>>> Oleg
> >>>>
> >>>>
> >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
> >>>> wrote:
> >>>> >
> >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> >>>> > > > Hi Oleg,
> >>>> > > > Thanks for answer.
> >>>> > > >
> >>>> > > > Find my answers inline.
> >>>> > > > Regards
> >>>> > > >
> >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >>>> olegk@apache.org>
> >>>> > > wrote:
> >>>> > > >
> >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> >>>> > > > > > Hello,
> >>>> > > > > > Any answer on this question ?
> >>>> > > > > > Thanks
> >>>> > > > > > Regards
> >>>> > > > > >
> >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> >>>> > > > > >
> >>>> > > > > > > Hello,
> >>>> > > > > > > We're in the process of migrating JMeter to last HttpClient
> >>>> 4.5.1.
> >>>> > > > > > >
> >>>> > > > > > > We are now migrating the CookieManager to remove all
> >>>> deprecated
> >>>> > > code.
> >>>> > > > > > > To test this class, we had a JUNIT class :
> >>>> > > > > > >
> >>>> > > > > > >
> >>>> > > > >
> >>>> > >
> >>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >>>> > > > > > >
> >>>> > > > > > > Before migration, it was still testing HC3 version.
> >>>> > > > > > > So we first switched to HC4.23 and noticed some failures:
> >>>> > > > > > >
> >>>> > > > >
> >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >>>> > > >
> >>>> > > >
> >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> >>>> Implementation
> >>>> > > of
> >>>> > > > CookieHandler and used 4.2.3, we got some failures compared to
> >>>> HC3.
> >>>> > > >
> >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures
> >>>> all
> >>>> > > > detailed in initial mail.
> >>>> > > >
> >>>> > > >
> >>>> > > > What policy does
> >>>> > > > > CookeManager use internally?
> >>>> > > > >
> >>>> > > > It depends on tests, you can see in the code that depending on
> >>>> test
> >>>> > > method
> >>>> > > > we set different Policy to test them.
> >>>> > > >
> >>>> > >
> >>>> > > You ought to be using RFC6265 policy either in strict or relaxed
> >>>> mode
> >>>> > > and nothing else. All other policies have been marked as obsolete
> >>>> and
> >>>> > > have already been removed in 5.0 (trunk).
> >>>> > >
> >>>> > > Oleg
> >>>> > >
> >>>> > >
> >>>> > >
> >>>> ---------------------------------------------------------------------
> >>>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >>>> > > For additional commands, e-mail:
> >>>> httpclient-users-help@hc.apache.org
> >>>> > >
> >>>> > >
> >>>> >
> >>>> >
> >>>>
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> Cordialement.
> >>> Philippe Mouawad.
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >> Cordialement.
> >> Philippe Mouawad.
> >>
> >>
> >>
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
> >
> >
> >
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sun, 2015-12-13 at 22:28 +0100, Philippe Mouawad wrote:
> Finally, for those  2 I am not sure  as per RFC6265, to use them , put code
> in org.apache.http.client.protocol.TestResponseProcessCookies.
> They worked with HC3 but it does not mean they should work with HC4, but I
> would like a confirmation:
> 

I cannot get the tests to compile due to missing instance variables
cookieOrigin, cookieSpec and cookieStore. I'll take another look if you
post the complete class. 

Oleg


> 
>     @Test
>     public void testParseCookies() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "name1=value1");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
>     }
>     @Test
>     public void testParseCookies2() throws Exception {
>         final HttpResponse response = new
> BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
>         response.addHeader(SM.SET_COOKIE, "test1=1;secure, test2=2;secure");
> 
>         final HttpClientContext context = HttpClientContext.create();
>         context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
> this.cookieOrigin);
>         context.setAttribute(HttpClientContext.COOKIE_SPEC,
> this.cookieSpec);
>         context.setAttribute(HttpClientContext.COOKIE_STORE,
> this.cookieStore);
> 
>         final HttpResponseInterceptor interceptor = new
> ResponseProcessCookies();
>         interceptor.process(response, context);
> 
>         final List<Cookie> cookies = this.cookieStore.getCookies();
>         List<Header> lstHdr = cookieSpec.formatCookies(cookies);
>         StringBuilder sbHdr = new StringBuilder();
>         for (Header header : lstHdr) {
>             sbHdr.append(header.getValue());
>         }
>         org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
>     }
> 
> Thanks
> 
> On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
> 
> > Hi,
> > Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a Test
> > case in it to show issue with Domain starting with ".".
> >
> >
> > Regards
> >
> > On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> >> Hi Oleg,
> >> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
> >> issue with Cookie Header ordering.
> >>
> >> Regards
> >>
> >> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> >> philippe.mouawad@gmail.com> wrote:
> >>
> >>> Hi,
> >>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with
> >>> JUnit test case so that you understand the difference we have.
> >>>
> >>> Regards
> >>>
> >>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
> >>> wrote:
> >>>
> >>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> >>>> > Thanks Oleg.
> >>>> > But look at
> >>>> >
> >>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> >>>> ,
> >>>> > it concerns IGNORE_POLICY
> >>>> >
> >>>> > I really think there is at least one bug.
> >>>> > Regards
> >>>> >
> >>>>
> >>>> Sure thing. All these issues may well be due to bugs in HC. Could you
> >>>> please though reproduce them with unit tests that do not involve JMeter
> >>>> specific code?
> >>>>
> >>>> Oleg
> >>>>
> >>>>
> >>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
> >>>> wrote:
> >>>> >
> >>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> >>>> > > > Hi Oleg,
> >>>> > > > Thanks for answer.
> >>>> > > >
> >>>> > > > Find my answers inline.
> >>>> > > > Regards
> >>>> > > >
> >>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
> >>>> olegk@apache.org>
> >>>> > > wrote:
> >>>> > > >
> >>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> >>>> > > > > > Hello,
> >>>> > > > > > Any answer on this question ?
> >>>> > > > > > Thanks
> >>>> > > > > > Regards
> >>>> > > > > >
> >>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> >>>> > > > > > philippe.mouawad@gmail.com> wrote:
> >>>> > > > > >
> >>>> > > > > > > Hello,
> >>>> > > > > > > We're in the process of migrating JMeter to last HttpClient
> >>>> 4.5.1.
> >>>> > > > > > >
> >>>> > > > > > > We are now migrating the CookieManager to remove all
> >>>> deprecated
> >>>> > > code.
> >>>> > > > > > > To test this class, we had a JUNIT class :
> >>>> > > > > > >
> >>>> > > > > > >
> >>>> > > > >
> >>>> > >
> >>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >>>> > > > > > >
> >>>> > > > > > > Before migration, it was still testing HC3 version.
> >>>> > > > > > > So we first switched to HC4.23 and noticed some failures:
> >>>> > > > > > >
> >>>> > > > >
> >>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >>>> > > >
> >>>> > > >
> >>>> > > > As I wrote, first we switched our JUnit tests to use HC4
> >>>> Implementation
> >>>> > > of
> >>>> > > > CookieHandler and used 4.2.3, we got some failures compared to
> >>>> HC3.
> >>>> > > >
> >>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures
> >>>> all
> >>>> > > > detailed in initial mail.
> >>>> > > >
> >>>> > > >
> >>>> > > > What policy does
> >>>> > > > > CookeManager use internally?
> >>>> > > > >
> >>>> > > > It depends on tests, you can see in the code that depending on
> >>>> test
> >>>> > > method
> >>>> > > > we set different Policy to test them.
> >>>> > > >
> >>>> > >
> >>>> > > You ought to be using RFC6265 policy either in strict or relaxed
> >>>> mode
> >>>> > > and nothing else. All other policies have been marked as obsolete
> >>>> and
> >>>> > > have already been removed in 5.0 (trunk).
> >>>> > >
> >>>> > > Oleg
> >>>> > >
> >>>> > >
> >>>> > >
> >>>> ---------------------------------------------------------------------
> >>>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >>>> > > For additional commands, e-mail:
> >>>> httpclient-users-help@hc.apache.org
> >>>> > >
> >>>> > >
> >>>> >
> >>>> >
> >>>>
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> Cordialement.
> >>> Philippe Mouawad.
> >>>
> >>>
> >>>
> >>
> >>
> >> --
> >> Cordialement.
> >> Philippe Mouawad.
> >>
> >>
> >>
> >
> >
> > --
> > Cordialement.
> > Philippe Mouawad.
> >
> >
> >
> 
> 



Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Finally, for those  2 I am not sure  as per RFC6265, to use them , put code
in org.apache.http.client.protocol.TestResponseProcessCookies.
They worked with HC3 but it does not mean they should work with HC4, but I
would like a confirmation:


    @Test
    public void testParseCookies() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        List<Header> lstHdr = cookieSpec.formatCookies(cookies);
        StringBuilder sbHdr = new StringBuilder();
        for (Header header : lstHdr) {
            sbHdr.append(header.getValue());
        }
        org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
    }
    @Test
    public void testParseCookies2() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "test1=1;secure, test2=2;secure");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        List<Header> lstHdr = cookieSpec.formatCookies(cookies);
        StringBuilder sbHdr = new StringBuilder();
        for (Header header : lstHdr) {
            sbHdr.append(header.getValue());
        }
        org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
    }

Thanks

On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi,
> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a Test
> case in it to show issue with Domain starting with ".".
>
>
> Regards
>
> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
>
>> Hi Oleg,
>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
>> issue with Cookie Header ordering.
>>
>> Regards
>>
>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>> philippe.mouawad@gmail.com> wrote:
>>
>>> Hi,
>>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with
>>> JUnit test case so that you understand the difference we have.
>>>
>>> Regards
>>>
>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
>>> wrote:
>>>
>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>>> > Thanks Oleg.
>>>> > But look at
>>>> >
>>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>>> ,
>>>> > it concerns IGNORE_POLICY
>>>> >
>>>> > I really think there is at least one bug.
>>>> > Regards
>>>> >
>>>>
>>>> Sure thing. All these issues may well be due to bugs in HC. Could you
>>>> please though reproduce them with unit tests that do not involve JMeter
>>>> specific code?
>>>>
>>>> Oleg
>>>>
>>>>
>>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
>>>> wrote:
>>>> >
>>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>>> > > > Hi Oleg,
>>>> > > > Thanks for answer.
>>>> > > >
>>>> > > > Find my answers inline.
>>>> > > > Regards
>>>> > > >
>>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>>> olegk@apache.org>
>>>> > > wrote:
>>>> > > >
>>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>>>> > > > > > Hello,
>>>> > > > > > Any answer on this question ?
>>>> > > > > > Thanks
>>>> > > > > > Regards
>>>> > > > > >
>>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>>> > > > > > philippe.mouawad@gmail.com> wrote:
>>>> > > > > >
>>>> > > > > > > Hello,
>>>> > > > > > > We're in the process of migrating JMeter to last HttpClient
>>>> 4.5.1.
>>>> > > > > > >
>>>> > > > > > > We are now migrating the CookieManager to remove all
>>>> deprecated
>>>> > > code.
>>>> > > > > > > To test this class, we had a JUNIT class :
>>>> > > > > > >
>>>> > > > > > >
>>>> > > > >
>>>> > >
>>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>>> > > > > > >
>>>> > > > > > > Before migration, it was still testing HC3 version.
>>>> > > > > > > So we first switched to HC4.23 and noticed some failures:
>>>> > > > > > >
>>>> > > > >
>>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>>> > > >
>>>> > > >
>>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>>>> Implementation
>>>> > > of
>>>> > > > CookieHandler and used 4.2.3, we got some failures compared to
>>>> HC3.
>>>> > > >
>>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures
>>>> all
>>>> > > > detailed in initial mail.
>>>> > > >
>>>> > > >
>>>> > > > What policy does
>>>> > > > > CookeManager use internally?
>>>> > > > >
>>>> > > > It depends on tests, you can see in the code that depending on
>>>> test
>>>> > > method
>>>> > > > we set different Policy to test them.
>>>> > > >
>>>> > >
>>>> > > You ought to be using RFC6265 policy either in strict or relaxed
>>>> mode
>>>> > > and nothing else. All other policies have been marked as obsolete
>>>> and
>>>> > > have already been removed in 5.0 (trunk).
>>>> > >
>>>> > > Oleg
>>>> > >
>>>> > >
>>>> > >
>>>> ---------------------------------------------------------------------
>>>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>>> > > For additional commands, e-mail:
>>>> httpclient-users-help@hc.apache.org
>>>> > >
>>>> > >
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>>
>>>>
>>>
>>>
>>> --
>>> Cordialement.
>>> Philippe Mouawad.
>>>
>>>
>>>
>>
>>
>> --
>> Cordialement.
>> Philippe Mouawad.
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Finally, for those  2 I am not sure  as per RFC6265, to use them , put code
in org.apache.http.client.protocol.TestResponseProcessCookies.
They worked with HC3 but it does not mean they should work with HC4, but I
would like a confirmation:


    @Test
    public void testParseCookies() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "name1=value1");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        List<Header> lstHdr = cookieSpec.formatCookies(cookies);
        StringBuilder sbHdr = new StringBuilder();
        for (Header header : lstHdr) {
            sbHdr.append(header.getValue());
        }
        org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
    }
    @Test
    public void testParseCookies2() throws Exception {
        final HttpResponse response = new
BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
        response.addHeader(SM.SET_COOKIE, "test1=1;secure, test2=2;secure");

        final HttpClientContext context = HttpClientContext.create();
        context.setAttribute(HttpClientContext.COOKIE_ORIGIN,
this.cookieOrigin);
        context.setAttribute(HttpClientContext.COOKIE_SPEC,
this.cookieSpec);
        context.setAttribute(HttpClientContext.COOKIE_STORE,
this.cookieStore);

        final HttpResponseInterceptor interceptor = new
ResponseProcessCookies();
        interceptor.process(response, context);

        final List<Cookie> cookies = this.cookieStore.getCookies();
        List<Header> lstHdr = cookieSpec.formatCookies(cookies);
        StringBuilder sbHdr = new StringBuilder();
        for (Header header : lstHdr) {
            sbHdr.append(header.getValue());
        }
        org.junit.Assert.assertEquals("test1=1; test2=2", sbHdr.toString());
    }

Thanks

On Sun, Dec 13, 2015 at 10:09 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi,
> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a Test
> case in it to show issue with Domain starting with ".".
>
>
> Regards
>
> On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
>
>> Hi Oleg,
>> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
>> issue with Cookie Header ordering.
>>
>> Regards
>>
>> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
>> philippe.mouawad@gmail.com> wrote:
>>
>>> Hi,
>>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with
>>> JUnit test case so that you understand the difference we have.
>>>
>>> Regards
>>>
>>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
>>> wrote:
>>>
>>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>>> > Thanks Oleg.
>>>> > But look at
>>>> >
>>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>>> ,
>>>> > it concerns IGNORE_POLICY
>>>> >
>>>> > I really think there is at least one bug.
>>>> > Regards
>>>> >
>>>>
>>>> Sure thing. All these issues may well be due to bugs in HC. Could you
>>>> please though reproduce them with unit tests that do not involve JMeter
>>>> specific code?
>>>>
>>>> Oleg
>>>>
>>>>
>>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
>>>> wrote:
>>>> >
>>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>>> > > > Hi Oleg,
>>>> > > > Thanks for answer.
>>>> > > >
>>>> > > > Find my answers inline.
>>>> > > > Regards
>>>> > > >
>>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>>> olegk@apache.org>
>>>> > > wrote:
>>>> > > >
>>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>>>> > > > > > Hello,
>>>> > > > > > Any answer on this question ?
>>>> > > > > > Thanks
>>>> > > > > > Regards
>>>> > > > > >
>>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>>> > > > > > philippe.mouawad@gmail.com> wrote:
>>>> > > > > >
>>>> > > > > > > Hello,
>>>> > > > > > > We're in the process of migrating JMeter to last HttpClient
>>>> 4.5.1.
>>>> > > > > > >
>>>> > > > > > > We are now migrating the CookieManager to remove all
>>>> deprecated
>>>> > > code.
>>>> > > > > > > To test this class, we had a JUNIT class :
>>>> > > > > > >
>>>> > > > > > >
>>>> > > > >
>>>> > >
>>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>>> > > > > > >
>>>> > > > > > > Before migration, it was still testing HC3 version.
>>>> > > > > > > So we first switched to HC4.23 and noticed some failures:
>>>> > > > > > >
>>>> > > > >
>>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>>> > > >
>>>> > > >
>>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>>>> Implementation
>>>> > > of
>>>> > > > CookieHandler and used 4.2.3, we got some failures compared to
>>>> HC3.
>>>> > > >
>>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures
>>>> all
>>>> > > > detailed in initial mail.
>>>> > > >
>>>> > > >
>>>> > > > What policy does
>>>> > > > > CookeManager use internally?
>>>> > > > >
>>>> > > > It depends on tests, you can see in the code that depending on
>>>> test
>>>> > > method
>>>> > > > we set different Policy to test them.
>>>> > > >
>>>> > >
>>>> > > You ought to be using RFC6265 policy either in strict or relaxed
>>>> mode
>>>> > > and nothing else. All other policies have been marked as obsolete
>>>> and
>>>> > > have already been removed in 5.0 (trunk).
>>>> > >
>>>> > > Oleg
>>>> > >
>>>> > >
>>>> > >
>>>> ---------------------------------------------------------------------
>>>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>>> > > For additional commands, e-mail:
>>>> httpclient-users-help@hc.apache.org
>>>> > >
>>>> > >
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>>
>>>>
>>>
>>>
>>> --
>>> Cordialement.
>>> Philippe Mouawad.
>>>
>>>
>>>
>>
>>
>> --
>> Cordialement.
>> Philippe Mouawad.
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a Test
case in it to show issue with Domain starting with ".".


Regards

On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi Oleg,
> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
> issue with Cookie Header ordering.
>
> Regards
>
> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
>
>> Hi,
>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with
>> JUnit test case so that you understand the difference we have.
>>
>> Regards
>>
>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>>
>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>> > Thanks Oleg.
>>> > But look at
>>> >
>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>> ,
>>> > it concerns IGNORE_POLICY
>>> >
>>> > I really think there is at least one bug.
>>> > Regards
>>> >
>>>
>>> Sure thing. All these issues may well be due to bugs in HC. Could you
>>> please though reproduce them with unit tests that do not involve JMeter
>>> specific code?
>>>
>>> Oleg
>>>
>>>
>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
>>> wrote:
>>> >
>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>> > > > Hi Oleg,
>>> > > > Thanks for answer.
>>> > > >
>>> > > > Find my answers inline.
>>> > > > Regards
>>> > > >
>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>> olegk@apache.org>
>>> > > wrote:
>>> > > >
>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>>> > > > > > Hello,
>>> > > > > > Any answer on this question ?
>>> > > > > > Thanks
>>> > > > > > Regards
>>> > > > > >
>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>> > > > > > philippe.mouawad@gmail.com> wrote:
>>> > > > > >
>>> > > > > > > Hello,
>>> > > > > > > We're in the process of migrating JMeter to last HttpClient
>>> 4.5.1.
>>> > > > > > >
>>> > > > > > > We are now migrating the CookieManager to remove all
>>> deprecated
>>> > > code.
>>> > > > > > > To test this class, we had a JUNIT class :
>>> > > > > > >
>>> > > > > > >
>>> > > > >
>>> > >
>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>> > > > > > >
>>> > > > > > > Before migration, it was still testing HC3 version.
>>> > > > > > > So we first switched to HC4.23 and noticed some failures:
>>> > > > > > >
>>> > > > >
>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>> > > >
>>> > > >
>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>>> Implementation
>>> > > of
>>> > > > CookieHandler and used 4.2.3, we got some failures compared to HC3.
>>> > > >
>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures
>>> all
>>> > > > detailed in initial mail.
>>> > > >
>>> > > >
>>> > > > What policy does
>>> > > > > CookeManager use internally?
>>> > > > >
>>> > > > It depends on tests, you can see in the code that depending on test
>>> > > method
>>> > > > we set different Policy to test them.
>>> > > >
>>> > >
>>> > > You ought to be using RFC6265 policy either in strict or relaxed mode
>>> > > and nothing else. All other policies have been marked as obsolete and
>>> > > have already been removed in 5.0 (trunk).
>>> > >
>>> > > Oleg
>>> > >
>>> > >
>>> > > ---------------------------------------------------------------------
>>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>> > >
>>> > >
>>> >
>>> >
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>>>
>>
>>
>> --
>> Cordialement.
>> Philippe Mouawad.
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 with a Test
case in it to show issue with Domain starting with ".".


Regards

On Sun, Dec 13, 2015 at 9:50 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi Oleg,
> Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show
> issue with Cookie Header ordering.
>
> Regards
>
> On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
>
>> Hi,
>>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with
>> JUnit test case so that you understand the difference we have.
>>
>> Regards
>>
>> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>>
>>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>>> > Thanks Oleg.
>>> > But look at
>>> >
>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>>> ,
>>> > it concerns IGNORE_POLICY
>>> >
>>> > I really think there is at least one bug.
>>> > Regards
>>> >
>>>
>>> Sure thing. All these issues may well be due to bugs in HC. Could you
>>> please though reproduce them with unit tests that do not involve JMeter
>>> specific code?
>>>
>>> Oleg
>>>
>>>
>>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
>>> wrote:
>>> >
>>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>>> > > > Hi Oleg,
>>> > > > Thanks for answer.
>>> > > >
>>> > > > Find my answers inline.
>>> > > > Regards
>>> > > >
>>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <
>>> olegk@apache.org>
>>> > > wrote:
>>> > > >
>>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>>> > > > > > Hello,
>>> > > > > > Any answer on this question ?
>>> > > > > > Thanks
>>> > > > > > Regards
>>> > > > > >
>>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>>> > > > > > philippe.mouawad@gmail.com> wrote:
>>> > > > > >
>>> > > > > > > Hello,
>>> > > > > > > We're in the process of migrating JMeter to last HttpClient
>>> 4.5.1.
>>> > > > > > >
>>> > > > > > > We are now migrating the CookieManager to remove all
>>> deprecated
>>> > > code.
>>> > > > > > > To test this class, we had a JUNIT class :
>>> > > > > > >
>>> > > > > > >
>>> > > > >
>>> > >
>>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>>> > > > > > >
>>> > > > > > > Before migration, it was still testing HC3 version.
>>> > > > > > > So we first switched to HC4.23 and noticed some failures:
>>> > > > > > >
>>> > > > >
>>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>>> > > >
>>> > > >
>>> > > > As I wrote, first we switched our JUnit tests to use HC4
>>> Implementation
>>> > > of
>>> > > > CookieHandler and used 4.2.3, we got some failures compared to HC3.
>>> > > >
>>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures
>>> all
>>> > > > detailed in initial mail.
>>> > > >
>>> > > >
>>> > > > What policy does
>>> > > > > CookeManager use internally?
>>> > > > >
>>> > > > It depends on tests, you can see in the code that depending on test
>>> > > method
>>> > > > we set different Policy to test them.
>>> > > >
>>> > >
>>> > > You ought to be using RFC6265 policy either in strict or relaxed mode
>>> > > and nothing else. All other policies have been marked as obsolete and
>>> > > have already been removed in 5.0 (trunk).
>>> > >
>>> > > Oleg
>>> > >
>>> > >
>>> > > ---------------------------------------------------------------------
>>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>> > >
>>> > >
>>> >
>>> >
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>>>
>>
>>
>> --
>> Cordialement.
>> Philippe Mouawad.
>>
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show issue
with Cookie Header ordering.

Regards

On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi,
>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with
> JUnit test case so that you understand the difference we have.
>
> Regards
>
> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>> > Thanks Oleg.
>> > But look at
>> >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>> ,
>> > it concerns IGNORE_POLICY
>> >
>> > I really think there is at least one bug.
>> > Regards
>> >
>>
>> Sure thing. All these issues may well be due to bugs in HC. Could you
>> please though reproduce them with unit tests that do not involve JMeter
>> specific code?
>>
>> Oleg
>>
>>
>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>> >
>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>> > > > Hi Oleg,
>> > > > Thanks for answer.
>> > > >
>> > > > Find my answers inline.
>> > > > Regards
>> > > >
>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <olegk@apache.org
>> >
>> > > wrote:
>> > > >
>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>> > > > > > Hello,
>> > > > > > Any answer on this question ?
>> > > > > > Thanks
>> > > > > > Regards
>> > > > > >
>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>> > > > > > philippe.mouawad@gmail.com> wrote:
>> > > > > >
>> > > > > > > Hello,
>> > > > > > > We're in the process of migrating JMeter to last HttpClient
>> 4.5.1.
>> > > > > > >
>> > > > > > > We are now migrating the CookieManager to remove all
>> deprecated
>> > > code.
>> > > > > > > To test this class, we had a JUNIT class :
>> > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>> > > > > > >
>> > > > > > > Before migration, it was still testing HC3 version.
>> > > > > > > So we first switched to HC4.23 and noticed some failures:
>> > > > > > >
>> > > > >
>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>> > > >
>> > > >
>> > > > As I wrote, first we switched our JUnit tests to use HC4
>> Implementation
>> > > of
>> > > > CookieHandler and used 4.2.3, we got some failures compared to HC3.
>> > > >
>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures
>> all
>> > > > detailed in initial mail.
>> > > >
>> > > >
>> > > > What policy does
>> > > > > CookeManager use internally?
>> > > > >
>> > > > It depends on tests, you can see in the code that depending on test
>> > > method
>> > > > we set different Policy to test them.
>> > > >
>> > >
>> > > You ought to be using RFC6265 policy either in strict or relaxed mode
>> > > and nothing else. All other policies have been marked as obsolete and
>> > > have already been removed in 5.0 (trunk).
>> > >
>> > > Oleg
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> > >
>> > >
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
Created https://issues.apache.org/jira/browse/HTTPCLIENT-1705 to show issue
with Cookie Header ordering.

Regards

On Sun, Dec 13, 2015 at 9:30 PM, Philippe Mouawad <
philippe.mouawad@gmail.com> wrote:

> Hi,
>  I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with
> JUnit test case so that you understand the difference we have.
>
> Regards
>
> On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
>
>> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
>> > Thanks Oleg.
>> > But look at
>> >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
>> ,
>> > it concerns IGNORE_POLICY
>> >
>> > I really think there is at least one bug.
>> > Regards
>> >
>>
>> Sure thing. All these issues may well be due to bugs in HC. Could you
>> please though reproduce them with unit tests that do not involve JMeter
>> specific code?
>>
>> Oleg
>>
>>
>> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>> >
>> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
>> > > > Hi Oleg,
>> > > > Thanks for answer.
>> > > >
>> > > > Find my answers inline.
>> > > > Regards
>> > > >
>> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <olegk@apache.org
>> >
>> > > wrote:
>> > > >
>> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
>> > > > > > Hello,
>> > > > > > Any answer on this question ?
>> > > > > > Thanks
>> > > > > > Regards
>> > > > > >
>> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
>> > > > > > philippe.mouawad@gmail.com> wrote:
>> > > > > >
>> > > > > > > Hello,
>> > > > > > > We're in the process of migrating JMeter to last HttpClient
>> 4.5.1.
>> > > > > > >
>> > > > > > > We are now migrating the CookieManager to remove all
>> deprecated
>> > > code.
>> > > > > > > To test this class, we had a JUNIT class :
>> > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
>> > > > > > >
>> > > > > > > Before migration, it was still testing HC3 version.
>> > > > > > > So we first switched to HC4.23 and noticed some failures:
>> > > > > > >
>> > > > >
>> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
>> > > >
>> > > >
>> > > > As I wrote, first we switched our JUnit tests to use HC4
>> Implementation
>> > > of
>> > > > CookieHandler and used 4.2.3, we got some failures compared to HC3.
>> > > >
>> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures
>> all
>> > > > detailed in initial mail.
>> > > >
>> > > >
>> > > > What policy does
>> > > > > CookeManager use internally?
>> > > > >
>> > > > It depends on tests, you can see in the code that depending on test
>> > > method
>> > > > we set different Policy to test them.
>> > > >
>> > >
>> > > You ought to be using RFC6265 policy either in strict or relaxed mode
>> > > and nothing else. All other policies have been marked as obsolete and
>> > > have already been removed in 5.0 (trunk).
>> > >
>> > > Oleg
>> > >
>> > >
>> > > ---------------------------------------------------------------------
>> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> > >
>> > >
>> >
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>
>
> --
> Cordialement.
> Philippe Mouawad.
>
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
 I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with JUnit
test case so that you understand the difference we have.

Regards

On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > Thanks Oleg.
> > But look at
> >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> ,
> > it concerns IGNORE_POLICY
> >
> > I really think there is at least one bug.
> > Regards
> >
>
> Sure thing. All these issues may well be due to bugs in HC. Could you
> please though reproduce them with unit tests that do not involve JMeter
> specific code?
>
> Oleg
>
>
> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > > > Hi Oleg,
> > > > Thanks for answer.
> > > >
> > > > Find my answers inline.
> > > > Regards
> > > >
> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <ol...@apache.org>
> > > wrote:
> > > >
> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > > > > > Hello,
> > > > > > Any answer on this question ?
> > > > > > Thanks
> > > > > > Regards
> > > > > >
> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > > > > philippe.mouawad@gmail.com> wrote:
> > > > > >
> > > > > > > Hello,
> > > > > > > We're in the process of migrating JMeter to last HttpClient
> 4.5.1.
> > > > > > >
> > > > > > > We are now migrating the CookieManager to remove all deprecated
> > > code.
> > > > > > > To test this class, we had a JUNIT class :
> > > > > > >
> > > > > > >
> > > > >
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > > > > >
> > > > > > > Before migration, it was still testing HC3 version.
> > > > > > > So we first switched to HC4.23 and noticed some failures:
> > > > > > >
> > > > >
> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > > >
> > > >
> > > > As I wrote, first we switched our JUnit tests to use HC4
> Implementation
> > > of
> > > > CookieHandler and used 4.2.3, we got some failures compared to HC3.
> > > >
> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures all
> > > > detailed in initial mail.
> > > >
> > > >
> > > > What policy does
> > > > > CookeManager use internally?
> > > > >
> > > > It depends on tests, you can see in the code that depending on test
> > > method
> > > > we set different Policy to test them.
> > > >
> > >
> > > You ought to be using RFC6265 policy either in strict or relaxed mode
> > > and nothing else. All other policies have been marked as obsolete and
> > > have already been removed in 5.0 (trunk).
> > >
> > > Oleg
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> > >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi,
 I created https://issues.apache.org/jira/browse/HTTPCLIENT-1704 with JUnit
test case so that you understand the difference we have.

Regards

On Sat, Dec 5, 2015 at 1:26 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> > Thanks Oleg.
> > But look at
> >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368
> ,
> > it concerns IGNORE_POLICY
> >
> > I really think there is at least one bug.
> > Regards
> >
>
> Sure thing. All these issues may well be due to bugs in HC. Could you
> please though reproduce them with unit tests that do not involve JMeter
> specific code?
>
> Oleg
>
>
> > On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > > > Hi Oleg,
> > > > Thanks for answer.
> > > >
> > > > Find my answers inline.
> > > > Regards
> > > >
> > > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <ol...@apache.org>
> > > wrote:
> > > >
> > > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > > > > > Hello,
> > > > > > Any answer on this question ?
> > > > > > Thanks
> > > > > > Regards
> > > > > >
> > > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > > > > philippe.mouawad@gmail.com> wrote:
> > > > > >
> > > > > > > Hello,
> > > > > > > We're in the process of migrating JMeter to last HttpClient
> 4.5.1.
> > > > > > >
> > > > > > > We are now migrating the CookieManager to remove all deprecated
> > > code.
> > > > > > > To test this class, we had a JUNIT class :
> > > > > > >
> > > > > > >
> > > > >
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > > > > >
> > > > > > > Before migration, it was still testing HC3 version.
> > > > > > > So we first switched to HC4.23 and noticed some failures:
> > > > > > >
> > > > >
> > > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > > >
> > > >
> > > > As I wrote, first we switched our JUnit tests to use HC4
> Implementation
> > > of
> > > > CookieHandler and used 4.2.3, we got some failures compared to HC3.
> > > >
> > > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures all
> > > > detailed in initial mail.
> > > >
> > > >
> > > > What policy does
> > > > > CookeManager use internally?
> > > > >
> > > > It depends on tests, you can see in the code that depending on test
> > > method
> > > > we set different Policy to test them.
> > > >
> > >
> > > You ought to be using RFC6265 policy either in strict or relaxed mode
> > > and nothing else. All other policies have been marked as obsolete and
> > > have already been removed in 5.0 (trunk).
> > >
> > > Oleg
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> > >
> > >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2015-12-04 at 21:43 +0100, Philippe Mouawad wrote:
> Thanks Oleg.
> But look at
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368,
> it concerns IGNORE_POLICY
> 
> I really think there is at least one bug.
> Regards
> 

Sure thing. All these issues may well be due to bugs in HC. Could you
please though reproduce them with unit tests that do not involve JMeter
specific code?

Oleg


> On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > > Hi Oleg,
> > > Thanks for answer.
> > >
> > > Find my answers inline.
> > > Regards
> > >
> > > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <ol...@apache.org>
> > wrote:
> > >
> > > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > > > > Hello,
> > > > > Any answer on this question ?
> > > > > Thanks
> > > > > Regards
> > > > >
> > > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > > > philippe.mouawad@gmail.com> wrote:
> > > > >
> > > > > > Hello,
> > > > > > We're in the process of migrating JMeter to last HttpClient 4.5.1.
> > > > > >
> > > > > > We are now migrating the CookieManager to remove all deprecated
> > code.
> > > > > > To test this class, we had a JUNIT class :
> > > > > >
> > > > > >
> > > >
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > > > >
> > > > > > Before migration, it was still testing HC3 version.
> > > > > > So we first switched to HC4.23 and noticed some failures:
> > > > > >
> > > >
> > > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> > >
> > >
> > > As I wrote, first we switched our JUnit tests to use HC4 Implementation
> > of
> > > CookieHandler and used 4.2.3, we got some failures compared to HC3.
> > >
> > > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures all
> > > detailed in initial mail.
> > >
> > >
> > > What policy does
> > > > CookeManager use internally?
> > > >
> > > It depends on tests, you can see in the code that depending on test
> > method
> > > we set different Policy to test them.
> > >
> >
> > You ought to be using RFC6265 policy either in strict or relaxed mode
> > and nothing else. All other policies have been marked as obsolete and
> > have already been removed in 5.0 (trunk).
> >
> > Oleg
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
> >
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Thanks Oleg.
But look at
https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java#L368,
it concerns IGNORE_POLICY

I really think there is at least one bug.
Regards

On Wed, Dec 2, 2015 at 4:00 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> > Hi Oleg,
> > Thanks for answer.
> >
> > Find my answers inline.
> > Regards
> >
> > On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> >
> > > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > > > Hello,
> > > > Any answer on this question ?
> > > > Thanks
> > > > Regards
> > > >
> > > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > > philippe.mouawad@gmail.com> wrote:
> > > >
> > > > > Hello,
> > > > > We're in the process of migrating JMeter to last HttpClient 4.5.1.
> > > > >
> > > > > We are now migrating the CookieManager to remove all deprecated
> code.
> > > > > To test this class, we had a JUNIT class :
> > > > >
> > > > >
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > > >
> > > > > Before migration, it was still testing HC3 version.
> > > > > So we first switched to HC4.23 and noticed some failures:
> > > > >
> > >
> > > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> >
> >
> > As I wrote, first we switched our JUnit tests to use HC4 Implementation
> of
> > CookieHandler and used 4.2.3, we got some failures compared to HC3.
> >
> > Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures all
> > detailed in initial mail.
> >
> >
> > What policy does
> > > CookeManager use internally?
> > >
> > It depends on tests, you can see in the code that depending on test
> method
> > we set different Policy to test them.
> >
>
> You ought to be using RFC6265 policy either in strict or relaxed mode
> and nothing else. All other policies have been marked as obsolete and
> have already been removed in 5.0 (trunk).
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>


-- 
Cordialement.
Philippe Mouawad.

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2015-12-02 at 15:51 +0100, Philippe Mouawad wrote:
> Hi Oleg,
> Thanks for answer.
> 
> Find my answers inline.
> Regards
> 
> On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> 
> > On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > > Hello,
> > > Any answer on this question ?
> > > Thanks
> > > Regards
> > >
> > > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > > philippe.mouawad@gmail.com> wrote:
> > >
> > > > Hello,
> > > > We're in the process of migrating JMeter to last HttpClient 4.5.1.
> > > >
> > > > We are now migrating the CookieManager to remove all deprecated code.
> > > > To test this class, we had a JUNIT class :
> > > >
> > > >
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > > >
> > > > Before migration, it was still testing HC3 version.
> > > > So we first switched to HC4.23 and noticed some failures:
> > > >
> >
> > I am confused. Are you using HC 4.2.3 or HC 4.5.1?
> 
> 
> As I wrote, first we switched our JUnit tests to use HC4 Implementation of
> CookieHandler and used 4.2.3, we got some failures compared to HC3.
> 
> Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures all
> detailed in initial mail.
> 
> 
> What policy does
> > CookeManager use internally?
> >
> It depends on tests, you can see in the code that depending on test method
> we set different Policy to test them.
> 

You ought to be using RFC6265 policy either in strict or relaxed mode
and nothing else. All other policies have been marked as obsolete and
have already been removed in 5.0 (trunk).

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Philippe Mouawad <ph...@gmail.com>.
Hi Oleg,
Thanks for answer.

Find my answers inline.
Regards

On Wed, Dec 2, 2015 at 3:36 PM, Oleg Kalnichevski <ol...@apache.org> wrote:

> On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> > Hello,
> > Any answer on this question ?
> > Thanks
> > Regards
> >
> > On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> > philippe.mouawad@gmail.com> wrote:
> >
> > > Hello,
> > > We're in the process of migrating JMeter to last HttpClient 4.5.1.
> > >
> > > We are now migrating the CookieManager to remove all deprecated code.
> > > To test this class, we had a JUNIT class :
> > >
> > >
> https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> > >
> > > Before migration, it was still testing HC3 version.
> > > So we first switched to HC4.23 and noticed some failures:
> > >
>
> I am confused. Are you using HC 4.2.3 or HC 4.5.1?


As I wrote, first we switched our JUnit tests to use HC4 Implementation of
CookieHandler and used 4.2.3, we got some failures compared to HC3.

Then we switched from HC 4.2.3 to HC 4.5.1 and got other failures all
detailed in initial mail.


What policy does
> CookeManager use internally?
>
It depends on tests, you can see in the code that depending on test method
we set different Policy to test them.

>
> HC 3.1 cookie support was probably never even remotely compliant with
> reasonably up to date HTTP state management specs.
>
I am aware of this.
But I think there are possibly issues as reported in initial mail.
I think some of the failing tests are outdated (but not all).


> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
Regards

Re: Issues when upgrading from 3 to 4.2.6 or 4.5.1

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2015-12-01 at 22:09 +0100, Philippe Mouawad wrote:
> Hello,
> Any answer on this question ?
> Thanks
> Regards
> 
> On Sun, Nov 15, 2015 at 8:39 PM, Philippe Mouawad <
> philippe.mouawad@gmail.com> wrote:
> 
> > Hello,
> > We're in the process of migrating JMeter to last HttpClient 4.5.1.
> >
> > We are now migrating the CookieManager to remove all deprecated code.
> > To test this class, we had a JUNIT class :
> >
> > https://github.com/ubikloadpack/jmeter/blob/HC4_5/test/src/org/apache/jmeter/protocol/http/control/TestCookieManager.java
> >
> > Before migration, it was still testing HC3 version.
> > So we first switched to HC4.23 and noticed some failures:
> >

I am confused. Are you using HC 4.2.3 or HC 4.5.1? What policy does
CookeManager use internally? 

HC 3.1 cookie support was probably never even remotely compliant with
reasonably up to date HTTP state management specs.

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org