New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow async customization of long polling request #801

Open
Diagoras opened this Issue Nov 9, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@Diagoras

Diagoras commented Nov 9, 2018

LongPollingTransport defines an empty protected void customize(Request request) method, presumably so that subclasses can override it in order to customize the request before it's sent. Unfortunately, this method returns immediately so it can't be used to customize the request with the result of an asynchronous operation. For example:

@Override
protected void customize(Request request) {
final CompletionStage<String> authorization = getAuthorizationFromAsyncSource();
request.header(HttpHeader.AUTHORIZATION, "Bearer " + authorization.join()); // Need to block since the method is synchronous.
}

Adding an alternative that accepts a Promise<Request> parameter should fix this, since we could complete that Promise with the result of any callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment