rburgst/okhttp-digest

Remove "missing realm in challenge" log entry

alexeyvasilyev opened this issue · 2 comments

Remove "missing realm in challenge" log entry from DigestAuthenticator. It overloads logs with this log entry if basic HTTP GET requests are coming all the time and caching used.

For example

Map<String, CachingAuthenticator> gAuthCache = new ConcurrentHashMap<>();
Credentials credentials = new Credentials(username, password);
final BasicAuthenticator  basicAuthenticator  = new BasicAuthenticator(credentials);
final DigestAuthenticator digestAuthenticator = new DigestAuthenticator(credentials);

DispatchingAuthenticator authenticator = new DispatchingAuthenticator.Builder()
  .with("digest", digestAuthenticator)
  .with("basic",  basicAuthenticator)
  .build();

OkHttpClient.Builder builder = new OkHttpClient.Builder();
OkHttpClient client = builder
  .authenticator(new CachingAuthenticatorDecorator(authenticator, gAuthCache))
  .addInterceptor(new AuthenticationCacheInterceptor(gAuthCache))
  ....

This happens because DispatchingAuthenticator will first call DigestAuthenticator.authenticateWithState() and only then BasicAuthenticator.authenticateWithState().

can you explain a bit more the use case? Are you using the authenticator for non-authenticated requests?

I'm using your library for connecting IP cameras. Almost all cameras are password protected. They support basic and digest authentication.
I'm sending sending sequence of HTTP requests to the same camera for getting real-time video:
GET /image.jpeg
GET /image.jpeg
GET /image.jpeg

And I'm using caching for quicker HTTP GET responses for the same camera (1 HTTP request versus 2 HTTP requests if authentication used).

The log entry "missing realm in challenge" not shown if the camera uses digest authentication.
However it is shown for every HTTP GET request if the camera supports basic authentication.