Skip to content

Commit

Permalink
Add read timeout for stream
Browse files Browse the repository at this point in the history
  • Loading branch information
tjbanghart committed Aug 8, 2023
1 parent 761d6d6 commit b407594
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,15 @@ private void streamResponse(String url, OutputStream outputStream) throws IOExce
if (!sdkTransport.getOptions().getVerifySSL()) {
trustAllHosts(connection);
}
// timeout is given as seconds
int timeout = sdkTransport.getOptions().getTimeout() * 1000;
connection.setReadTimeout(timeout);
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setDoOutput(true);
// Set the auth header as the SDK would
connection.setRequestProperty("Authorization",
"token " + authSession.getAuthToken().getAccessToken());
connection.setRequestProperty("Accept", "application/json");
int responseCode = connection.getResponseCode();
if (responseCode == 200) {
// grab the input stream and write to the output for the main thread to consume.
Expand Down

0 comments on commit b407594

Please sign in to comment.