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

17
LINES

< > BotCompany Repo | #1012490 // urlExists

JavaX fragment (include)

1  
// retrieves url with HEAD
2  
static bool urlExists(S url) {
3  
  url = absoluteURL(url);
4  
  HttpURLConnection conn = null;
5  
  InputStream in = null;
6  
  try {
7  
    conn = (HttpURLConnection) new URL(url).openConnection();
8  
    conn.setRequestMethod("HEAD");
9  
    conn.setRequestProperty("X-No-Cookies", "1");
10  
    in = conn.getInputStream();
11  
    true;
12  
  } catch (IOException e) {
13  
    false;
14  
  } finally {
15  
    closeURLConnection(conn, in);
16  
  }
17  
}

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: 454 / 462
Referenced in: [show references]