ObjFW  Check-in [bfcd3875fe]

Overview
Comment:Add +[requestWithURL:] to OFHTTPRequest.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bfcd3875fec0768a238f6fdea38523883732bb588c707f6db045d23d1844be03
User & Date: js on 2011-03-29 17:51:31
Other Links: manifest | tags
Context
2011-03-29
18:20
Ignore leading and trailing whitespaces in -[(hexa)decimalValue]. check-in: e0a8e01190 user: js tags: trunk
17:51
Add +[requestWithURL:] to OFHTTPRequest. check-in: bfcd3875fe user: js tags: trunk
2011-03-28
23:54
One more workaround for a bug in gcc 4.4.4 (possibly only Haiku). check-in: 12dd2db6ce user: js tags: trunk
Changes

Modified src/OFHTTPRequest.h from [15378426fb] to [ee98886554].

47
48
49
50
51
52
53














54
55
56
57
58
59
60
#endif

/**
 * \return A new, autoreleased OFHTTPRequest
 */
+ request;















/**
 * Sets the URL for the HTTP request.
 *
 * \param URL The URL for the HTTP request
 */
- (void)setURL: (OFURL*)url;








>
>
>
>
>
>
>
>
>
>
>
>
>
>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#endif

/**
 * \return A new, autoreleased OFHTTPRequest
 */
+ request;

/**
 * \param url The URL for the request
 * \return A new, autoreleased OFHTTPRequest
 */
+ requestWithURL: (OFURL*)url;

/**
 * Initializes an already allocated OFHTTPRequest with the specified URL.
 *
 * \param url The URL for the request
 * \return An initialized OFHTTPRequest
 */
- initWithURL: (OFURL*)url;

/**
 * Sets the URL for the HTTP request.
 *
 * \param URL The URL for the HTTP request
 */
- (void)setURL: (OFURL*)url;

Modified src/OFHTTPRequest.m from [52aa44a3ac] to [43e2c90ca2].

36
37
38
39
40
41
42





43
44
45
46
47
48
49
50
51
52














53
54
55
56
57
58
59
Class of_http_request_tls_socket_class = Nil;

@implementation OFHTTPRequest
+ request
{
	return [[[self alloc] init] autorelease];
}






- init
{
	self = [super init];

	requestType = OF_HTTP_REQUEST_TYPE_GET;
	headers = [[OFDictionary alloc]
	    initWithObject: @"Something using ObjFW "
			    @"<https://webkeks.org/objfw/>"
		    forKey: @"User-Agent"];















	return self;
}

- (void)dealloc
{
	[URL release];







>
>
>
>
>










>
>
>
>
>
>
>
>
>
>
>
>
>
>







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
Class of_http_request_tls_socket_class = Nil;

@implementation OFHTTPRequest
+ request
{
	return [[[self alloc] init] autorelease];
}

+ requestWithURL: (OFURL*)url
{
	return [[[self alloc] initWithURL: url] autorelease];
}

- init
{
	self = [super init];

	requestType = OF_HTTP_REQUEST_TYPE_GET;
	headers = [[OFDictionary alloc]
	    initWithObject: @"Something using ObjFW "
			    @"<https://webkeks.org/objfw/>"
		    forKey: @"User-Agent"];

	return self;
}

- initWithURL: (OFURL*)url
{
	self = [self init];

	@try {
		[self setURL: url];
	} @catch (id e) {
		[self release];
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[URL release];

Modified tests/OFHTTPRequestTests.m from [c6dc023c7c] to [d40fc902b8].

101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
		server->port += 1024;
	[server start];

	url = [OFURL URLWithString:
	    [OFString stringWithFormat: @"http://127.0.0.1:%" @PRIu16 "/foo",
					server->port]];

	TEST(@"+[request]", (req = [OFHTTPRequest request]))
	TEST(@"-[setURL:]", R([req setURL: url]))

	[cond wait];
	[cond unlock];

	TEST(@"-[perform]", (res = [req perform]))

	[server join];

	[pool drain];
}
@end







|
<











101
102
103
104
105
106
107
108

109
110
111
112
113
114
115
116
117
118
119
		server->port += 1024;
	[server start];

	url = [OFURL URLWithString:
	    [OFString stringWithFormat: @"http://127.0.0.1:%" @PRIu16 "/foo",
					server->port]];

	TEST(@"+[requestWithURL]", (req = [OFHTTPRequest requestWithURL: url]))


	[cond wait];
	[cond unlock];

	TEST(@"-[perform]", (res = [req perform]))

	[server join];

	[pool drain];
}
@end