ObjFW  Check-in [6888885299]

Overview
Comment:OFHTTPClient: Don't depend on OFString internals.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 68888852998c30e4a1471a7e7e469f6714c707f2dd507cb239872bd883512ea2
User & Date: js on 2012-12-09 12:33:41
Other Links: manifest | tags
Context
2012-12-11
11:54
Coding style. check-in: e2877b3d28 user: js tags: trunk
2012-12-09
12:33
OFHTTPClient: Don't depend on OFString internals. check-in: 6888885299 user: js tags: trunk
12:31
Fix +[OFString stringWithUTF8StringNoCopy:…]. check-in: b55b4ab87b user: js tags: trunk
Changes

Modified src/OFHTTPClient.m from [6940cfd80f] to [c9133990ba].

29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
44
45
46
47

48
49
50
51
52
53
54
55
56
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

48
49

50
51
52
53
54
55
56







+











-
+

-







#import "OFDictionary.h"
#import "OFDataArray.h"

#import "OFHTTPRequestFailedException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidServerReplyException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFTruncatedDataException.h"
#import "OFUnsupportedProtocolException.h"
#import "OFUnsupportedVersionException.h"

#import "autorelease.h"
#import "macros.h"

Class of_http_client_tls_socket_class = Nil;

static OF_INLINE void
normalizeKey(OFString *key)
normalizeKey(char *str)
{
	uint8_t *str = (uint8_t*)[key UTF8String];
	BOOL firstLetter = YES;

	while (*str != '\0') {
		if (!isalnum(*str)) {
			firstLetter = YES;
			str++;
			continue;
244
245
246
247
248
249
250

251
252
253
254
255
256
257
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258







+







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

	serverHeaders = [OFMutableDictionary dictionary];

	for (;;) {
		OFString *key, *value;
		const char *line_c, *tmp;
		char *key_c;

		@try {
			line = [sock readLine];
		} @catch (OFInvalidEncodingException *e) {
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];
		}
265
266
267
268
269
270
271




272
273
274











275
276
277
278
279
280
281
266
267
268
269
270
271
272
273
274
275
276



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294







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








		line_c = [line UTF8String];

		if ((tmp = strchr(line_c, ':')) == NULL)
			@throw [OFInvalidServerReplyException
			    exceptionWithClass: [self class]];

		if ((key_c = malloc(tmp - line_c + 1)) == NULL)
			@throw [OFOutOfMemoryException
			    exceptionWithClass: [self class]
				 requestedSize: tmp - line_c + 1];
		key = [OFString stringWithUTF8String: line_c
					      length: tmp - line_c];
		normalizeKey(key);

		memcpy(key_c, line_c, tmp - line_c);
		key_c[tmp - line_c] = '\0';
		normalizeKey(key_c);

		@try {
			key = [OFString stringWithUTF8StringNoCopy: key_c
						      freeWhenDone: YES];
		} @catch (id e) {
			free(key_c);
		}

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

		value = [OFString stringWithUTF8String: tmp];