ObjFW  Diff

Differences From Artifact [0d964b4cba]:

To Artifact [90f1585c87]:


44
45
46
47
48
49
50


51
52
53
54
55
56
57
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59







+
+







#import "OFNotOpenException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFUnsupportedProtocolException.h"
#import "OFUnsupportedVersionException.h"
#import "OFWriteFailedException.h"

#import "socket_helpers.h"

#define REDIRECTS_DEFAULT 10

@interface OFHTTPClientRequestHandler: OFObject <OFTCPSocketDelegate>
{
@public
	OFHTTPClient *_client;
878
879
880
881
882
883
884
885

886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
880
881
882
883
884
885
886

887
888
889






890
891
892
893
894
895
896







-
+


-
-
-
-
-
-







				       length: length];

		if (ret > length)
			@throw [OFOutOfRangeException exception];

		_toRead -= ret;

		if (_toRead == 0) {
		if (_toRead == 0)
			_atEndOfStream = true;

			if (!_keepAlive) {
				[_socket release];
				_socket = nil;
			}
		}

		return ret;
	}

	/* Chunked */
	if (_toRead > 0) {
		if (length > _toRead)
			length = (size_t)_toRead;
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
943
944
945
946
947
948
949



950
951
952
953
954
955
956







-
-
-







					@throw [OFInvalidServerReplyException
					    exception];
				}

				if (line.length > 0)
					@throw [OFInvalidServerReplyException
					    exception];
			} else {
				[_socket release];
				_socket = nil;
			}
		}

		objc_autoreleasePoolPop(pool);

		return 0;
	}
976
977
978
979
980
981
982
983

984
985
986
987
988
989
990
969
970
971
972
973
974
975

976
977
978
979
980
981
982
983







-
+








	return _atEndOfStream;
}

- (int)fileDescriptorForReading
{
	if (_socket == nil)
		return -1;
		return INVALID_SOCKET;

	return _socket.fileDescriptorForReading;
}

- (bool)hasDataInReadBuffer
{
	return (super.hasDataInReadBuffer || _socket.hasDataInReadBuffer);