HTTPResponse createResponse(final HttpURLConnection conn, final String out) throws IOException { final HTTPResponse response = new HTTPResponse(conn.getResponseCode()); final String location = conn.getHeaderField("Location"); if (!StringHelper.isBlank(location)) { response.setLocation(new URL(location)); } try { response.setContentType(conn.getContentType()); } catch (final ParseException e) { throw new IOException("Couldn't parse Content-Type header: " + e.getMessage(), e); } response.setCacheControl(conn.getHeaderField("Cache-Control")); response.setPragma(conn.getHeaderField("Pragma")); response.setWWWAuthenticate(conn.getHeaderField("WWW-Authenticate")); if (!StringHelper.isBlank(out)) { response.setContent(out); } return response; }
HTTPResponse createResponse(final HttpURLConnection conn, final String out) throws IOException { final HTTPResponse response = new HTTPResponse(conn.getResponseCode()); final String location = conn.getHeaderField("Location"); if (!StringHelper.isBlank(location)) { try { response.setLocation(new URI(location)); } catch (URISyntaxException e) { throw new IOException("Invalid location URI " + location, e); } } try { response.setContentType(conn.getContentType()); } catch (final ParseException e) { throw new IOException("Couldn't parse Content-Type header: " + e.getMessage(), e); } response.setCacheControl(conn.getHeaderField("Cache-Control")); response.setPragma(conn.getHeaderField("Pragma")); response.setWWWAuthenticate(conn.getHeaderField("WWW-Authenticate")); if (!StringHelper.isBlank(out)) { response.setContent(out); } return response; }
HTTPResponse createResponse(final HttpURLConnection conn, final String out) throws IOException { final HTTPResponse response = new HTTPResponse(conn.getResponseCode()); final String location = conn.getHeaderField("Location"); if (!StringHelper.isBlank(location)) { try { response.setLocation(new URI(location)); } catch (URISyntaxException e) { throw new IOException("Invalid location URI " + location, e); } } try { response.setContentType(conn.getContentType()); } catch (final ParseException e) { throw new IOException("Couldn't parse Content-Type header: " + e.getMessage(), e); } response.setCacheControl(conn.getHeaderField("Cache-Control")); response.setPragma(conn.getHeaderField("Pragma")); response.setWWWAuthenticate(conn.getHeaderField("WWW-Authenticate")); if (!StringHelper.isBlank(out)) { response.setContent(out); } return response; }
httpResponse.setCacheControl("s-maxage=" + cacheLiveTime);