ObjFW  Diff

Differences From Artifact [a601f5af31]:

To Artifact [209c55758d]:


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
571
572
573
574

575













576
577
578
579
580
581
582
			   forKey: key];

	return true;
}

- (bool)stream: (OF_KINDOF(OFStream *))sock
   didReadLine: (OFString *)line

{
	bool ret;










	@try {
		if (_firstLine) {
			_firstLine = false;
			ret = [self handleFirstLine: line];
		} else
			ret = [self handleServerHeader: line
						socket: sock];
	} @catch (id e) {
		[self raiseException: e];
		ret = false;
	}

	return ret;
}

-		(void)stream: (OF_KINDOF(OFStream *))sock
  didFailToReadWithException: (id)exception
{
	if ([exception isKindOfClass: [OFInvalidEncodingException class]])
		exception = [OFInvalidServerReplyException exception];

	[self raiseException: exception];
}

-		 (void)stream: (OF_KINDOF(OFStream *))sock
  didFailToWriteWithException: (id)exception
{
	if ([exception isKindOfClass: [OFWriteFailedException class]] &&
	    ([exception errNo] == ECONNRESET || [exception errNo] == EPIPE)) {
		/* In case a keep-alive connection timed out */
		[self closeAndReconnect];
		return;
	}

	[self raiseException: exception];
}

- (size_t)stream: (OF_KINDOF(OFStream *))sock
  didWriteBuffer: (const void **)request
	  length: (size_t)length

{













	_firstLine = true;

	[_requestString release];
	_requestString = nil;

	if ([[_request headers] objectForKey: @"Content-Length"] != nil) {
		[sock setDelegate: nil];







>


>
>
>
>
>
>
>
>
>
















<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<



>

>
>
>
>
>
>
>
>
>
>
>
>
>







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
571
572
573
574
575
576
577
578
579
580
581
582
583
584
			   forKey: key];

	return true;
}

- (bool)stream: (OF_KINDOF(OFStream *))sock
   didReadLine: (OFString *)line
     exception: (id)exception
{
	bool ret;

	if (exception != nil) {
		if ([exception isKindOfClass:
		    [OFInvalidEncodingException class]])
			exception = [OFInvalidServerReplyException exception];

		[self raiseException: exception];
		return false;
	}

	@try {
		if (_firstLine) {
			_firstLine = false;
			ret = [self handleFirstLine: line];
		} else
			ret = [self handleServerHeader: line
						socket: sock];
	} @catch (id e) {
		[self raiseException: e];
		ret = false;
	}

	return ret;
}























- (size_t)stream: (OF_KINDOF(OFStream *))sock
  didWriteBuffer: (const void **)request
	  length: (size_t)length
       exception: (id)exception
{
	if (exception != nil) {
		if ([exception isKindOfClass: [OFWriteFailedException class]] &&
		    ([exception errNo] == ECONNRESET ||
		    [exception errNo] == EPIPE)) {
			/* In case a keep-alive connection timed out */
			[self closeAndReconnect];
			return 0;
		}

		[self raiseException: exception];
		return 0;
	}

	_firstLine = true;

	[_requestString release];
	_requestString = nil;

	if ([[_request headers] objectForKey: @"Content-Length"] != nil) {
		[sock setDelegate: nil];
620
621
622
623
624
625
626

627
628





629
630
631
632
633
634
635
		return;
	}
}

-     (void)socket: (OF_KINDOF(OFTCPSocket *))sock
  didConnectToHost: (OFString *)host
	      port: (uint16_t)port

{
	[(OFTCPSocket *)sock setDelegate: self];






	if ([_client->_delegate respondsToSelector:
	    @selector(client:didCreateSocket:request:context:)])
		[_client->_delegate client: _client
			   didCreateSocket: sock
				   request: _request
				   context: _context];







>


>
>
>
>
>







622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
		return;
	}
}

-     (void)socket: (OF_KINDOF(OFTCPSocket *))sock
  didConnectToHost: (OFString *)host
	      port: (uint16_t)port
	 exception: (id)exception
{
	[(OFTCPSocket *)sock setDelegate: self];

	if (exception != nil) {
		[self raiseException: exception];
		return;
	}

	if ([_client->_delegate respondsToSelector:
	    @selector(client:didCreateSocket:request:context:)])
		[_client->_delegate client: _client
			   didCreateSocket: sock
				   request: _request
				   context: _context];