protected Cookie[] parse(final HeaderElement[] elems, final CookieOrigin origin)
throws MalformedCookieException {
Cookie[] cookies = new Cookie[elems.length];
for (int i = 0; i < elems.length; i++) {
HeaderElement headerelement = elems[i];
String name = headerelement.getName();
String value = headerelement.getValue();
if (name == null || name.equals("")) {
throw new MalformedCookieException("Cookie name may not be empty");
}
Cookie cookie = new Cookie(name, value);
cookie.setPath(getDefaultPath(origin));
cookie.setDomain(getDefaultDomain(origin));
// cycle through the parameters
NameValuePair[] attribs = headerelement.getParameters();
for (int j = attribs.length - 1; j >= 0; j--) {
NameValuePair attrib = attribs[j];
String s = attrib.getName().toLowerCase();
CookieAttributeHandler handler = findAttribHandler(s);
if (handler != null) {