Advertisement
Guest User

Untitled

a guest
Dec 10th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. static class CookiePathComparator implements Comparator<HttpCookie> {
  2. public int compare(HttpCookie c1, HttpCookie c2) {
  3. if (c1 == c2) return 0;
  4. if (c1 == null) return -1;
  5. if (c2 == null) return 1;
  6.  
  7. // path rule only applies to the cookies with same name
  8. if (!c1.getName().equals(c2.getName())) return 0;
  9.  
  10. // those with more specific Path attributes precede those with less specific
  11. if (c1.getPath().startsWith(c2.getPath()))
  12. return -1;
  13. else if (c2.getPath().startsWith(c1.getPath()))
  14. return 1;
  15. else
  16. return 0;
  17. }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement