akka/akka-http

[akka-http, 2.4.8] "Cannot determine request scheme and target endpoint" while using host header in client request level api

オープン

#47 opened on 2016/09/08

 (6 件のコメント) (0 件のリアクション) (0 人の担当者)Scala (598 件のフォーク)batch import
1 - triagedhelp wantedt:docs

Repository metrics

Stars
 (1,311 個のスター)
PR merge metrics
 (平均マージ 1d 10h) (30d で 2 merged PRs)

説明

Issue by alias1 Monday Jul 11, 2016 at 09:53 GMT Originally opened as https://github.com/akka/akka/issues/20934


I'm trying to put together some API abstractions using the request level client API, and running into this error message:

Cannot determine request scheme and target endpoint as HttpMethod(GET) request to /self/calendar doesn't have an absolute URI

I would have expected this should work since I am setting the host header. Cut down example:

# Initial Setup/Abstractions
val http = Http(system)
val hostHeader = headers.Host("api.meetup.com")
val request = HttpRequest().withDefaultHeaders(hostHeader)
val get = request.withMethod(HttpMethods.GET)

# Individual Call
val uri = Uri().withPath(Path("/self/calendar"))
val r = get.withUri(uri)
http.singleRequest(r)

Printing the request:

HttpRequest(HttpMethod(GET),/self/calendar,List(Host: api.meetup.com),HttpEntity.Strict(none/none,ByteString()),HttpProtocol(HTTP/1.1))

I have also tried using the following, to no avail:

  • val request = HttpRequest().withHeaders(hostHeader)
  • val request = HttpRequest().withEffectiveUri(true, hostHeader)
  • .toRelative on the uri chain
  • get.withUri("/self/calendar")

Though if I use val request = get.withUri(uri).withEffectiveUri(true, hostHeader) then the request works.

Am I missing something? Or is there a better way to build up these abstractions? I would have expected that so long as I had the host/effective URL set somewhere in the chain it should work fine.

コントリビューターガイド