ObjFW  Check-in [75c12eaf7b]

Overview
Comment:OFHTTPClient: Defaults for Content-{Type,Length}

In case the entity body has been set, but the headers don't contain
Content-Type and/or Content-Length, assume a default of
"application/x-www-form-urlencoded; charset=UTF-8" for the Content-Type
and set the Content-Length to the number of bytes of the entity body.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 75c12eaf7b95cff4b7d8e9eb9da10098d8e1224cafb6440e5ed03d38d9ee530a
User & Date: js on 2014-07-05 09:11:42
Other Links: manifest | tags
Context
2014-07-05
09:14
OFHTTPRequest: Add -[setEntityFromString:] check-in: 5109a3e7e4 user: js tags: trunk
09:11
OFHTTPClient: Defaults for Content-{Type,Length} check-in: 75c12eaf7b user: js tags: trunk
08:32
OFHTTPClient: Add support for Basic Authorization check-in: 29f7a25643 user: js tags: trunk
Changes

Modified src/OFHTTPClient.m from [38cf4b12f6] to [d38e8f0fed].

407
408
409
410
411
412
413












414
415
416
417
418
419
420
		    [authorization stringByBase64Encoding]];
	}

	if ([headers objectForKey: @"User-Agent"] == nil)
		[requestString appendString:
		    @"User-Agent: Something using ObjFW "
		    @"<https://webkeks.org/objfw>\r\n"];













	keyEnumerator = [headers keyEnumerator];
	objectEnumerator = [headers objectEnumerator];

	while ((key = [keyEnumerator nextObject]) != nil &&
	    (object = [objectEnumerator nextObject]) != nil)
		[requestString appendFormat: @"%@: %@\r\n", key, object];







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







407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
		    [authorization stringByBase64Encoding]];
	}

	if ([headers objectForKey: @"User-Agent"] == nil)
		[requestString appendString:
		    @"User-Agent: Something using ObjFW "
		    @"<https://webkeks.org/objfw>\r\n"];

	if (entity != nil) {
		if ([headers objectForKey: @"Content-Length"] == nil)
			[requestString appendFormat:
			    @"Content-Length: %zd\r\n",
			    [entity itemSize] * [entity count]];

		if ([headers objectForKey: @"Content-Type"] == nil)
			[requestString appendString:
			    @"Content-Type: application/x-www-form-urlencoded; "
			    @"charset=UTF-8\r\n"];
	}

	keyEnumerator = [headers keyEnumerator];
	objectEnumerator = [headers objectEnumerator];

	while ((key = [keyEnumerator nextObject]) != nil &&
	    (object = [objectEnumerator nextObject]) != nil)
		[requestString appendFormat: @"%@: %@\r\n", key, object];