ObjFW  Diff

Differences From Artifact [a6980a9e89]:

To Artifact [11686037f1]:


239
240
241
242
243
244
245
246

247
248
249
250
251
252
253
239
240
241
242
243
244
245

246
247
248
249
250
251
252
253







-
+







	[_context release];
	[_version release];
	[_serverHeaders release];

	[super dealloc];
}

- (void)createResponseWithSocket: (OFTCPSocket *)sock
- (void)createResponseWithSocketOrThrow: (OFTCPSocket *)sock
{
	OFURL *URL = [_request URL];
	OFHTTPClientResponse *response;
	OFString *connectionHeader;
	bool keepAlive;
	OFString *location;

368
369
370
371
372
373
374


375
376
377
378
379
380
381
382
383
384
385
386
387
388
389












390
391
392
393
394
395
396
368
369
370
371
372
373
374
375
376
377
378
379
380


381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408







+
+




-
-









+
+
+
+
+
+
+
+
+
+
+
+







			[_client asyncPerformRequest: newRequest
					   redirects: _redirects - 1
					     context: _context];
			return;
		}
	}

	_client->_inProgress = false;

	if (_status / 100 != 2)
		@throw [OFHTTPRequestFailedException
		    exceptionWithRequest: _request
				response: response];

	_client->_inProgress = false;

	[_client->_delegate performSelector: @selector(client:didPerformRequest:
						 response:context:)
				 withObject: _client
				 withObject: _request
				 withObject: response
				 withObject: _context
				 afterDelay: 0];
}

- (void)createResponseWithSocket: (OFTCPSocket *)sock
{
	@try {
		[self createResponseWithSocketOrThrow: sock];
	} @catch (id e) {
		[_client->_delegate client: _client
		     didEncounterException: e
				forRequest: _request
				   context: _context];
	}
}

- (bool)handleFirstLine: (OFString *)line
{
	/*
	 * It's possible that the write succeeds on a connection that is
	 * keep-alive, but the connection has already been closed by the remote
	 * end due to a timeout. In this case, we need to reconnect.
708
709
710
711
712
713
714

715
716
717
718




719
720

721
722
723
724
725




726
727
728
729
730
731
732






733
734
735
736



737
738
739
740
741
742
743












744
745
746
747
748
749
750
720
721
722
723
724
725
726
727




728
729
730
731
732

733
734




735
736
737
738
739






740
741
742
743
744
745
746



747
748
749
750






751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769







+
-
-
-
-
+
+
+
+

-
+

-
-
-
-
+
+
+
+

-
-
-
-
-
-
+
+
+
+
+
+

-
-
-
+
+
+

-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+







		}
	} else
		[self closeAndReconnect];
}

- (void)closeAndReconnect
{
	@try {
	OFURL *URL = [_request URL];
	OFTCPSocket *sock;
	uint16_t port;
	OFNumber *URLPort;
		OFURL *URL = [_request URL];
		OFTCPSocket *sock;
		uint16_t port;
		OFNumber *URLPort;

	[_client close];
		[_client close];

	if ([[URL scheme] isEqual: @"https"]) {
		if (of_tls_socket_class == Nil)
			@throw [OFUnsupportedProtocolException
			    exceptionWithURL: URL];
		if ([[URL scheme] isEqual: @"https"]) {
			if (of_tls_socket_class == Nil)
				@throw [OFUnsupportedProtocolException
				    exceptionWithURL: URL];

		sock = [[[of_tls_socket_class alloc] init] autorelease];
		port = 443;
	} else {
		sock = [OFTCPSocket socket];
		port = 80;
	}
			sock = [[[of_tls_socket_class alloc] init] autorelease];
			port = 443;
		} else {
			sock = [OFTCPSocket socket];
			port = 80;
		}

	URLPort = [URL port];
	if (URLPort != nil)
		port = [URLPort uInt16Value];
		URLPort = [URL port];
		if (URLPort != nil)
			port = [URLPort uInt16Value];

	[sock asyncConnectToHost: [URL host]
			    port: port
			  target: self
			selector: @selector(socketDidConnect:context:
				      exception:)
			 context: nil];
		[sock asyncConnectToHost: [URL host]
				    port: port
				  target: self
				selector: @selector(socketDidConnect:context:
					      exception:)
				 context: nil];
	} @catch (id e) {
		[_client->_delegate client: _client
		     didEncounterException: e
				forRequest: _request
				   context: _context];
	}
}
@end

@implementation OFHTTPClientResponse
@synthesize of_keepAlive = _keepAlive;

- (instancetype)initWithSocket: (OFTCPSocket *)sock