diff --git a/src/test/java/org/jsoup/integration/ConnectTest.java b/src/test/java/org/jsoup/integration/ConnectTest.java index edc5c3f115..95f6e325f9 100644 --- a/src/test/java/org/jsoup/integration/ConnectTest.java +++ b/src/test/java/org/jsoup/integration/ConnectTest.java @@ -313,7 +313,11 @@ public void postFiles() throws IOException { @Test public void multiCookieSet() throws IOException { - Connection con = Jsoup.connect("http://direct.infohound.net/tools/302-cookie.pl"); + Connection con = Jsoup + .connect(RedirectServlet.Url) + .data(RedirectServlet.CodeParam, "302") + .data(RedirectServlet.SetCookiesParam, "true") + .data(RedirectServlet.LocationParam, echoUrl); Connection.Response res = con.execute(); // test cookies set by redirect: diff --git a/src/test/java/org/jsoup/integration/servlets/RedirectServlet.java b/src/test/java/org/jsoup/integration/servlets/RedirectServlet.java index 8431347750..a6784c4853 100644 --- a/src/test/java/org/jsoup/integration/servlets/RedirectServlet.java +++ b/src/test/java/org/jsoup/integration/servlets/RedirectServlet.java @@ -3,6 +3,7 @@ import org.jsoup.integration.TestServer; import javax.servlet.ServletException; +import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -11,6 +12,7 @@ public class RedirectServlet extends BaseServlet { public static final String Url = TestServer.map(RedirectServlet.class); public static final String LocationParam = "loc"; public static final String CodeParam = "code"; + public static final String SetCookiesParam = "setCookies"; private static final int DefaultCode = HttpServletResponse.SC_MOVED_TEMPORARILY; @Override @@ -24,6 +26,11 @@ protected void doGet(HttpServletRequest req, HttpServletResponse res) throws IOE if (code != null) intCode = Integer.parseInt(code); + if (req.getParameter(SetCookiesParam) != null) { + res.addCookie(new Cookie("token", "asdfg123")); + res.addCookie(new Cookie("uid", "jhy")); + } + res.setHeader("Location", location); res.setStatus(intCode); }