Improve HTTP authentication support.
The authentication state is stored (in a hash map, using the domain+path as a key) in the UrlContext class. It can then be reused for multiple requests to the same place. We also lookup stored authentications for parent directories and stop at the first we find. Authentication state is not stored on disk (unlike cookies), and there can only be one for each domain+path.
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
#include <deque>
|
||||
|
||||
|
||||
#include <HttpAuthentication.h>
|
||||
#include <HttpForm.h>
|
||||
#include <HttpHeaders.h>
|
||||
#include <HttpResult.h>
|
||||
@@ -93,7 +92,6 @@ private:
|
||||
BNetBuffer fInputBuffer;
|
||||
|
||||
BHttpHeaders fHeaders;
|
||||
BHttpAuthentication fAuthentication;
|
||||
|
||||
// Request status
|
||||
|
||||
|
||||
@@ -6,22 +6,36 @@
|
||||
#define _B_URL_CONTEXT_H_
|
||||
|
||||
|
||||
#include <HttpAuthentication.h>
|
||||
#include <NetworkCookieJar.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
template <class key, class value> class HashMap;
|
||||
class HashString;
|
||||
}
|
||||
|
||||
|
||||
class BUrlContext {
|
||||
public:
|
||||
BUrlContext();
|
||||
~BUrlContext();
|
||||
|
||||
// Context modifiers
|
||||
void SetCookieJar(
|
||||
const BNetworkCookieJar& cookieJar);
|
||||
void AddAuthentication(const BUrl& url,
|
||||
BHttpAuthentication* const authentication);
|
||||
|
||||
// Context accessors
|
||||
BNetworkCookieJar& GetCookieJar();
|
||||
BHttpAuthentication& GetAuthentication(const BUrl& url);
|
||||
|
||||
private:
|
||||
BNetworkCookieJar fCookieJar;
|
||||
typedef BPrivate::HashMap<BPrivate::HashString,
|
||||
BHttpAuthentication*> BHttpAuthenticationMap;
|
||||
BHttpAuthenticationMap* fAuthenticationMap;
|
||||
};
|
||||
|
||||
#endif // _B_URL_CONTEXT_H_
|
||||
|
||||
Reference in New Issue
Block a user