@Test public void testHeaderConfigurationIsApplied() { StreamConfiguration sc = new StreamConfiguration(); sc.requestHeader("Accept-Encoding", "gzip"); NakadiClient client = NakadiClient.newBuilder().baseURI(baseUrl()).build(); final ResourceOptions resourceOptions = StreamResourceSupport.buildResourceOptions(client, sc); assertTrue(resourceOptions.headers().containsKey("Accept-Encoding")); }
static ResourceOptions buildResourceOptions(NakadiClient client, StreamConfiguration sc) { ResourceOptions options = ResourceSupport .options(APPLICATION_JSON) .tokenProvider(client.resourceTokenProvider()); applyConfiguredHeaders(sc, options); if (sc.isSubscriptionStream()) { return options; } Optional<List<Cursor>> cursors = sc.cursors(); cursors.ifPresent( list -> options.header(HEADER_X_NAKADI_CURSORS, client.jsonSupport().toJsonCompressed(list))); return options; }
StreamResourceSupport { static ResourceOptions buildResourceOptions(NakadiClient client, StreamConfiguration sc) { ResourceOptions options = ResourceSupport .options(APPLICATION_JSON) .tokenProvider(client.resourceTokenProvider()); applyConfiguredHeaders(sc, options); if (sc.isSubscriptionStream()) { return options; } Optional<List<Cursor>> cursors = sc.cursors(); cursors.ifPresent( list -> options.header(HEADER_X_NAKADI_CURSORS, client.jsonSupport().toJsonCompressed(list))); return options; } }
StreamResourceSupport { static ResourceOptions buildResourceOptions(NakadiClient client, StreamConfiguration sc) { ResourceOptions options = ResourceSupport .options(APPLICATION_JSON) .tokenProvider(client.resourceTokenProvider()); applyConfiguredHeaders(sc, options); if (sc.isSubscriptionStream()) { return options; } Optional<List<Cursor>> cursors = sc.cursors(); cursors.ifPresent( list -> options.header(HEADER_X_NAKADI_CURSORS, client.jsonSupport().toJsonCompressed(list))); return options; }  }
StreamResourceSupport { static ResourceOptions buildResourceOptions(NakadiClient client, StreamConfiguration sc) { ResourceOptions options = ResourceSupport .options(APPLICATION_JSON) .tokenProvider(client.resourceTokenProvider()); applyConfiguredHeaders(sc, options); if (sc.isSubscriptionStream()) { return options; } Optional<List<Cursor>> cursors = sc.cursors(); cursors.ifPresent( list -> options.header(HEADER_X_NAKADI_CURSORS, client.jsonSupport().toJsonCompressed(list))); return options; }   }
StreamResourceSupport { static ResourceOptions buildResourceOptions(NakadiClient client, StreamConfiguration sc) { ResourceOptions options = ResourceSupport .options(APPLICATION_JSON) .tokenProvider(client.resourceTokenProvider()); applyConfiguredHeaders(sc, options); if (sc.isSubscriptionStream()) { return options; } Optional<List<Cursor>> cursors = sc.cursors(); cursors.ifPresent( list -> options.header(HEADER_X_NAKADI_CURSORS, client.jsonSupport().toJsonCompressed(list))); return options; }   static final String X_NAKADI_STREAM_ID; static final String SUBSCRIPTION_ID; }