Yes Jsoup.connect(url).get()
and Jsoup.connect(url).timeout(10*1000).execute();
are two separate connections. Maybe you are looking for something like
Response resp = Jsoup.connect(url).timeout(10*1000).execute();
String contentType = res.contentType();
and later parse body of response as a Document
Document doc = resp.parse();
Anyway Jsoup by default parses only text/*
, application/xml
, or application/xhtml+xml
and if content type is other, like application/pdf
it will throw UnsupportedMimeTypeException
so you shouldn't be worried about it.