Skip to content

Fixed bug with cookie handling #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 5, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}