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

17
LINES

< > BotCompany Repo | #1018964 // returnCodeHttpHEAD

JavaX fragment (include)

1  
// -1 in case of error
2  
static int returnCodeHttpHEAD(String 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  
    ret conn.getResponseCode();
12  
  } catch (IOException e) {
13  
    ret -1;
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, 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: 280 / 310
Version history: 2 change(s)
Referenced in: [show references]