use of de.geeksfactory.opacclient.networking.SSLSecurityException in project opacclient by opacapp.
the class Adis method htmlPost.
public Document htmlPost(String url, List<NameValuePair> data) throws IOException {
HttpPost httppost = new HttpPost(cleanUrl(url));
boolean rcf = false;
for (NameValuePair nv : data) {
if (nv.getName().equals("requestCount")) {
rcf = true;
break;
}
}
if (!rcf) {
data.add(new BasicNameValuePair("requestCount", s_requestCount + ""));
}
httppost.setEntity(new UrlEncodedFormEntity(data, getDefaultEncoding()));
HttpResponse response;
try {
response = http_client.execute(httppost);
} catch (javax.net.ssl.SSLPeerUnverifiedException e) {
throw new SSLSecurityException(e.getMessage());
} catch (javax.net.ssl.SSLException e) {
// aborted/interrupted handshake/connection
if (e.getMessage().contains("timed out") || e.getMessage().contains("reset by")) {
e.printStackTrace();
throw new NotReachableException(e.getMessage());
} else {
throw new SSLSecurityException(e.getMessage());
}
} catch (InterruptedIOException e) {
e.printStackTrace();
throw new NotReachableException(e.getMessage());
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().contains("Request aborted")) {
e.printStackTrace();
throw new NotReachableException(e.getMessage());
} else {
throw e;
}
}
if (response.getStatusLine().getStatusCode() >= 400) {
throw new NotReachableException(response.getStatusLine().getReasonPhrase());
}
String html = convertStreamToString(response.getEntity().getContent(), getDefaultEncoding());
HttpUtils.consume(response.getEntity());
Document doc = Jsoup.parse(html);
Pattern patRequestCount = Pattern.compile(".*requestCount=([0-9]+)[^0-9].*");
for (Element a : doc.select("a")) {
Matcher objid_matcher = patRequestCount.matcher(a.attr("href"));
if (objid_matcher.matches()) {
s_requestCount = Integer.parseInt(objid_matcher.group(1));
}
}
doc.setBaseUri(url);
return doc;
}
use of de.geeksfactory.opacclient.networking.SSLSecurityException in project opacclient by opacapp.
the class Adis method htmlGet.
public Document htmlGet(String url) throws IOException {
if (!url.contains("requestCount") && s_requestCount >= 0) {
url = url + (url.contains("?") ? "&" : "?") + "requestCount=" + s_requestCount;
}
HttpGet httpget = new HttpGet(cleanUrl(url));
HttpResponse response;
try {
response = http_client.execute(httpget);
} catch (javax.net.ssl.SSLPeerUnverifiedException e) {
throw new SSLSecurityException(e.getMessage());
} catch (javax.net.ssl.SSLException e) {
// aborted/interrupted handshake/connection
if (e.getMessage().contains("timed out") || e.getMessage().contains("reset by")) {
e.printStackTrace();
throw new NotReachableException(e.getMessage());
} else {
throw new SSLSecurityException(e.getMessage());
}
} catch (InterruptedIOException e) {
e.printStackTrace();
throw new NotReachableException(e.getMessage());
} catch (IOException e) {
if (e.getMessage() != null && e.getMessage().contains("Request aborted")) {
e.printStackTrace();
throw new NotReachableException(e.getMessage());
} else {
throw e;
}
}
if (response.getStatusLine().getStatusCode() >= 400) {
throw new NotReachableException(response.getStatusLine().getReasonPhrase());
}
String html = convertStreamToString(response.getEntity().getContent(), getDefaultEncoding());
HttpUtils.consume(response.getEntity());
Document doc = Jsoup.parse(html);
Pattern patRequestCount = Pattern.compile("requestCount=([0-9]+)");
for (Element a : doc.select("a")) {
Matcher objid_matcher = patRequestCount.matcher(a.attr("href"));
if (objid_matcher.matches()) {
s_requestCount = Integer.parseInt(objid_matcher.group(1));
}
}
doc.setBaseUri(url);
return doc;
}
Aggregations