List of usage examples for org.apache.commons.httpclient Cookie setComment
public void setComment(String paramString)
From source file:org.apache.cactus.WebResponse.java
/** * @return the cookies returned by the server *///from ww w. j a v a 2 s. c o m public Cookie[] getCookies() { Cookie[] returnCookies = null; // There can be several headers named "Set-Cookie", so loop through // all the headers, looking for cookies String headerName = this.connection.getHeaderFieldKey(0); String headerValue = this.connection.getHeaderField(0); Vector cookieVector = new Vector(); CookieSpec cookieSpec = CookiePolicy.getDefaultSpec(); for (int i = 1; (headerName != null) || (headerValue != null); i++) { LOGGER.debug("Header name = [" + headerName + "]"); LOGGER.debug("Header value = [" + headerValue + "]"); if ((headerName != null) && (headerName.toLowerCase().equals("set-cookie") || headerName.toLowerCase().equals("set-cookie2"))) { // Parse the cookie definition org.apache.commons.httpclient.Cookie[] cookies; try { cookies = cookieSpec.parse( CookieUtil.getCookieDomain(getWebRequest(), getConnection().getURL().getHost()), CookieUtil.getCookiePort(getWebRequest(), getConnection().getURL().getPort()), CookieUtil.getCookiePath(getWebRequest(), getConnection().getURL().getFile()), false, new Header(headerName, headerValue)); } catch (HttpException e) { throw new ChainedRuntimeException("Error parsing cookies", e); } // Transform the HttpClient cookies into Cactus cookies and // add them to the cookieVector vector for (int j = 0; j < cookies.length; j++) { Cookie cookie = new Cookie(cookies[j].getDomain(), cookies[j].getName(), cookies[j].getValue()); cookie.setComment(cookies[j].getComment()); cookie.setExpiryDate(cookies[j].getExpiryDate()); cookie.setPath(cookies[j].getPath()); cookie.setSecure(cookies[j].getSecure()); cookieVector.addElement(cookie); } } headerName = this.connection.getHeaderFieldKey(i); headerValue = this.connection.getHeaderField(i); } returnCookies = new Cookie[cookieVector.size()]; cookieVector.copyInto(returnCookies); return returnCookies; }
From source file:org.mule.transport.http.CookieHelper.java
/** * Transforms a {@link ServerCookie} (from Apache Tomcat) into a {@link Cookie} * (from commons httpclient). Both types of Cookie hold the same data but the * {@link ServerCookie} is the type that you get when parsing cookies as a * Server.//w w w .j av a2 s . c o m */ protected static Cookie transformServerCookieToClientCookie(ServerCookie serverCookie) { Cookie clientCookie = new Cookie(serverCookie.getDomain().toString(), serverCookie.getName().toString(), serverCookie.getValue().toString(), serverCookie.getPath().toString(), serverCookie.getMaxAge(), serverCookie.getSecure()); clientCookie.setComment(serverCookie.getComment().toString()); clientCookie.setVersion(serverCookie.getVersion()); return clientCookie; }