Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1012490 // urlExists

JavaX fragment (include)

// retrieves url with HEAD
static bool urlExists(S url) {
  url = absoluteURL(url);
  HttpURLConnection conn = null;
  InputStream in = null;
  try {
    conn = (HttpURLConnection) new URL(url).openConnection();
    conn.setRequestMethod("HEAD");
    conn.setRequestProperty("X-No-Cookies", "1");
    in = conn.getInputStream();
    true;
  } catch (IOException e) {
    false;
  } finally {
    closeURLConnection(conn, in);
  }
}

Author comment

Began life as a copy of #1002941

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1012490
Snippet name: urlExists
Eternal ID of this version: #1012490/1
Text MD5: 8a5591c8769548411553615236e7f718
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-03 23:45:27
Source code size: 449 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 453 / 460
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)