This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
> I'm using IOUtil.getInputStream(String) to get the contents of a URL hosted > at SSEC. This call falls through to IOUtil.getInputStream(String, Class) > which captures HTTP response code 401, but not others. In my case, on a > wireless network that redirects to a gateway, the response code is 302. > Could you please add a check for other HTTP redirects (at least 301, 302, > 303) and throw an exception? In this case the input stream that is returned > is valid, but the content is not the resource you are expecting. > > Hi Dave, The problem is the URLConnection handles the redirects automatically. In the code: URLConnection connection = url.openConnection(); connection.setAllowUserInteraction(true); if (connection instanceof HttpURLConnection) { HttpURLConnection huc = (HttpURLConnection) connection; //We never see a 301 here. All we see is the 200 if (huc.getResponseCode() == 401) { ... Do you know a different approach? -jeff Ticket Details =================== Ticket ID: LQX-280027 Department: Support McV Priority: Normal Status: Closed