ObjFW  Diff

Differences From Artifact [4a757213a5]:

To Artifact [1a3fb9a7bd]:


18
19
20
21
22
23
24

25
26
27
28
29
30
31

#import "OFHTTPRequest.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFDictionary.h"
#import "OFDataArray.h"


#import "macros.h"

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







>







18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#import "OFHTTPRequest.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFDictionary.h"
#import "OFDataArray.h"

#import "autorelease.h"
#import "macros.h"

@implementation OFHTTPRequest
+ (instancetype)request
{
	return [[[self alloc] init] autorelease];
}
113
114
115
116
117
118
119








































120
121
122
123
124
125
126
	OF_SETTER(MIMEType, MIMEType_, YES, 1)
}

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








































@end

@implementation OFHTTPRequestResult
+ resultWithStatusCode: (short)status
	       headers: (OFDictionary*)headers
		  data: (OFDataArray*)data
{







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







114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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
165
166
167
	OF_SETTER(MIMEType, MIMEType_, YES, 1)
}

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

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

	switch (requestType) {
	case OF_HTTP_REQUEST_TYPE_GET:
		requestTypeStr = "GET";
		break;
	case OF_HTTP_REQUEST_TYPE_POST:
		requestTypeStr = "POST";
		break;
	case OF_HTTP_REQUEST_TYPE_HEAD:
		requestTypeStr = "HEAD";
		break;
	}

	indentedHeaders = [[headers description]
	    stringByReplacingOccurrencesOfString: @"\n"
				      withString: @"\n\t"];
	indentedPOSTData = [[POSTData description]
	    stringByReplacingOccurrencesOfString: @"\n"
				      withString: @"\n\t"];

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

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}
@end

@implementation OFHTTPRequestResult
+ resultWithStatusCode: (short)status
	       headers: (OFDictionary*)headers
		  data: (OFDataArray*)data
{
160
161
162
163
164
165
166

























167
	OF_GETTER(headers, YES)
}

- (OFDataArray*)data
{
	OF_GETTER(data, YES)
}

























@end







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

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
	OF_GETTER(headers, YES)
}

- (OFDataArray*)data
{
	OF_GETTER(data, YES)
}

- (OFString*)description
{
	void *pool = objc_autoreleasePoolPush();
	OFString *indentedHeaders, *indentedData, *ret;

	indentedHeaders = [[headers description]
	    stringByReplacingOccurrencesOfString: @"\n"
				      withString: @"\n\t"];
	indentedData = [[data description]
	    stringByReplacingOccurrencesOfString: @"\n"
				      withString: @"\n\t"];

	ret = [[OFString alloc] initWithFormat:
	    @"<%@:\n"
	    @"\tStatus code = %d\n"
	    @"\tHeaders = %@\n"
	    @"\tData = %@\n"
	    @">",
	    [self class], statusCode, indentedHeaders, indentedData];

	objc_autoreleasePoolPop(pool);

	return [ret autorelease];
}
@end