in notificationworkerlambda/src/main/scala/com/gu/notifications/worker/delivery/fcm/oktransport/OkGoogleHttpRequest.scala [18:45]
override def addHeader(name: String, value: String): Unit = headers.offer((name, value))
override def execute(): LowLevelHttpResponse = {
val response: Response = executeRequest()
val (maybeContentType: Option[String], maybeBodyBytes: Option[Array[Byte]]) = callOnceWithResponseBody(response)(responseBody =>
(Option(responseBody.contentType()).map(_.toString), Option(responseBody.bytes()))
).getOrElse(None, None)
val maybeContent: Option[ByteArrayInputStream] = maybeBodyBytes.map(new ByteArrayInputStream(_))
val maybeContentLength: Option[Long] = maybeBodyBytes.map(_.length.toLong)
val headerList: scala.List[(String, String)] = readHeaders(response)
val maybeContentEncoding = Option(response.header("content-encoding"))
val httpProtocolInUpperCase = response.protocol().toString.toUpperCase
val statusCode = response.code
val statusReason = Option(response.message()).map(_.trim).filterNot(_.isEmpty)
new OkGoogleHttpResponse(
maybeContent,
maybeContentEncoding,
maybeContentLength,
maybeContentType,
httpProtocolInUpperCase,
statusCode,
statusReason,
headerList
)
}