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

15
LINES

< > BotCompany Repo | #1031399 // returnCodeHttpHEADWithTimeout_passOnExceptions

JavaX fragment (include)

1  
static int returnCodeHttpHEADWithTimeout_passOnExceptions(int timeout, String url) ctex {
2  
  url = absoluteURL(url);
3  
  HttpURLConnection conn = null;
4  
  InputStream in = null;
5  
  try {
6  
    conn = (HttpURLConnection) new URL(url).openConnection();
7  
    setURLConnectionTimeouts(conn, timeout);
8  
    conn.setRequestMethod("HEAD");
9  
    conn.setRequestProperty("X-No-Cookies", "1");
10  
    in = conn.getInputStream();
11  
    ret conn.getResponseCode();
12  
  } finally {
13  
    closeURLConnection(conn, in);
14  
  }
15  
}

Author comment

Began life as a copy of #1018970

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031399
Snippet name: returnCodeHttpHEADWithTimeout_passOnExceptions
Eternal ID of this version: #1031399/3
Text MD5: 676274adf92a35b10ef16f925100ec74
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-10 16:27:12
Source code size: 507 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 134 / 166
Version history: 2 change(s)
Referenced in: [show references]