-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Hello,
I like this library, thanks for creating it!
When running in the browser, would it be reasonable to provide default HttpRequest parameter values based off of document.location if the user does not specify host, port and/or protocol? For example, I find myself writing this code whenever I use roshttp on the client side to make requests back the originating server.
import roshttp.{HttpRequest, Protocol}
val baseRequest: HttpRequest = {
val hostPort: Array[String] = document.location.host.split(":")
val host: String = hostPort(0)
val request1 = HttpRequest().withHost(host)
val request2 =
if (hostPort.length > 1) {
request1.withPort(hostPort(1).toInt)
} else {
request1
}
if (document.location.protocol == "https:") {
request2.withProtocol(Protocol.HTTPS)
} else {
request2
}
}