1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/*
* Copyright (c) 2008-2022 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFHTTPCookie.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFURI.h"
#import "OFInvalidFormatException.h"
static void
handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
{
OFString *lowercaseName = name.lowercaseString;
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/*
* Copyright (c) 2008-2023 Jonathan Schleifer <js@nil.im>
*
* All rights reserved.
*
* This file is part of ObjFW. It may be distributed under the terms of the
* Q Public License 1.0, which can be found in the file LICENSE.QPL included in
* the packaging of this file.
*
* Alternatively, it may be distributed under the terms of the GNU General
* Public License, either version 2 or 3, which can be found in the file
* LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
* file.
*/
#include "config.h"
#import "OFHTTPCookie.h"
#import "OFArray.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFIRI.h"
#import "OFInvalidFormatException.h"
static void
handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
{
OFString *lowercaseName = name.lowercaseString;
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
@implementation OFHTTPCookie
@synthesize name = _name, value = _value, domain = _domain, path = _path;
@synthesize expires = _expires, secure = _secure, HTTPOnly = _HTTPOnly;
@synthesize extensions = _extensions;
+ (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields:
(OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields
forURI: (OFURI *)URI
{
OFMutableArray OF_GENERIC(OFHTTPCookie *) *ret = [OFMutableArray array];
void *pool = objc_autoreleasePoolPush();
OFString *string = [headerFields objectForKey: @"Set-Cookie"];
OFString *domain = URI.host;
const OFUnichar *characters = string.characters;
size_t length = string.length, last = 0;
enum {
statePreName,
stateName,
stateExpectValue,
stateValue,
|
|
|
>
|
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
@implementation OFHTTPCookie
@synthesize name = _name, value = _value, domain = _domain, path = _path;
@synthesize expires = _expires, secure = _secure, HTTPOnly = _HTTPOnly;
@synthesize extensions = _extensions;
+ (OFArray OF_GENERIC(OFHTTPCookie *) *)cookiesWithResponseHeaderFields:
(OFDictionary OF_GENERIC(OFString *, OFString *) *)headerFields
forIRI: (OFIRI *)IRI
{
OFMutableArray OF_GENERIC(OFHTTPCookie *) *ret = [OFMutableArray array];
void *pool = objc_autoreleasePoolPush();
OFString *string = [headerFields objectForKey: @"Set-Cookie"];
OFString *domain = IRI.IRIByAddingPercentEncodingForUnicodeCharacters
.host;
const OFUnichar *characters = string.characters;
size_t length = string.length, last = 0;
enum {
statePreName,
stateName,
stateExpectValue,
stateValue,
|