MCPcopy Create free account
hub / github.com/M66B/FairEmail / call

Method call

app/src/extra/java/eu/faircode/email/VirusTotal.java:200–232  ·  view source on GitHub ↗
(Context context, String api, String apiKey)

Source from the content-addressed store, hash-verified

198 }
199
200 private static Pair<Integer, String> call(Context context, String api, String apiKey) throws IOException {
201 URL url = new URL(URI_ENDPOINT + api);
202 HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
203 connection.setRequestMethod("GET");
204 connection.setReadTimeout(VT_TIMEOUT * 1000);
205 connection.setConnectTimeout(VT_TIMEOUT * 1000);
206 ConnectionHelper.setUserAgent(context, connection);
207 connection.setRequestProperty("x-apikey", apiKey);
208 connection.setRequestProperty("Accept", "application/json");
209 connection.connect();
210
211 try {
212 int status = connection.getResponseCode();
213 if (status != HttpsURLConnection.HTTP_OK) {
214 String error = "Error " + status + ": " + connection.getResponseMessage();
215 try {
216 InputStream is = connection.getErrorStream();
217 if (is != null)
218 error += "\n" + Helper.readStream(is);
219 } catch (Throwable ex) {
220 Log.w(ex);
221 }
222 return new Pair<>(status, error);
223 }
224
225 String response = Helper.readStream(connection.getInputStream());
226 //Log.i("VT response=" + response);
227 return new Pair<>(status, response);
228
229 } finally {
230 connection.disconnect();
231 }
232 }
233
234 public static class ScanResult implements Parcelable {
235 public String name;

Callers 3

lookupMethod · 0.95
uploadMethod · 0.95
waitForAnalysisMethod · 0.95

Calls 6

setUserAgentMethod · 0.95
readStreamMethod · 0.95
wMethod · 0.95
getInputStreamMethod · 0.65
connectMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected