Example usage for org.apache.http.cookie CookieOrigin getPath

List of usage examples for org.apache.http.cookie CookieOrigin getPath

Introduction

In this page you can find the example usage for org.apache.http.cookie CookieOrigin getPath.

Prototype

public String getPath() 

Source Link

Usage

From source file:com.gargoylesoftware.htmlunit.httpclient.HtmlUnitPathHandler.java

@Override
public boolean match(final Cookie cookie, final CookieOrigin origin) {
    CookieOrigin newOrigin = origin;/*  w  w  w.j ava  2s. com*/
    String targetpath = origin.getPath();
    if (browserVersion_.hasFeature(HTTP_COOKIE_EXTRACT_PATH_FROM_LOCATION) && !targetpath.isEmpty()) {
        final int lastSlashPos = targetpath.lastIndexOf('/');
        if (lastSlashPos > 1 && lastSlashPos < targetpath.length()) {
            targetpath = targetpath.substring(0, lastSlashPos);
            newOrigin = new CookieOrigin(origin.getHost(), origin.getPort(), targetpath, origin.isSecure());
        }
    }

    return super.match(cookie, newOrigin);
}