ObjFW  Diff

Differences From Artifact [38cf4b12f6]:

To Artifact [d38e8f0fed]:

  • File src/OFHTTPClient.m — part of check-in [75c12eaf7b] at 2014-07-05 09:11:42 on branch trunk — 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. (user: js, size: 16064) [annotate] [blame] [check-ins using]


407
408
409
410
411
412
413












414
415
416
417
418
419
420
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];