使用InputStreamReader时出现IOException

时间:2017-05-26 11:08:53

标签: java authentication http-headers http-status-code-403 ioexception

当我的程序中执行下面的代码部分时,我得到一个IOException。

try(BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(logStorageUrl.openStream())))  {
            String currentLine;
            while((currentLine = bufferedReader.readLine()) != null){
                Vault vlt = mapper.readValue(currentLine, Vault.class);
                logger.debug("Log Store Name: " + vlt.getvault_name());
                logger.debug("Log Store Vault: " + vault);
                if(vlt.getvault_name().equals(vault.toLowerCase())){
                    logger.debug("Per Vault Total log_store vault name: " + vlt.getvault_name() + ", bytes: " + vlt.getBytes());
                    byteCount += vlt.getBytes();
                }
            }
            logger.debug("Total LogStore ByteCount: " + byteCount);

} catch(IOException e){
            System.out.println("IO Exception " + e );
}

以下是例外情况:

IO Exception java.io.IOException: Server returned HTTP response code: 403 for URL: https://s3-api.XXXXXX.net/cr-test

我怀疑它可能与aws v4身份验证有关,因为这是我使用的方法,我已经遇到了问题,但似乎已经解决了。这可能是我标题中遗漏的东西吗?我之前的问题是由于没有通过主持人'在我的标题中,但这次我把它包括在内。

我知道我传递了正确的访问权限和密钥,但我没有选择要通过的任何特定标头。

1 个答案:

答案 0 :(得分:0)

我正在传递一个不正确的uri。一旦我得到了正确的uri,我就不再收到错误了。

相关问题