ObjFW  Diff

Differences From Artifact [db503301c5]:

To Artifact [c477e44d18]:


16
17
18
19
20
21
22
23

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

23
24
25
26
27
28
29
30







-
+








#include "config.h"

#include <stdlib.h>
#include <string.h>

#import "OFHTTPServer.h"
#import "OFDataArray.h"
#import "OFData.h"
#import "OFDate.h"
#import "OFDictionary.h"
#import "OFURL.h"
#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFTCPSocket.h"
#import "OFTimer.h"
331
332
333
334
335
336
337
338

339
340
341
342
343
344
345
331
332
333
334
335
336
337

338
339
340
341
342
343
344
345







-
+







	} _state;
	uint8_t _HTTPMinorVersion;
	of_http_request_method_t _method;
	OFString *_host, *_path;
	uint16_t _port;
	OFMutableDictionary *_headers;
	size_t _contentLength;
	OFDataArray *_body;
	OFMutableData *_body;
}

- initWithSocket: (OFTCPSocket *)socket
	  server: (OFHTTPServer *)server;
- (bool)socket: (OFTCPSocket *)socket
   didReadLine: (OFString *)line
     exception: (OFException *)exception;
496
497
498
499
500
501
502
503

504
505
506
507
508
509
510
496
497
498
499
500
501
502

503
504
505
506
507
508
509
510







-
+







			return [self sendErrorAndClose: 400];
		}

		if (contentLength > 0) {
			char *buffer;

			buffer = [self allocMemoryWithSize: BUFFER_SIZE];
			_body = [[OFDataArray alloc] init];
			_body = [[OFMutableData alloc] init];

			[_socket asyncReadIntoBuffer: buffer
					      length: BUFFER_SIZE
					      target: self
					    selector: @selector(socket:
							  didReadIntoBuffer:
							  length:exception:)];
584
585
586
587
588
589
590


591
592
593
594
595
596
597
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599







+
+







		/*
		 * Manually free the buffer here. While this is not required
		 * now as the async read is the only thing referencing self and
		 * the buffer is allocated on self, it is required once
		 * Connection: keep-alive is implemented.
		 */
		[self freeMemory: buffer];

		[_body makeImmutable];

		@try {
			[self createResponse];
		} @catch (OFWriteFailedException *e) {
			return false;
		}