ObjFW  Diff

Differences From Artifact [2f6eab66c7]:

To Artifact [e6f92f7b1d]:


178
179
180
181
182
183
184
185

186
187
188
189
190
191
192
178
179
180
181
182
183
184

185
186
187
188
189
190
191
192







-
+







	} state;
	uint8_t HTTPMinorVersion;
	of_http_request_type_t requestType;
	OFString *host, *path;
	uint16_t port;
	OFMutableDictionary *headers;
	size_t contentLength;
	OFDataArray *postData;
	OFDataArray *POSTData;
}

- initWithSocket: (OFTCPSocket*)socket
	  server: (OFHTTPServer*)server;
- (BOOL)socket: (OFTCPSocket*)sock
   didReadLine: (OFString*)line
     exception: (OFException*)exception;
215
216
217
218
219
220
221
222

223
224
225
226
227
228
229
215
216
217
218
219
220
221

222
223
224
225
226
227
228
229







-
+








- (void)dealloc
{
	[sock release];
	[host release];
	[path release];
	[headers release];
	[postData release];
	[POSTData release];

	[super dealloc];
}

- (BOOL)socket: (OFTCPSocket*)sock_
   didReadLine: (OFString*)line
     exception: (OFException*)exception
328
329
330
331
332
333
334
335

336
337
338
339
340
341
342
328
329
330
331
332
333
334

335
336
337
338
339
340
341
342







-
+







			@try {
				contentLength = (size_t)[tmp decimalValue];
			} @catch (OFInvalidFormatException *e) {
				return [self sendErrorAndClose: 400];
			}

			buffer = [self allocMemoryWithSize: BUFFER_SIZE];
			postData = [[OFDataArray alloc] init];
			POSTData = [[OFDataArray alloc] init];

			[sock asyncReadIntoBuffer: buffer
					   length: BUFFER_SIZE
					   target: self
					 selector: @selector(socket:
						       didReadIntoBuffer:
						       length:exception:)];
396
397
398
399
400
401
402
403

404
405
406

407
408
409
410
411
412
413
396
397
398
399
400
401
402

403
404
405

406
407
408
409
410
411
412
413







-
+


-
+







  didReadIntoBuffer: (const char*)buffer
	     length: (size_t)length
	  exception: (OFException*)exception
{
	if ([sock_ isAtEndOfStream] || exception != nil)
		return NO;

	[postData addItemsFromCArray: buffer
	[POSTData addItemsFromCArray: buffer
			       count: length];

	if ([postData count] >= contentLength) {
	if ([POSTData count] >= contentLength) {
		@try {
			[self sendReply];
		} @catch (OFWriteFailedException *e) {
			return NO;
		}

		return NO;
457
458
459
460
461
462
463
464

465
466
467
468
469
470
471
457
458
459
460
461
462
463

464
465
466
467
468
469
470
471







-
+







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

	request = [OFHTTPRequest requestWithURL: URL];
	[request setRequestType: requestType];
	[request setHeaders: headers];
	[request setPostData: postData];
	[request setPOSTData: POSTData];

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

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