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

17
LINES

< > BotCompany Repo | #1018964 // returnCodeHttpHEAD

JavaX fragment (include)

// -1 in case of error
static int returnCodeHttpHEAD(String 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();
    ret conn.getResponseCode();
  } catch (IOException e) {
    ret -1;
  } 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, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018964
Snippet name: returnCodeHttpHEAD
Eternal ID of this version: #1018964/3
Text MD5: 8b25c75ee6117fb553569832204b43cd
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-18 16:12:33
Source code size: 481 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 348 / 367
Version history: 2 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1018965 - returnCodesOfMultipleServers
#1018970 - returnCodeHttpHEADWithTimeout