|
31 | 31 | import io.a2a.server.extensions.A2AExtensions; |
32 | 32 | import io.a2a.server.util.async.Internal; |
33 | 33 | import io.a2a.spec.A2AError; |
| 34 | +import io.a2a.spec.ContentTypeNotSupportedError; |
34 | 35 | import io.a2a.spec.InternalError; |
35 | 36 | import io.a2a.spec.InvalidParamsError; |
36 | 37 | import io.a2a.spec.MethodNotFoundError; |
@@ -165,8 +166,13 @@ public class A2AServerRoutes { |
165 | 166 | * @param body the JSON request body |
166 | 167 | * @param rc the Vert.x routing context |
167 | 168 | */ |
168 | | - @Route(regex = "^\\/(?<tenant>[^\\/]*\\/?)message:send$", order = 1, methods = {Route.HttpMethod.POST}, consumes = {APPLICATION_JSON}, type = Route.HandlerType.BLOCKING) |
| 169 | + @Route(regex = "^\\/(?<tenant>[^\\/]*\\/?)message:send$", order = 1, methods = {Route.HttpMethod.POST}, type = Route.HandlerType.BLOCKING) |
169 | 170 | public void sendMessage(@Body String body, RoutingContext rc) { |
| 171 | + String contentType = rc.request().getHeader(CONTENT_TYPE); |
| 172 | + if (contentType == null || !contentType.contains(APPLICATION_JSON)) { |
| 173 | + sendResponse(rc, jsonRestHandler.createErrorResponse(new ContentTypeNotSupportedError(null, null, null))); |
| 174 | + return; |
| 175 | + } |
170 | 176 | ServerCallContext context = createCallContext(rc, SEND_MESSAGE_METHOD); |
171 | 177 | HTTPRestResponse response = null; |
172 | 178 | try { |
@@ -198,8 +204,13 @@ public void sendMessage(@Body String body, RoutingContext rc) { |
198 | 204 | * @param body the JSON request body |
199 | 205 | * @param rc the Vert.x routing context |
200 | 206 | */ |
201 | | - @Route(regex = "^\\/(?<tenant>[^\\/]*\\/?)message:stream$", order = 1, methods = {Route.HttpMethod.POST}, consumes = {APPLICATION_JSON}, type = Route.HandlerType.BLOCKING) |
| 207 | + @Route(regex = "^\\/(?<tenant>[^\\/]*\\/?)message:stream$", order = 1, methods = {Route.HttpMethod.POST}, type = Route.HandlerType.BLOCKING) |
202 | 208 | public void sendMessageStreaming(@Body String body, RoutingContext rc) { |
| 209 | + String contentType = rc.request().getHeader(CONTENT_TYPE); |
| 210 | + if (contentType == null || !contentType.contains(APPLICATION_JSON)) { |
| 211 | + sendResponse(rc, jsonRestHandler.createErrorResponse(new ContentTypeNotSupportedError(null, null, null))); |
| 212 | + return; |
| 213 | + } |
203 | 214 | ServerCallContext context = createCallContext(rc, SEND_STREAMING_MESSAGE_METHOD); |
204 | 215 | HTTPRestStreamingResponse streamingResponse = null; |
205 | 216 | HTTPRestResponse error = null; |
@@ -339,6 +350,11 @@ public void getTask(RoutingContext rc) { |
339 | 350 | */ |
340 | 351 | @Route(regex = "^\\/(?<tenant>[^\\/]*\\/?)tasks\\/(?<taskId>[^/]+):cancel$", order = 1, methods = {Route.HttpMethod.POST}, type = Route.HandlerType.BLOCKING) |
341 | 352 | public void cancelTask(@Body String body, RoutingContext rc) { |
| 353 | + String contentType = rc.request().getHeader(CONTENT_TYPE); |
| 354 | + if (contentType == null || !contentType.contains(APPLICATION_JSON)) { |
| 355 | + sendResponse(rc, jsonRestHandler.createErrorResponse(new ContentTypeNotSupportedError(null, null, null))); |
| 356 | + return; |
| 357 | + } |
342 | 358 | String taskId = rc.pathParam("taskId"); |
343 | 359 | ServerCallContext context = createCallContext(rc, CANCEL_TASK_METHOD); |
344 | 360 | HTTPRestResponse response = null; |
@@ -443,8 +459,13 @@ public void subscribeToTask(RoutingContext rc) { |
443 | 459 | * @param body the JSON request body with notification configuration |
444 | 460 | * @param rc the Vert.x routing context (taskId extracted from path) |
445 | 461 | */ |
446 | | - @Route(regex = "^\\/(?<tenant>[^\\/]*\\/?)tasks\\/(?<taskId>[^/]+)\\/pushNotificationConfigs$", order = 1, methods = {Route.HttpMethod.POST}, consumes = {APPLICATION_JSON}, type = Route.HandlerType.BLOCKING) |
| 462 | + @Route(regex = "^\\/(?<tenant>[^\\/]*\\/?)tasks\\/(?<taskId>[^/]+)\\/pushNotificationConfigs$", order = 1, methods = {Route.HttpMethod.POST}, type = Route.HandlerType.BLOCKING) |
447 | 463 | public void CreateTaskPushNotificationConfiguration(@Body String body, RoutingContext rc) { |
| 464 | + String contentType = rc.request().getHeader(CONTENT_TYPE); |
| 465 | + if (contentType == null || !contentType.contains(APPLICATION_JSON)) { |
| 466 | + sendResponse(rc, jsonRestHandler.createErrorResponse(new ContentTypeNotSupportedError(null, null, null))); |
| 467 | + return; |
| 468 | + } |
448 | 469 | String taskId = rc.pathParam("taskId"); |
449 | 470 | ServerCallContext context = createCallContext(rc, SET_TASK_PUSH_NOTIFICATION_CONFIG_METHOD); |
450 | 471 | HTTPRestResponse response = null; |
|
0 commit comments