Skip to content

Commit

Permalink
When calculating the client ip, allow the possibility of the address …
Browse files Browse the repository at this point in the history
…to be null (#3389)
  • Loading branch information
adamw authored Dec 12, 2023
1 parent 19d08b1 commit 15fb9fd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/src/main/scala/sttp/tapir/Tapir.scala
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,13 @@ trait TapirComputedInputs { this: Tapir =>
.flatMap(_.split(",").headOption)
.orElse(request.header("Remote-Address"))
.orElse(request.header("X-Real-Ip"))
.orElse(request.connectionInfo.remote.flatMap(a => Option(a.getAddress.getHostAddress)))
.orElse {
for {
r <- request.connectionInfo.remote
a <- Option(r.getAddress)
ha <- Option(a.getHostAddress)
} yield ha
}
)

def isWebSocket: EndpointInput[Boolean] =
Expand Down

0 comments on commit 15fb9fd

Please sign in to comment.