ClientRequestContextAdapter { static brave.http.HttpClientRequest asHttpClientRequest(ClientRequestContext ctx, RequestHeadersBuilder headersBuilder) { return new HttpClientRequest(ctx, headersBuilder); } private  ClientRequestContextAdapter();   }
@Test void path() { final HttpRequest req = HttpRequest.of(HttpMethod.GET, "/foo"); final HttpClientRequest braveReq = ClientRequestContextAdapter.asHttpClientRequest( ClientRequestContext.of(req), req.headers().toBuilder()); assertThat(braveReq.path()).isEqualTo("/foo"); }
@Test void method() { final HttpRequest req = HttpRequest.of(HttpMethod.GET, "/foo"); final HttpClientRequest braveReq = ClientRequestContextAdapter.asHttpClientRequest( ClientRequestContext.of(req), req.headers().toBuilder()); assertThat(braveReq.method()).isEqualTo("GET"); }
@Test void url() { final HttpRequest req = HttpRequest.of( RequestHeaders.of(HttpMethod.GET, "/foo?name=hoge", HttpHeaderNames.SCHEME, "http", HttpHeaderNames.AUTHORITY, "example.com")); final HttpClientRequest braveReq = ClientRequestContextAdapter.asHttpClientRequest( ClientRequestContext.of(req), req.headers().toBuilder()); assertThat(braveReq.url()).isEqualTo("http: }
@Test void requestHeader() { final ClientRequestContext ctx = ClientRequestContext.of( HttpRequest.of(RequestHeaders.of(HttpMethod.GET, "/", "foo", "bar"))); ctx.logBuilder().endRequest(); ctx.logBuilder().endResponse(); final HttpClientRequest braveReq = ClientRequestContextAdapter.asHttpClientRequest(ctx, ctx.request().headers().toBuilder()); assertThat(braveReq.header("foo")).isEqualTo("bar"); assertThat(braveReq.header("bar")).isNull(); }