ObjFW  Check-in [0913a2e1d9]

Overview
Comment:OFHTTP{Client,Server}: Concatenate repeated fields
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 0.8
Files: files | file ages | folders
SHA3-256: 0913a2e1d9ebbc3886685193f9d3e1368d628877772c178fa51dac2f773a0b4b
User & Date: js on 2015-11-02 13:54:15
Other Links: branch diff | manifest | tags
Context
2015-11-02
15:10
OFDate: Use wcsftime on Windows check-in: f585645c21 user: js tags: 0.8
13:54
OFHTTP{Client,Server}: Concatenate repeated fields check-in: 0913a2e1d9 user: js tags: 0.8
2015-10-17
12:18
Fix two forgotten instances of FD_SETSIZE on Win32 check-in: c37ca0932c user: js tags: 0.8
Changes

Modified src/OFHTTPClient.m from [10e2ede1ff] to [824a74cbab].

501
502
503
504
505
506
507
508

509
510
511
512
513
514
515
501
502
503
504
505
506
507

508
509
510
511
512
513
514
515







-
+







		    exceptionWithVersion: version];

	status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];

	serverHeaders = [OFMutableDictionary dictionary];

	for (;;) {
		OFString *key, *value;
		OFString *key, *value, *old;
		const char *lineC, *tmp;
		char *keyC;

		@try {
			line = [socket readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException exception];
544
545
546
547
548
549
550




551
552
553
554
555
556
557
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561







+
+
+
+








		do {
			tmp++;
		} while (*tmp == ' ');

		value = [OFString stringWithUTF8String: tmp];

		old = [serverHeaders objectForKey: key];
		if (old != nil)
			value = [old stringByAppendingFormat: @",%@", value];

		[serverHeaders setObject: value
				  forKey: key];
	}

	[serverHeaders makeImmutable];

	if ([_delegate respondsToSelector:

Modified src/OFHTTPServer.m from [0ddfcecf31] to [c9577b3169].

449
450
451
452
453
454
455
456

457
458
459
460
461
462
463
449
450
451
452
453
454
455

456
457
458
459
460
461
462
463







-
+







	_state = PARSING_HEADERS;

	return true;
}

- (bool)parseHeaders: (OFString*)line
{
	OFString *key, *value;
	OFString *key, *value, *old;
	size_t pos;

	if ([line length] == 0) {
		intmax_t contentLength;

		@try {
			contentLength = [[_headers
495
496
497
498
499
500
501




502
503
504
505
506
507
508
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512







+
+
+
+







	key = [line substringWithRange: of_range(0, pos)];
	value = [line substringWithRange:
	    of_range(pos + 1, [line length] - pos - 1)];

	key = normalizedKey([key stringByDeletingTrailingWhitespaces]);
	value = [value stringByDeletingLeadingWhitespaces];

	old = [_headers objectForKey: key];
	if (old != nil)
		value = [old stringByAppendingFormat: @",%@", value];

	[_headers setObject: value
		     forKey: key];

	if ([key isEqual: @"Host"]) {
		pos = [value
		    rangeOfString: @":"
			  options: OF_STRING_SEARCH_BACKWARDS].location;