ObjFW  Diff

Differences From Artifact [aa1c799693]:

To Artifact [684e137d81]:


29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43







-
+







#import "OFHTTPRequest.h"
#import "OFHTTPResponse.h"
#import "OFNumber.h"
#import "OFSocket+Private.h"
#import "OFTCPSocket.h"
#import "OFThread.h"
#import "OFTimer.h"
#import "OFURL.h"
#import "OFURI.h"

#import "OFAlreadyConnectedException.h"
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFNotOpenException.h"
#import "OFOutOfMemoryException.h"
510
511
512
513
514
515
516
517

518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539



540
541

542
543
544
545
546
547
548
549
550
551
552


553
554

555
556
557
558
559
560
561

562
563

564
565
566
567
568
569
570
510
511
512
513
514
515
516

517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536



537
538
539
540

541
542
543
544
545
546
547
548
549
550


551
552
553

554
555
556
557
558
559
560

561
562

563
564
565
566
567
568
569
570







-
+



















-
-
-
+
+
+

-
+









-
-
+
+

-
+






-
+

-
+







			      date, _server.name];
	return false;
}

- (void)createResponse
{
	void *pool = objc_autoreleasePoolPush();
	OFMutableURL *URL;
	OFMutableURI *URI;
	OFHTTPRequest *request;
	OFHTTPServerResponse *response;
	size_t pos;

	[_timer invalidate];
	[_timer release];
	_timer = nil;

	if (_host == nil || _port == 0) {
		if (_HTTPMinorVersion > 0) {
			[self sendErrorAndClose: 400];
			return;
		}

		[_host release];
		_host = [_server.host copy];
		_port = [_server port];
	}

	URL = [OFMutableURL URL];
	URL.scheme = @"http";
	URL.host = _host;
	URI = [OFMutableURI URI];
	URI.scheme = @"http";
	URI.host = _host;
	if (_port != 80)
		URL.port = [OFNumber numberWithUnsignedShort: _port];
		URI.port = [OFNumber numberWithUnsignedShort: _port];

	@try {
		if ((pos = [_path rangeOfString: @"?"].location) !=
		    OFNotFound) {
			OFString *path, *query;

			path = [_path substringToIndex: pos];
			query = [_path substringFromIndex: pos + 1];

			URL.URLEncodedPath = path;
			URL.URLEncodedQuery = query;
			URI.percentEncodedPath = path;
			URI.percentEncodedQuery = query;
		} else
			URL.URLEncodedPath = _path;
			URI.percentEncodedPath = _path;
	} @catch (OFInvalidFormatException *e) {
		objc_autoreleasePoolPop(pool);
		[self sendErrorAndClose: 400];
		return;
	}

	[URL makeImmutable];
	[URI makeImmutable];

	request = [OFHTTPRequest requestWithURL: URL];
	request = [OFHTTPRequest requestWithURI: URI];
	request.method = _method;
	request.protocolVersion =
	    (OFHTTPRequestProtocolVersion){ 1, _HTTPMinorVersion };
	request.headers = _headers;
	request.remoteAddress = _socket.remoteAddress;

	response = [[[OFHTTPServerResponse alloc]