Skip to content

Commit

Permalink
discard entity bytes when not consuming them in another way (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewBemis committed Nov 12, 2020
1 parent f8fc0bf commit cd0630e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,10 @@ class HttpGoogleServicesDAO(implicit val system: ActorSystem, implicit val mater
userAuthedRequest(metadataRequest)(AccessToken(authToken)).map { response =>
response.status match {
case OK => xmlApiResponseToObject(response, bucketName, objectKey)
case _ => throw new FireCloudExceptionWithErrorReport(ErrorReport(response.status, response.status.reason))
case _ => {
response.discardEntityBytes()
throw new FireCloudExceptionWithErrorReport(ErrorReport(response.status, response.status.reason))
}
}
}
}
Expand All @@ -256,6 +259,9 @@ class HttpGoogleServicesDAO(implicit val system: ActorSystem, implicit val mater
h.lowercaseName -> h.value
}.toMap

//we're done with the response and we don't care about the body, so we should discard the bytes now
response.discardEntityBytes()

// exists in xml api, same value as json api
val generation: String = headerMap("x-goog-generation")
val size: String = headerMap("x-goog-stored-content-length") // present in x-goog-stored-content-length vs. content-length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ trait RestJsonClient extends FireCloudRequestBuilding with PerformanceLogging {
}
case f => {
FCErrorReport(response).map { errorReport =>
//we never consume the response body in this case, so we must discard the bytes here
response.discardEntityBytes()
throw new FireCloudExceptionWithErrorReport(errorReport)
}
}
Expand Down

0 comments on commit cd0630e

Please sign in to comment.