Clone
Cédric Champeau
committed
on 13 Jun 17
Rework fix for parallel downloads on authenticated repositories
This commit reworks the fix for authenticated repositories to use a queue of… Show more
Rework fix for parallel downloads on authenticated repositories

This commit reworks the fix for authenticated repositories to use a queue of `HttpContext` instead of a thread local map.

The rationale for this change is that 2 subsequent requests are not necessarily executed on the same thread. This means that

if request 1 performed authentication, and request 2 is done some time later, but on a different thread, authentication is

going to be done again.

To avoid this, request 1 will ask for a context in a queue. If no context is available, a new one is added. Once the request

is done, the context is added back in the queue, making it availble for subsequent requests to pick up. Request 2 comes and

picks it from the queue, then authentication state can be reused.

This means that at most, we can re-authenticate as many times as there are concurrent requests. But in practice, it is likely

that we're going to reuse shared context.

This commit also adds an integration test proving that parallel downloads work with authenticated repositories.

Show less

master + 518 more