in http-server/src/main/scala/com/twitter/finatra/http/filters/HttpResponseFilter.scala [120:145]
private[this] def getCurrentDateValue: String = Message.httpDateFormat(System.currentTimeMillis())
private[this] def updateLocationHeader(request: R, response: Response): Unit = {
for (existingLocation <- response.location) {
Try(new URI(existingLocation)) match {
case Throw(e) =>
logger.warn(
s"Response Header '${Fields.Location}' value: '$existingLocation' is not a valid URI. ${e.getMessage}"
)
case Return(uri) if isRelativeLocation(uri) =>
setLocationHeader(
response.headerMap,
getLocationHeaderValue(fullyQualify = this.fullyQualifyLocationHeader, uri, request))
case Return(uri) =>
// valid URI with a non-null scheme, check scheme against "x-forwarded-proto" from request
request.headerMap.get("x-forwarded-proto") match {
case Some(protocol) if protocol != uri.getScheme =>
setLocationHeader(
response.headerMap,
getLocationHeaderValue(fullyQualify = true, uri, request))
case _ =>
// valid URI with a non-null scheme, no "x-forwarded-proto" from request = do nothing
}
}
}
}