Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions common/src/main/java/org/a2aproject/sdk/common/MediaType.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ public interface MediaType {

/** MIME type for JSON content: {@code application/json}. */
String APPLICATION_JSON = "application/json";

/** MIME type accepted from HTTP+JSON clients alongside {@code application/json}: {@code application/a2a+json}. */
String APPLICATION_A2A_JSON = "application/a2a+json";
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.a2aproject.sdk.server.rest.quarkus;

import static org.a2aproject.sdk.common.MediaType.APPLICATION_A2A_JSON;
import static org.a2aproject.sdk.server.ServerCallContext.TRANSPORT_KEY;
import static org.a2aproject.sdk.spec.A2AMethods.CANCEL_TASK_METHOD;
import static org.a2aproject.sdk.spec.A2AMethods.SEND_STREAMING_MESSAGE_METHOD;
Expand Down Expand Up @@ -774,13 +775,14 @@ private String extractTenant(RoutingContext rc) {
}

/**
* Check if the request content type is application/json.
* Check if the request content type is application/json or application/a2a+json.
* @param rc the routing context
* @return true if the content type is application/json - false otherwise.
* @return true if the content type is one of those - false otherwise.
*/
private boolean validateContentType(RoutingContext rc) {
String contentType = rc.request().getHeader(CONTENT_TYPE);
if (contentType == null || !contentType.trim().startsWith(APPLICATION_JSON)) {
if (contentType == null || !(contentType.trim().startsWith(APPLICATION_JSON)
|| contentType.trim().startsWith(APPLICATION_A2A_JSON))) {
sendResponse(rc, jsonRestHandler.createErrorResponse(new ContentTypeNotSupportedError(null, null, null)));
return false;
}
Expand Down
Loading