junit-servers-core/src/main/java/com/github/mjeanroy/junit/servers/client/Cookies.java
public static Cookie read(String rawValue) {
		notBlank(rawValue, "Cookie value");

		final String[] parts = rawValue.split(FIELD_SEPARATOR);

		// Extract name and value
		final String[] nameAndValue = parts[0].split(NAME_VALUE_SEPARATOR);
		if (nameAndValue.length != 2) {
			throw new IllegalArgumentException("Cookie must have a valid name and a valid value");
		}

		final String name = nameAndValue[0].trim();
		final String value = nameAndValue[1].trim();
		if (name.isEmpty()) {
			throw new IllegalArgumentException("Cookie must have a valid name");
		}

		// Extract other parts
		Map<String, String> params = new HashMap<>();
		if (parts.length > 1) {
			for (String part : parts) {
				String[] param = part.split(NAME_VALUE_SEPARATOR);
				String paramName = param[0].toLowerCase().trim();
				String paramValue = param.length == 2 ? param[1].trim() : "";
				params.put(paramName, paramValue);
			}
		}

		final String domain = params.get("domain");
		final String path = params.get("path");
		final boolean secure = params.containsKey("secure");
		final boolean httpOnly = params.containsKey("httponly");

		final String maxAgeTt = params.get("max-age");
		final String expiresDate = params.get("expires");

		Long expires;
		Long maxAge = maxAgeTt == null ? null : Long.valueOf(maxAgeTt);

		if (expiresDate != null) {
			expires = getTime(expiresDate, "EEE, d MMM yyyy HH:mm:ss Z", "EEE, d-MMM-yyyy HH:mm:ss Z", "EEE, d/MMM/yyyy HH:mm:ss Z");
		}
		else {
			expires = null;
		}

		if (maxAge == null && expires == null) {
			maxAge = 0L;
		}
		else if (maxAge == null) {
			maxAge = expires - System.currentTimeMillis();
		}

		return Cookies.cookie(name, value, domain, path, expires, maxAge, secure, httpOnly);
	}
public static Cookie read(String rawValue) {
		notBlank(rawValue, "Cookie value");

		final String[] parts = rawValue.split(FIELD_SEPARATOR);

		// Extract name and value
		final String[] nameAndValue = parts[0].split(NAME_VALUE_SEPARATOR);
		if (nameAndValue.length != 2) {
			throw new IllegalArgumentException("Cookie must have a valid name and a valid value");
		}

		final String name = nameAndValue[0].trim();
		final String value = nameAndValue[1].trim();
		if (name.isEmpty()) {
			throw new IllegalArgumentException("Cookie must have a valid name");
		}

		// Extract other parts
		Map<String, String> params = new HashMap<>();
		if (parts.length > 1) {
			for (String part : parts) {
				String[] param = part.split(NAME_VALUE_SEPARATOR);
				String paramName = param[0].toLowerCase().trim();
				String paramValue = param.length == 2 ? param[1].trim() : "";
				params.put(paramName, paramValue);
			}
		}

		final String domain = params.get("domain");
		final String path = params.get("path");
		final boolean secure = params.containsKey("secure");
		final boolean httpOnly = params.containsKey("httponly");

		final String maxAgeTt = params.get("max-age");
		final String expiresDate = params.get("expires");

		Long expires;
		Long maxAge = maxAgeTt == null ? null : Long.valueOf(maxAgeTt);

		if (expiresDate != null) {
			expires = getTime(expiresDate, "EEE, d MMM yyyy HH:mm:ss Z", "EEE, d-MMM-yyyy HH:mm:ss Z", "EEE, d/MMM/yyyy HH:mm:ss Z");
		}
		else {
			expires = null;
		}

		if (maxAge == null && expires == null) {
			maxAge = 0L;
		}
		else if (maxAge == null) {
			maxAge = expires - System.currentTimeMillis();
		}

		return Cookies.cookie(name, value, domain, path, expires, maxAge, secure, httpOnly);
	}
Create a cookie from header value.

@param rawValue Header value.
@return Cookie.