Open samthebest opened 1 year ago
After a little playing around, realised something fishy has to be going on with sbt
also, because we cannot reproduce the same error by trying different build files!
...
going to try to find a minimal build file to reproduce
Here is a minimal build file that reproduces the error ... I've put comments in the build file to show that if you comment/uncomment certain lines the issue goes away
https://github.com/samthebest/reproducing-finagle-bug/tree/master
So in this project you can do:
sbt
project hvDomain
console
then paste in
import com.twitter.finagle.{Http, Service}
import com.twitter.finagle.http.{Request, RequestBuilder, Response}
import com.twitter.util.{Await, Future}
val client: Service[Request, Response] = Http.client.withTls("REDACTED").newService("REDACTED:443")
val req = Request("REDACTED", "start" -> "2023-08-10", "end" -> "2023-08-10")
Await.result(client.apply(req))
Just send the hostname in the request for comply with the expected HTTP protocol with something like:
import com.twitter.finagle.Http
import com.twitter.finagle.http
val client = Http.client.withTls("myserver.com").newClient("myserver.com:443")
val requestBuilder = http.RequestBuilder().url("https://myserver.com/").addHeader(http.Fields.Host, "myserver.com")
val req = requestBuilder.buildGet() // or buildPost or the one you need.
client.toService.apply(req)
Finagle does not send any explicit HTTP host headers for covering more possible corner cases requests ... but just add a call to addHeader
with the hostname and it should work.
Additionally is recommended to pass the http.Fields.UserAgent
header and any other header information for following a standard HTTP call.
Describe the bug
I try to call a simple endpoint, which I can do easily in another library and using
curl
, but with finagle http I get:As stated I know the server is available because I can hit it using other libraries, or
curl
.To Reproduce
Expected behavior
It behaves like any other library or
curl
, i.e. hits the endpoint and returns a response.Also I don't understand why we need to specify the host 3 times (twice to create the service, once in the URI)