Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public static <T, U> Function<PollingContext<PollResult<T>>, Mono<U>> fetchResul
U result = deserialize(serializerAdapter, value, finalResultType);
return result != null ? Mono.just(result) : Mono.empty();
} else {
return pipeline.send(new HttpRequest(HttpMethod.GET, finalResult.getResultUri()))
return pipeline.send(decorateRequest(new HttpRequest(HttpMethod.GET, finalResult.getResultUri())))
.flatMap((Function<HttpResponse, Mono<String>>) response -> response.getBodyAsString())
.flatMap(body -> {
U result = deserialize(serializerAdapter, body, finalResultType);
Expand Down Expand Up @@ -173,7 +173,7 @@ private static <T> Mono<PollResponse<PollResult<T>>> pollResponseMono(Serializer
* @return a Mono emitting PollingState updated from the poll operation response
*/
private static Mono<PollingState> doSinglePoll(HttpPipeline pipeline, PollingState pollingState) {
return pipeline.send(new HttpRequest(HttpMethod.GET, pollingState.getPollUrl()))
return pipeline.send(decorateRequest(new HttpRequest(HttpMethod.GET, pollingState.getPollUrl())))
.flatMap((Function<HttpResponse, Mono<PollingState>>) response -> response.getBodyAsString()
.map(body -> pollingState.update(response.getStatusCode(), response.getHeaders(), body))
.switchIfEmpty(Mono.defer(() -> {
Expand All @@ -183,6 +183,16 @@ private static Mono<PollingState> doSinglePoll(HttpPipeline pipeline, PollingSta
})));
}

/**
* Decorate the request.
*
* @param httpRequest the HttpRequest
* @return the HttpRequest with decoration.
*/
private static HttpRequest decorateRequest(HttpRequest httpRequest) {
return httpRequest.setHeader("Accept", "application/json");
}

/**
* Decode a string value.
*
Expand Down