Example usage for org.apache.commons.httpclient.cookie MalformedCookieException getMessage

List of usage examples for org.apache.commons.httpclient.cookie MalformedCookieException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.cookie MalformedCookieException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:at.spardat.xma.boot.transport.HTTPTransport.java

/**
 *  Parses the cookies from the given connection and stores them in httpState.
 *  Invalid cookies are ignored and logged.
 *//*from  ww w.  j  a v  a 2s . c o m*/
private void readCookies(IRtXMASessionClient session, URL url, HttpURLConnection conn) {
    String headerName = "";
    for (int i = 1; headerName != null; i++) {
        headerName = conn.getHeaderFieldKey(i);
        if (Statics.HTTP_SET_COOKIE.equals(headerName)) {
            try {
                Cookie[] cookies = cookieSpec.parse(url.getHost(), getPort(url), url.getPath(),
                        "https".equals(url.getProtocol()), conn.getHeaderField(i));
                if (cookies != null) {
                    for (int j = 0; j < cookies.length; j++) {
                        try {
                            cookieSpec.validate(url.getHost(), getPort(url), url.getPath(),
                                    "https".equals(url.getProtocol()), cookies[j]);
                            getHttpState(session).addCookie(cookies[j]);
                            if (session != null && "JSESSIONID".equals(cookies[j].getName())) {
                                session.setId(cookies[j].getName() + "=" + cookies[j].getValue());
                            }
                        } catch (MalformedCookieException e) {
                            log_.log(LogLevel.WARNING, "cookie rejected: \""
                                    + cookieSpec.formatCookie(cookies[j]) + "\". " + e.getMessage());
                        }
                    }
                }
            } catch (MalformedCookieException e) {
                log_.log(LogLevel.WARNING,
                        "Invalid cookie header: \"" + conn.getHeaderField(i) + "\". " + e.getMessage());
            }
        }
    }
}