namespace Best.HTTP.Request.Authenticators
{
///
/// Represents an interface for various authentication implementations used in HTTP requests.
///
public interface IAuthenticator
{
///
/// Set required headers or content for the HTTP request. Called right before the request is sent out.
///
///
///
/// The SetupRequest method will be called every time the request is redirected or retried.
///
///
/// The HTTP request to which headers or content will be added.
void SetupRequest(HTTPRequest request);
///
/// Called when the server is sending a 401 (Unauthorized) response with an WWW-Authenticate header.
/// The authenticator might find additional knowledge about the authentication requirements (like what auth method it should use).
/// If the authenticator is confident it can successfully (re)authenticate the request it can return true and the request will be resent to the server.
///
///
/// More details can be found here:
///
/// - RFC-9110 - 401 Unauthorized
/// - RFC-9110 - WWW-Authenticate header
///
///
/// The HTTP request that received the 401 response.
/// The HTTP response containing the 401 (Unauthorized) status.
/// true if the challange is handled by the authenticator and the request can be re-sent with authentication.
bool HandleChallange(HTTPRequest req, HTTPResponse resp);
}
}