Cleanup and fix cookies handling
* The cookie jar iterator now use a BObjectList instead of a BList * Add a convenience method to the cookie jar to add a cookie by BUrl and raw cookie string. * Remove some methods in BNetworkCookie that could lead to invalid cookies (cross-domain or with no domain at all). * Make the cookie parsing able to report errors * Fix off-by-one error in domain cookies validation.
This commit is contained in:
@@ -16,8 +16,7 @@
|
||||
class BNetworkCookie : public BArchivable {
|
||||
public:
|
||||
BNetworkCookie(const char* name,
|
||||
const char* value);
|
||||
BNetworkCookie(const BString& cookieString);
|
||||
const char* value, const BUrl& url);
|
||||
BNetworkCookie(const BString& cookieString,
|
||||
const BUrl& url);
|
||||
BNetworkCookie(BMessage* archive);
|
||||
@@ -26,9 +25,8 @@ public:
|
||||
|
||||
// Parse a "SetCookie" string
|
||||
|
||||
BNetworkCookie& ParseCookieStringFromUrl(const BString& string,
|
||||
status_t ParseCookieString(const BString& string,
|
||||
const BUrl& url);
|
||||
BNetworkCookie& ParseCookieString(const BString& cookieString);
|
||||
|
||||
// Modify the cookie fields
|
||||
BNetworkCookie& SetName(const BString& name);
|
||||
@@ -76,7 +74,6 @@ public:
|
||||
static BArchivable* Instantiate(BMessage* archive);
|
||||
|
||||
// Overloaded operators
|
||||
BNetworkCookie& operator=(const char* string);
|
||||
bool operator==(const BNetworkCookie& other);
|
||||
bool operator!=(const BNetworkCookie& other);
|
||||
private:
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
|
||||
#include <Archivable.h>
|
||||
#include <Flattenable.h>
|
||||
#include <List.h>
|
||||
#include <Message.h>
|
||||
#include <ObjectList.h>
|
||||
#include <NetworkCookie.h>
|
||||
#include <String.h>
|
||||
#include <Url.h>
|
||||
|
||||
|
||||
typedef BList BNetworkCookieList;
|
||||
typedef BObjectList<BNetworkCookie> BNetworkCookieList;
|
||||
|
||||
|
||||
class BNetworkCookieJar : public BArchivable, public BFlattenable {
|
||||
@@ -35,6 +35,8 @@ public:
|
||||
virtual ~BNetworkCookieJar();
|
||||
|
||||
status_t AddCookie(const BNetworkCookie& cookie);
|
||||
status_t AddCookie(const BString& cookie,
|
||||
const BUrl& url);
|
||||
status_t AddCookie(BNetworkCookie* cookie);
|
||||
status_t AddCookies(const BNetworkCookieList& cookies);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user