ObjFW  Check-in [b8d3e09eff]

Overview
Comment:OFHTTPRequest: Add property remoteAddress.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b8d3e09eff9f3fc61e2cc4722559f311a22b15a82991a25f7beb479b9166e0a6
User & Date: js on 2012-12-15 20:35:58
Other Links: manifest | tags
Context
2012-12-15
23:31
OFString: Improved API for getting C strings. check-in: e2f4c1283c user: js tags: trunk
20:35
OFHTTPRequest: Add property remoteAddress. check-in: b8d3e09eff user: js tags: trunk
19:45
OFSet: Fix wrong argument type in interface. check-in: b39e7c8bd1 user: js tags: trunk
Changes

Modified src/OFHTTPRequest.h from [5980347de8] to [045a3b40c5].

33
34
35
36
37
38
39

40
41
42
43
44
45
46
47

48
49
50
51
52
53
54
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56







+








+







@interface OFHTTPRequest: OFObject
{
	OFURL *URL;
	of_http_request_type_t requestType;
	OFDictionary *headers;
	OFDataArray *POSTData;
	OFString *MIMEType;
	OFString *remoteAddress;
}

#ifdef OF_HAVE_PROPERTIES
@property (copy) OFURL *URL;
@property of_http_request_type_t requestType;
@property (copy) OFDictionary *headers;
@property (retain) OFDataArray *POSTData;
@property (copy) OFString *MIMEType;
@property (copy) OFString *remoteAddress;
#endif

/*!
 * @brief Creates a new OFHTTPRequest.
 *
 * @return A new, autoreleased OFHTTPRequest
 */
135
136
137
138
139
140
141














142
143
144
145
146
147
148
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164







+
+
+
+
+
+
+
+
+
+
+
+
+
+








/*!
 * @brief Returns the MIME type for the POST data.
 *
 * @return The MIME type for the POST data
 */
- (OFString*)MIMEType;

/*!
 * @brief Sets the remote address from which the request originates.
 *
 * @param remoteAddress The remote address from which the request originates
 */
- (void)setRemoteAddress: (OFString*)remoteAddress;

/*!
 * @brief Returns the remote address from which the request originates.
 *
 * @return The remote address from which the request originates
 */
- (OFString*)remoteAddress;
@end

/*!
 * @brief A class for storing the result of an HTTP request.
 */
@interface OFHTTPRequestResult: OFObject
{

Modified src/OFHTTPRequest.m from [2b89bc9ca2] to [617ad3d55d].

114
115
116
117
118
119
120










121
122
123
124
125
126
127
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137







+
+
+
+
+
+
+
+
+
+







	OF_SETTER(MIMEType, MIMEType_, YES, 1)
}

- (OFString*)MIMEType
{
	OF_GETTER(MIMEType, YES)
}

- (void)setRemoteAddress: (OFString*)remoteAddress_
{
	OF_SETTER(remoteAddress, remoteAddress_, YES, 1)
}

- (OFString*)remoteAddress
{
	OF_GETTER(remoteAddress, YES)
}

- (OFString*)description
{
	void *pool = objc_autoreleasePoolPush();
	const char *requestTypeStr = NULL;
	OFString *indentedHeaders, *indentedPOSTData, *ret;

146
147
148
149
150
151
152

153
154
155

156
157
158
159
160
161
162
156
157
158
159
160
161
162
163
164
165

166
167
168
169
170
171
172
173







+


-
+








	ret = [[OFString alloc] initWithFormat:
	    @"<%@:\n\tURL = %@\n"
	    @"\tRequest type = %s\n"
	    @"\tHeaders = %@\n"
	    @"\tPOST data = %@\n"
	    @"\tPOST data MIME type = %@\n"
	    @"\tRemote address = %@\n"
	    @">",
	    [self class], URL, requestTypeStr, indentedHeaders,
	    indentedPOSTData, MIMEType];
	    indentedPOSTData, MIMEType, remoteAddress];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}
@end

Modified src/OFHTTPServer.m from [0a1464d83e] to [bee3baba47].

460
461
462
463
464
465
466

467
468
469
470
471
472
473
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474







+







	[URL setPort: port];
	[URL setPath: path];

	request = [OFHTTPRequest requestWithURL: URL];
	[request setRequestType: requestType];
	[request setHeaders: headers];
	[request setPOSTData: POSTData];
	[request setRemoteAddress: [sock remoteAddress]];

	reply = [[server delegate] server: server
			didReceiveRequest: request];

	if (reply == nil) {
		[self sendErrorAndClose: 500];
		@throw [OFInvalidArgumentException