|
5 | 5 |
|
6 | 6 | import java.io.IOException; |
7 | 7 | import java.io.PrintWriter; |
| 8 | +import java.util.ArrayList; |
8 | 9 | import java.util.Enumeration; |
9 | 10 | import java.util.HashMap; |
| 11 | +import java.util.List; |
10 | 12 | import java.util.Map; |
| 13 | +import java.util.Set; |
11 | 14 | import java.util.concurrent.CompletableFuture; |
12 | 15 | import java.util.concurrent.Executor; |
13 | 16 | import java.util.concurrent.Flow; |
|
25 | 28 | import jakarta.ws.rs.core.MediaType; |
26 | 29 | import jakarta.ws.rs.core.Response; |
27 | 30 | import jakarta.ws.rs.core.SecurityContext; |
| 31 | + |
| 32 | +import io.a2a.common.A2AHeaders; |
28 | 33 | import io.a2a.server.ExtendedAgentCard; |
29 | 34 | import io.a2a.server.ServerCallContext; |
30 | 35 | import io.a2a.server.auth.UnauthenticatedUser; |
31 | 36 | import io.a2a.server.auth.User; |
| 37 | +import io.a2a.server.extensions.A2AExtensions; |
32 | 38 | import io.a2a.server.util.async.Internal; |
33 | 39 | import io.a2a.spec.AgentCard; |
34 | 40 | import io.a2a.spec.InvalidParamsError; |
@@ -177,7 +183,7 @@ public Response getTask(@PathParam("taskId") String taskId, @QueryParam("history |
177 | 183 | ServerCallContext context = createCallContext(httpRequest, securityContext); |
178 | 184 | RestHandler.HTTPRestResponse response = null; |
179 | 185 | try { |
180 | | - Integer historyLength = null; |
| 186 | + int historyLength = 0; |
181 | 187 | if (history_length != null) { |
182 | 188 | historyLength = Integer.valueOf(history_length); |
183 | 189 | } |
@@ -344,7 +350,13 @@ public String getUsername() { |
344 | 350 |
|
345 | 351 | state.put("headers", headers); |
346 | 352 |
|
347 | | - return new ServerCallContext(user, state); |
| 353 | + Enumeration<String> en = request.getHeaders(A2AHeaders.X_A2A_EXTENSIONS); |
| 354 | + List<String> extensionHeaderValues = new ArrayList<>(); |
| 355 | + while (en.hasMoreElements()) { |
| 356 | + extensionHeaderValues.add(en.nextElement()); |
| 357 | + } |
| 358 | + Set<String> requestedExtensions = A2AExtensions.getRequestedExtensions(extensionHeaderValues); |
| 359 | + return new ServerCallContext(user, state, requestedExtensions); |
348 | 360 | } else { |
349 | 361 | CallContextFactory builder = callContextFactory.get(); |
350 | 362 | return builder.build(request); |
|
0 commit comments