private void fetchOne(boolean examine, boolean save, YouAreEll yrl, InputStream is) { logger.entering(examine); logger.entering(save); logger.entering(yrl); if (examine) is = new DelimitedBufferedInputStream(is, '<', '>'); BufferedOutputStream bos = null; WebFile wf = null; if (save) { wf = new WebFile(yrl, args); bos = wf.getBOS(); if (bos == null) save = false; } if (save || examine) { if (!examineORsave(yrl, is, bos, examine, save, yrl.getURL())) { logger.severe("examineORsave failed"); } } if (bos != null) { try { bos.close(); if (args.SetLastModified) wf.getFile().setLastModified(yrl.getLastModified()); } catch (IOException e) { logger.throwing(e); } } if (examine) { try { is.close(); } catch (IOException e) { logger.throwing(e); } } }
private void fetch(String url) { logger.entering(url); boolean Path = args.PathExamine != null || args.PathIgnore != null || args.PathSave != null || args.PathRefuse != null; boolean MIME = args.MIMEExamine != null || args.MIMEIgnore != null || args.MIMESave != null || args.MIMERefuse != null; logger.fine("Path = " + Path); logger.fine("MIME = " + MIME); boolean tb[] = EISR(url, "path", args.PathExamine, args.PathIgnore, args.PathSave, args.PathRefuse); boolean Pexamine = tb[0]; boolean Psave = tb[1]; /* * if there is no MIME, and the Path doesn't say to examine or save, * we're done. */ if (!MIME && !Pexamine && !Psave) return; /* * otherwise, we need to Path examine or save, or we need the MIME * header. in either case, we need an InputStream. */ InputStream is = null; YouAreEll yrl = null; for (int t = 0; t < args.Tries; t++) { yrl = new YouAreEll(url, urls, cookies, args); is = yrl.getInputStream(); if (is != null) break; if (args.Tries > 1) logger.warning("Trying again"); } if (is == null) return; boolean Mexamine = false; boolean Msave = false; if (MIME && yrl.getContentType() != null) { tb = EISR( yrl.getContentType(), "MIME", args.MIMEExamine, args.MIMEIgnore, args.MIMESave, args.MIMERefuse); Mexamine = tb[0]; Msave = tb[1]; } // we've looked at both Path and now MIME and there's nothing to do if (!Pexamine && !Psave && !Mexamine && !Msave) return; fetchOne(Pexamine || Mexamine, Psave || Msave, yrl, is); try { is.close(); } catch (IOException IOE) { logger.throwing(IOE); } }