Skip to content

Commit 09a14cd

Browse files
committed
Merge pull request AsyncHttpClient#138 from elFarto/master
Fixed bug with cookie handling
2 parents f258370 + 9af5921 commit 09a14cd

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

api/src/main/java/com/ning/http/util/AsyncHttpProviderUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ public static String parseCharset(String contentType) {
505505

506506
public static Cookie parseCookie(String value) {
507507
String[] fields = value.split(";\\s*");
508-
String[] cookie = fields[0].split("=");
508+
String[] cookie = fields[0].split("=", 2);
509509
String cookieName = cookie[0];
510510
String cookieValue = (cookie.length == 1) ? null : cookie[1];
511511

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2010 Ning, Inc.
3+
*
4+
* Ning licenses this file to you under the Apache License, version 2.0
5+
* (the "License"); you may not use this file except in compliance with the
6+
* License. You may obtain a copy of the License at:
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
package com.ning.http.util;
17+
18+
import com.ning.http.client.Cookie;
19+
import org.testng.Assert;
20+
import org.testng.annotations.Test;
21+
22+
public class TestAsyncHttpProviderUtils
23+
{
24+
@Test(groups="fast")
25+
public void testCookieParsing()
26+
{
27+
String cookieValue = "ID=a3be7f468f2a528c:FF=0:TM=1397369269:LM=134759269:S=XZQK3o8HJ1mytzgz";
28+
String testCookie = "PREF=" + cookieValue + "; expires=Thu, 11-Sep-2013 13:14:29 GMT; path=/; domain=.google.co.uk";
29+
Cookie cookie = AsyncHttpProviderUtils.parseCookie(testCookie);
30+
31+
Assert.assertEquals(cookie.getValue(), cookieValue);
32+
}
33+
}

0 commit comments

Comments
 (0)