1 | // retrieves url with HEAD. returns content length, |
2 | // or -1 in case of error. |
3 | static long getURLSizeByHEAD(String url) {
|
4 | url = absoluteURL(url); |
5 | HttpURLConnection conn = null; |
6 | InputStream in = null; |
7 | try {
|
8 | conn = (HttpURLConnection) new URL(url).openConnection(); |
9 | conn.setRequestMethod("HEAD");
|
10 | conn.setRequestProperty("X-No-Cookies", "1");
|
11 | in = conn.getInputStream(); |
12 | return conn.getContentLength(); |
13 | } catch (IOException e) {
|
14 | return -1; |
15 | } finally {
|
16 | closeURLConnection(conn, in); |
17 | } |
18 | } |
Began life as a copy of #1001555
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: | #1002941 |
| Snippet name: | getURLSizeByHEAD |
| Eternal ID of this version: | #1002941/4 |
| Text MD5: | e1731bf0b583fd8738f63680b6283626 |
| 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:44:45 |
| Source code size: | 544 bytes / 18 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 928 / 902 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |