1 | static InputStream urlConnection_getInputStream(URLConnection con) throws IOException { |
2 | UnknownHostException lastException = null; |
3 | repeat 2 { |
4 | try { |
5 | if (con cast HttpURLConnection) |
6 | if (con.getResponseCode() == 500) |
7 | throw new IOException(joinNemptiesWithColonSpace("Server code 500", tryToReadErrorStreamFromURLConnection(con))); |
8 | ret con.getInputStream(); |
9 | } catch (UnknownHostException e) { |
10 | lastException = e; |
11 | print("Retrying because of: " + e); |
12 | continue; |
13 | } |
14 | } |
15 | throw lastException; |
16 | } |
Began life as a copy of #1022757
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033015 |
Snippet name: | urlConnection_getInputStream - we really don't need this anymore (with DNS retry, drop-in replacement for URLConnection.getInputStream) |
Eternal ID of this version: | #1033015/1 |
Text MD5: | fb89c2ffc066ecd51fa78de0e0f516d9 |
Author: | stefan |
Category: | javax / networking |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-10-11 11:04:54 |
Source code size: | 563 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 132 / 148 |
Referenced in: | [show references] |