diff --git a/api/src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java b/api/src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java index 59691c06af..6d417cf934 100644 --- a/api/src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java +++ b/api/src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java @@ -505,7 +505,7 @@ public static String parseCharset(String contentType) { public static Cookie parseCookie(String value) { String[] fields = value.split(";\\s*"); - String[] cookie = fields[0].split("="); + String[] cookie = fields[0].split("=", 2); String cookieName = cookie[0]; String cookieValue = (cookie.length == 1) ? null : cookie[1]; diff --git a/api/src/test/java/com/ning/http/util/TestAsyncHttpProviderUtils.java b/api/src/test/java/com/ning/http/util/TestAsyncHttpProviderUtils.java new file mode 100644 index 0000000000..e2bab0876f --- /dev/null +++ b/api/src/test/java/com/ning/http/util/TestAsyncHttpProviderUtils.java @@ -0,0 +1,33 @@ +/* + * Copyright 2010 Ning, Inc. + * + * Ning 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. + */ +package com.ning.http.util; + +import com.ning.http.client.Cookie; +import org.testng.Assert; +import org.testng.annotations.Test; + +public class TestAsyncHttpProviderUtils +{ + @Test(groups="fast") + public void testCookieParsing() + { + String cookieValue = "ID=a3be7f468f2a528c:FF=0:TM=1397369269:LM=134759269:S=XZQK3o8HJ1mytzgz"; + String testCookie = "PREF=" + cookieValue + "; expires=Thu, 11-Sep-2013 13:14:29 GMT; path=/; domain=.google.co.uk"; + Cookie cookie = AsyncHttpProviderUtils.parseCookie(testCookie); + + Assert.assertEquals(cookie.getValue(), cookieValue); + } +}