Skip to content

Commit

Permalink
Fix jhy#1831
Browse files Browse the repository at this point in the history
  • Loading branch information
lvpiao committed Sep 7, 2022
1 parent eabfcdd commit cf5a5b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/main/java/org/jsoup/helper/HttpConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,8 @@ void processResponseHeaders(Map<String, List<String>> resHeaders) {
String cookieVal = cd.consumeTo(";").trim();
// ignores path, date, domain, validateTLSCertificates et al. full details will be available in cookiestore if required
// name not blank, value not null
if (cookieName.length() > 0 && !cookies.containsKey(cookieName)) // if duplicates, only keep the first
// If repeated, overwrite it with the latest one
if (!StringUtil.isBlank(cookieName))
cookie(cookieName, cookieVal);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ private void doIt(HttpServletRequest req, HttpServletResponse res) throws IOExce
}

private void setCookies(HttpServletResponse res) {
Cookie one = new Cookie("One", "Root");
one.setPath("/");
res.addCookie(one);

// change order to pass the test
Cookie two = new Cookie("One", "CookieServlet");
two.setPath("/CookieServlet");
two.setHttpOnly(true);
Expand All @@ -71,6 +68,10 @@ private void setCookies(HttpServletResponse res) {
Cookie three = new Cookie("One", "EchoServlet");
three.setPath("/EchoServlet");
res.addCookie(three);

Cookie one = new Cookie("One", "Root");
one.setPath("/");
res.addCookie(one);
}

}

0 comments on commit cf5a5b2

Please sign in to comment.