Skip to content

Commit

Permalink
Apply fix for #347 in the vertx engine
Browse files Browse the repository at this point in the history
Signed-off-by: Clement Escoffier <clement.escoffier@gmail.com>
  • Loading branch information
cescoffier committed Sep 12, 2014
1 parent 4a31397 commit e520547
Showing 1 changed file with 9 additions and 2 deletions.
Expand Up @@ -165,8 +165,8 @@ private Result invoke(Route route) {
private void handleAsyncResult(
final ContextFromVertx context,
final RequestFromVertx request,
AsyncResult result) {
Future<Result> future = accessor.getSystem().dispatchResultWithContext(result.callable(), context);
final AsyncResult asyncResult) {
Future<Result> future = accessor.getSystem().dispatchResultWithContext(asyncResult.callable(), context);
future.onComplete(new OnComplete<Result>() {
/**
* Called when the result is computed. It writes the response.
Expand All @@ -180,6 +180,13 @@ public void onComplete(Throwable failure, Result result) {
writeResponse(context, request, Results.internalServerError(failure), false, true);
} else {
// We got a result, write it here.
// Merge the headers of the initial result and the async results.
final Map<String, String> headers = result.getHeaders();
for (Map.Entry<String, String> header : asyncResult.getHeaders().entrySet()) {
if (! headers.containsKey(header.getKey())) {
headers.put(header.getKey(), header.getValue());
}
}
writeResponse(context, request, result, true, true);
}
}
Expand Down

0 comments on commit e520547

Please sign in to comment.