ObjFW  Check-in [d9350dba53]

Overview
Comment:OFHTTPClient: Minor chunked body improvement
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d9350dba538eb658671104d5f3817d80a1e27f990c1ee1284c8998a3c1882f01
User & Date: js on 2020-03-29 03:05:37
Other Links: manifest | tags
Context
2020-03-29
14:04
OFHTTP{Client,Server}: Reject empty Content-Length check-in: e833a8b212 user: js tags: trunk
03:05
OFHTTPClient: Minor chunked body improvement check-in: d9350dba53 user: js tags: trunk
2020-03-28
14:35
OFHTTPClient: Fixes for chunked request bodies check-in: fea4fe86b0 user: js tags: trunk
Changes

Modified src/OFHTTPClient.m from [515705e71c] to [4db698c7b0].

985
986
987
988
989
990
991
992
993












994
995
996
997
998
999
1000
985
986
987
988
989
990
991


992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010







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







		}

		range = [line rangeOfString: @";"];
		if (range.location != OF_NOT_FOUND)
			line = [line substringWithRange:
			    of_range(0, range.location)];

		if (line.length < 1)
			@throw [OFInvalidServerReplyException exception];
		if (line.length < 1) {
			/*
			 * We have read the empty string because the socket is
			 * at end of stream.
			 */
			if (_socket.atEndOfStream &&
			    range.location == OF_NOT_FOUND)
				@throw [OFTruncatedDataException exception];
			else
				@throw [OFInvalidServerReplyException
				    exception];
		}

		@try {
			_toRead = line.hexadecimalValue;
			if (_toRead < 0)
				@throw [OFOutOfRangeException exception];
		} @catch (OFInvalidFormatException *e) {
			@throw [OFInvalidServerReplyException exception];

Modified src/OFHTTPServer.m from [269e3a7f9d] to [b25900c5f7].

231
232
233
234
235
236
237
238

239
240
241
242
243

244
245
246
247
248
249
250
251
231
232
233
234
235
236
237

238
239
240
241
242

243

244
245
246
247
248
249
250







-
+




-
+
-







		[self of_sendHeaders];

	if (!_chunked)
		return [_socket writeBuffer: buffer
				     length: length];

	pool = objc_autoreleasePoolPush();
	[_socket writeString: [OFString stringWithFormat: @"%zx\r\n", length]];
	[_socket writeString: [OFString stringWithFormat: @"%zX\r\n", length]];
	objc_autoreleasePoolPop(pool);

	[_socket writeBuffer: buffer
		      length: length];
	[_socket writeBuffer: "\r\n"
	[_socket writeString: @"\r\n"];
		      length: 2];

	return length;
}

- (void)close
{
	if (_socket == nil)
706
707
708
709
710
711
712
713
714


715
716
717
718
719
720
721
705
706
707
708
709
710
711


712
713
714
715
716
717
718
719
720







-
-
+
+







		range = [line rangeOfString: @";"];
		if (range.location != OF_NOT_FOUND)
			line = [line substringWithRange:
			    of_range(0, range.location)];

		if (line.length < 1) {
			/*
			 * We read the empty string because the socket is at
			 * end of stream.
			 * We have read the empty string because the socket is
			 * at end of stream.
			 */
			if (_socket.atEndOfStream &&
			    range.location == OF_NOT_FOUND)
				@throw [OFTruncatedDataException exception];
			else
				@throw [OFInvalidFormatException exception];
		}