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

15
LINES

< > BotCompany Repo | #1031399 // returnCodeHttpHEADWithTimeout_passOnExceptions

JavaX fragment (include)

static int returnCodeHttpHEADWithTimeout_passOnExceptions(int timeout, String url) ctex {
  url = absoluteURL(url);
  HttpURLConnection conn = null;
  InputStream in = null;
  try {
    conn = (HttpURLConnection) new URL(url).openConnection();
    setURLConnectionTimeouts(conn, timeout);
    conn.setRequestMethod("HEAD");
    conn.setRequestProperty("X-No-Cookies", "1");
    in = conn.getInputStream();
    ret conn.getResponseCode();
  } finally {
    closeURLConnection(conn, in);
  }
}

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: 69 / 95
Version history: 2 change(s)
Referenced in: [show references]