Class RFC9457Reporter<T, E extends Exception, R>
java.lang.Object
org.eclipse.aether.spi.connector.transport.http.RFC9457.RFC9457Reporter<T,E,R>
- Type Parameters:
T- The type of the response.E- The base exception type to throw if the response is not a RFC9457 message.R- The type of the request or request builder (which allows to modify headers)
A reporter for RFC 9457 messages.
RFC 9457 is a standard for reporting problems in HTTP responses as a JSON object.
There are members specified in the RFC but none of those appear to be required,
see rfc9457 section 3.7
Given the JSON fields are not mandatory, this reporter simply extracts the body of the
response without validation.
A RFC 9457 message is detected by the content type "application/problem+json"<T, E extends Exception, R> in the response header.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerateException(T response, BiConsumerChecked<Integer, String, E> baseException) Generates aHttpRFC9457Exceptionif the response type is a RFC 9457 message.protected abstract Stringprotected abstract StringgetReasonPhrase(T response) protected abstract intgetStatusCode(T response) protected booleanhasRFC9457ContentType(String contentType) protected abstract booleanisRFC9457Message(T response) abstract voidprepareRequest(R request) Prepares the request to accept RFC 9457 responses.
-
Field Details
-
CONTENT_TYPE_PROBLEM_DETAILS_JSON
- See Also:
-
-
Constructor Details
-
RFC9457Reporter
public RFC9457Reporter()
-
-
Method Details
-
isRFC9457Message
-
getStatusCode
-
getReasonPhrase
-
getBody
- Throws:
IOException
-
prepareRequest
Prepares the request to accept RFC 9457 responses. This involves setting/updating the "Accept" header to include "application/problem+json".- Parameters:
request- The request or request builder to prepare- See Also:
-
hasRFC9457ContentType
-
generateException
public void generateException(T response, BiConsumerChecked<Integer, String, throws E, HttpRFC9457ExceptionE> baseException) Generates aHttpRFC9457Exceptionif the response type is a RFC 9457 message. Otherwise, it throws the base exception- Parameters:
response- The response to check for RFC 9457 messages.baseException- The base exception to throw if the response is not a RFC 9457 message.- Throws:
EHttpRFC9457Exception
-