use of org.jsoup.Connection in project jsoup by jhy.
the class UrlConnectTest method doesGet.
@Test
public void doesGet() throws IOException {
Connection con = Jsoup.connect(echoURL + "?what=the").userAgent("Mozilla").referrer("http://example.com").data("what", "about & me?");
Document doc = con.get();
assertEquals("what=the&what=about+%26+me%3F", ihVal("QUERY_STRING", doc));
assertEquals("the, about & me?", ihVal("what", doc));
assertEquals("Mozilla", ihVal("HTTP_USER_AGENT", doc));
assertEquals("http://example.com", ihVal("HTTP_REFERER", doc));
}
use of org.jsoup.Connection in project jsoup by jhy.
the class UrlConnectTest method followsRelativeRedirect.
@Test
public void followsRelativeRedirect() throws IOException {
// to /tidy/
Connection con = Jsoup.connect("http://direct.infohound.net/tools/302-rel.pl");
Document doc = con.post();
assertTrue(doc.title().contains("HTML Tidy Online"));
}
use of org.jsoup.Connection in project jsoup by jhy.
the class UrlConnectTest method redirectsResponseCookieToNextResponse.
@Test
public void redirectsResponseCookieToNextResponse() throws IOException {
Connection con = Jsoup.connect("http://direct.infohound.net/tools/302-cookie.pl");
Connection.Response res = con.execute();
// confirms that cookies set on 1st hit are presented in final result
assertEquals("asdfg123", res.cookie("token"));
Document doc = res.parse();
// confirms that redirected hit saw cookie
assertEquals("token=asdfg123; uid=jhy", ihVal("HTTP_COOKIE", doc));
}
use of org.jsoup.Connection in project jsoup by jhy.
the class HttpConnectionTest method throwsExceptionOnBodyAsBytesWithoutExecute.
@Test(expected = IllegalArgumentException.class)
public void throwsExceptionOnBodyAsBytesWithoutExecute() throws IOException {
Connection con = HttpConnection.connect("http://example.com");
con.response().bodyAsBytes();
}
use of org.jsoup.Connection in project jsoup by jhy.
the class HttpConnectionTest method connectWithUrl.
@Test
public void connectWithUrl() throws MalformedURLException {
Connection con = HttpConnection.connect(new URL("http://example.com"));
assertEquals("http://example.com", con.request().url().toExternalForm());
}
Aggregations