mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
Skeletal implementation of new URL laoding scheme
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23065 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a5a2b746ad
commit
44ba76ce4f
33 changed files with 5024 additions and 28 deletions
173
Source/NSHTTPCookie.m
Normal file
173
Source/NSHTTPCookie.m
Normal file
|
@ -0,0 +1,173 @@
|
|||
/* Implementation for NSHTTPCookie for GNUstep
|
||||
Copyright (C) 2006 Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <frm@gnu.org>
|
||||
Date: 2006
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "GSURLPrivate.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
|
||||
NSString * const NSHTTPCookieComment = @"NSHTTPCookieComment";
|
||||
NSString * const NSHTTPCookieCommentURL = @"NSHTTPCookieCommentURL";
|
||||
NSString * const NSHTTPCookieDiscard = @"NSHTTPCookieDiscard";
|
||||
NSString * const NSHTTPCookieDomain = @"NSHTTPCookieDomain";
|
||||
NSString * const NSHTTPCookieExpires = @"NSHTTPCookieExpires";
|
||||
NSString * const NSHTTPCookieMaximumAge = @"NSHTTPCookieMaximumAge";
|
||||
NSString * const NSHTTPCookieName = @"NSHTTPCookieName";
|
||||
NSString * const NSHTTPCookieOriginURL = @"NSHTTPCookieOriginURL";
|
||||
NSString * const NSHTTPCookiePath = @"NSHTTPCookiePath";
|
||||
NSString * const NSHTTPCookiePort = @"NSHTTPCookiePort";
|
||||
NSString * const NSHTTPCookieSecure = @"NSHTTPCookieSecure";
|
||||
NSString * const NSHTTPCookieValue = @"NSHTTPCookieValue";
|
||||
NSString * const NSHTTPCookieVersion = @"NSHTTPCookieVersion";
|
||||
|
||||
// Internal data storage
|
||||
typedef struct {
|
||||
NSDictionary *_properties;
|
||||
} Internal;
|
||||
|
||||
typedef struct {
|
||||
@defs(NSHTTPCookie)
|
||||
} priv;
|
||||
#define this ((Internal*)(((priv*)self)->_NSHTTPCookieInternal))
|
||||
#define inst ((Internal*)(((priv*)o)->_NSHTTPCookieInternal))
|
||||
|
||||
@implementation NSHTTPCookie
|
||||
|
||||
+ (id) allocWithZone: (NSZone*)z
|
||||
{
|
||||
NSHTTPCookie *o = [super allocWithZone: z];
|
||||
|
||||
if (o != nil)
|
||||
{
|
||||
o->_NSHTTPCookieInternal = NSZoneMalloc(z, sizeof(Internal));
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
+ (id) cookieWithProperties: (NSDictionary *)properties
|
||||
{
|
||||
NSHTTPCookie *o;
|
||||
|
||||
o = [[self alloc] initWithProperties: properties];
|
||||
return AUTORELEASE(o);
|
||||
}
|
||||
|
||||
+ (NSArray *) cookiesWithResponseHeaderFields: (NSDictionary *)headerFields
|
||||
forURL: (NSURL *)URL
|
||||
{
|
||||
NSMutableArray *a = nil;
|
||||
|
||||
[self notImplemented: _cmd]; // FIXME
|
||||
return a;
|
||||
}
|
||||
|
||||
+ (NSDictionary *) requestHeaderFieldsWithCookies: (NSArray *)cookies
|
||||
{
|
||||
NSMutableDictionary *d = nil;
|
||||
|
||||
[self notImplemented: _cmd]; // FIXME
|
||||
return d;
|
||||
}
|
||||
|
||||
- (NSString *) comment
|
||||
{
|
||||
return [this->_properties objectForKey: NSHTTPCookieComment];
|
||||
}
|
||||
|
||||
- (NSURL *) commentURL
|
||||
{
|
||||
return [this->_properties objectForKey: NSHTTPCookieCommentURL];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
if (this != 0)
|
||||
{
|
||||
RELEASE(this->_properties);
|
||||
NSZoneFree([self zone], this);
|
||||
}
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString *) domain
|
||||
{
|
||||
return [this->_properties objectForKey: NSHTTPCookieDomain];
|
||||
}
|
||||
|
||||
- (NSDate *) expiresDate
|
||||
{
|
||||
return [this->_properties objectForKey: NSHTTPCookieExpires];
|
||||
}
|
||||
|
||||
- (id) initWithProperties: (NSDictionary *)properties
|
||||
{
|
||||
if ((self = [super init]) != nil)
|
||||
{
|
||||
this->_properties = [properties copy];
|
||||
// FIXME ... parse and validate
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isSecure
|
||||
{
|
||||
return [[this->_properties objectForKey: NSHTTPCookieSecure] boolValue];
|
||||
}
|
||||
|
||||
- (BOOL) isSessionOnly
|
||||
{
|
||||
return [[this->_properties objectForKey: NSHTTPCookieDiscard] boolValue];
|
||||
}
|
||||
|
||||
- (NSString *) name
|
||||
{
|
||||
return [this->_properties objectForKey: NSHTTPCookieName];
|
||||
}
|
||||
|
||||
- (NSString *) path
|
||||
{
|
||||
return [this->_properties objectForKey: NSHTTPCookiePath];
|
||||
}
|
||||
|
||||
- (NSArray *) portList
|
||||
{
|
||||
return [[this->_properties objectForKey: NSHTTPCookiePort]
|
||||
componentsSeparatedByString: @","];
|
||||
}
|
||||
|
||||
- (NSDictionary *) properties
|
||||
{
|
||||
return this->_properties;
|
||||
}
|
||||
|
||||
- (NSString *) value
|
||||
{
|
||||
return [this->_properties objectForKey: NSHTTPCookieValue];
|
||||
}
|
||||
|
||||
- (unsigned) version
|
||||
{
|
||||
return [[this->_properties objectForKey: NSHTTPCookieVersion] intValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue