ObjFW  Diff

Differences From Artifact [f5ea4dfab5]:

To Artifact [ba8461807d]:


17
18
19
20
21
22
23

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







+







#include "config.h"

#include <string.h>
#include <ctype.h>

#import "OFHTTPClient.h"
#import "OFHTTPRequest.h"
#import "OFHTTPRequestReply.h"
#import "OFString.h"
#import "OFURL.h"
#import "OFTCPSocket.h"
#import "OFDictionary.h"
#import "OFDataArray.h"
#import "OFSystemInfo.h"

102
103
104
105
106
107
108
109

110
111
112
113
114
115
116


117
118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
103
104
105
106
107
108
109

110
111
112
113
114
115


116
117
118
119
120
121
122
123
124
125

126
127
128
129
130
131
132
133







-
+





-
-
+
+








-
+







}

- (BOOL)storesData
{
	return storesData;
}

- (OFHTTPRequestResult*)performRequest: (OFHTTPRequest*)request
- (OFHTTPRequestReply*)performRequest: (OFHTTPRequest*)request
{
	return [self performRequest: request
			  redirects: 10];
}

- (OFHTTPRequestResult*)performRequest: (OFHTTPRequest*)request
			     redirects: (size_t)redirects
- (OFHTTPRequestReply*)performRequest: (OFHTTPRequest*)request
			    redirects: (size_t)redirects
{
	void *pool = objc_autoreleasePoolPush();
	OFURL *URL = [request URL];
	OFString *scheme = [URL scheme];
	of_http_request_type_t requestType = [request requestType];
	OFDictionary *headers = [request headers];
	OFDataArray *POSTData = [request POSTData];
	OFTCPSocket *sock;
	OFHTTPRequestResult *result;
	OFHTTPRequestReply *reply;
	OFString *line, *path, *version;
	OFMutableDictionary *serverHeaders;
	OFDataArray *data;
	OFEnumerator *keyEnumerator, *objectEnumerator;
	OFString *key, *object, *contentLengthHeader;
	int status;
	const char *type = NULL;
479
480
481
482
483
484
485
486
487
488



489
490
491
492

493
494
495
496
497
498

499
500

501
502
480
481
482
483
484
485
486



487
488
489
490
491
492

493
494
495
496
497
498

499
500

501
502
503







-
-
-
+
+
+



-
+





-
+

-
+


	if (status == 200 && contentLengthHeader != nil &&
	    contentLength != bytesReceived)
		@throw [OFTruncatedDataException
		    exceptionWithClass: [self class]];

	[serverHeaders makeImmutable];

	result = [[OFHTTPRequestResult alloc] initWithStatusCode: status
							 headers: serverHeaders
							    data: data];
	reply = [[OFHTTPRequestReply alloc] initWithStatusCode: status
						       headers: serverHeaders
							  data: data];

	objc_autoreleasePoolPop(pool);

	[result autorelease];
	[reply autorelease];

	if (status != 200)
		@throw [OFHTTPRequestFailedException
		    exceptionWithClass: [self class]
			       request: request
				result: result];
				 reply: reply];

	return result;
	return reply;
}
@end