MCPcopy Index your code
hub / github.com/cSploit/android / run

Method run

cSploit/src/org/csploit/android/net/RemoteReader.java:354–435  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

352 }
353
354 public void run() {
355 URLConnection connection = null;
356 Task task = null;
357 boolean isError;
358 InputStream stream;
359 Notifier notifier;
360 URL url;
361
362 running = true;
363
364 Thread.currentThread().setName("RemoteReader[" + host + "]");
365
366 Logger.debug("RemoteReader[" + host +"] started");
367
368 while(running) {
369
370 try {
371 synchronized (tasks) {
372 while(running && (task = tasks.poll()) == null) {
373 tasks.wait();
374 }
375 }
376 } catch (InterruptedException e) {
377 Logger.warning("RemoteReader[" + host +"] interrupted");
378 break;
379 }
380
381 if(task == null) break;
382
383 isError = false;
384 notifier = null;
385 stream = null;
386
387 try {
388 url = new URL(task.getUrl());
389 } catch (MalformedURLException e) {
390 notifiers.execute(new Notifier(task, ("Bad URL: " + task.getUrl()).getBytes(), true));
391 continue;
392 }
393
394 if(!url.getHost().equals(host)) {
395 Logger.error(String.format("RemoteReader[%s]: URL '%s' does not belong to me", host, task.getUrl()));
396 notifiers.execute(new Notifier(task, "Host mismatch".getBytes(), true));
397 continue;
398 }
399
400 Logger.info("fetching '" + url.toString() + "'");
401
402 try {
403 connection = url.openConnection();
404 stream = connection.getInputStream();
405 } catch (IOException e) {
406 if (connection != null && connection instanceof HttpURLConnection) {
407 stream = ((HttpURLConnection) connection).getErrorStream();
408 isError = true;
409 } else {
410 notifier = new Notifier(task, e.getMessage().getBytes(), true);
411 }

Callers

nothing calls this directly

Calls 13

debugMethod · 0.95
warningMethod · 0.95
getUrlMethod · 0.95
errorMethod · 0.95
infoMethod · 0.95
waitMethod · 0.80
getHostMethod · 0.80
formatMethod · 0.80
toByteArrayMethod · 0.80
removeMethod · 0.80
setNameMethod · 0.45
equalsMethod · 0.45

Tested by

no test coverage detected