arturobernalg commented on code in PR #424: URL: https://github.com/apache/httpcomponents-core/pull/424#discussion_r1312058180
########## httpcore5/src/main/java/org/apache/hc/core5/http/protocol/RequestContent.java: ########## @@ -127,4 +133,32 @@ public void process(final HttpRequest request, final EntityDetails entity, final } } + /** + * Validates the presence and format of the Content-Type header for an OPTIONS request. + * + * <p> + * According to the HTTP protocol, an {@link Method#OPTIONS} request that contains content must also have + * a valid Content-Type header. This method checks for the presence of the Content-Type header + * and attempts to parse it to ensure its validity. If the header is missing or cannot be parsed, + * a {@link ProtocolException} is thrown. + * </p> + * + * @param request The {@link HttpRequest} whose Content-Type header is to be validated. Must not be null. + * @throws ProtocolException If the Content-Type header is missing or its format is invalid. + */ + public void validateOptionsContentType(final HttpRequest request) throws ProtocolException { + if (Method.OPTIONS.isSame(request.getMethod())) { + final Header header = request.getFirstHeader(HttpHeaders.CONTENT_TYPE); + if (header == null) { + throw new ProtocolException("OPTIONS request must have Content-Type header"); + } + try { Review Comment: @ok2c Removed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org