ObjFW  Diff

Differences From Artifact [3269a913de]:

To Artifact [cc46fb2dcd]:


38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
38
39
40
41
42
43
44

45
46
47
48
49
50
51
52







-
+







#import "macros.h"

Class of_http_request_tls_socket_class = Nil;

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

	while (*str != '\0') {
		if (!isalnum(*str)) {
			firstLetter = YES;
			str++;
			continue;
258
259
260
261
262
263
264
265

266
267
268
269
270
271
272
258
259
260
261
262
263
264

265
266
267
268
269
270
271
272







-
+







		if (requestType == OF_HTTP_REQUEST_TYPE_POST) {
			if ([headers objectForKey: @"Content-Type"] == nil)
				[sock writeString: @"Content-Type: "
				   @"application/x-www-form-urlencoded\r\n"];

			if ([headers objectForKey: @"Content-Length"] == nil)
				[sock writeFormat: @"Content-Length: %d\r\n",
				    [queryString cStringLength]];
				    [queryString UTF8StringLength]];
		}

		[sock writeString: @"\r\n"];

		/* Work around a bug in lighttpd, see above */
		[sock flushWriteBuffer];
		[sock setBuffersWrites: NO];
287
288
289
290
291
292
293
294

295
296
297
298
299
300
301
302
303
304


305
306
307
308
309
310
311

312
313
314
315
316
317
318
287
288
289
290
291
292
293

294
295
296
297
298
299
300
301
302


303
304
305
306
307
308
309
310

311
312
313
314
315
316
317
318







-
+








-
-
+
+






-
+







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

		serverHeaders = [OFMutableDictionary dictionary];

		while ((line = [sock readLine]) != nil) {
			OFString *key, *value;
			const char *line_c = [line cString], *tmp;
			const char *line_c = [line UTF8String], *tmp;

			if ([line isEqual: @""])
				break;

			if ((tmp = strchr(line_c, ':')) == NULL)
				@throw [OFInvalidServerReplyException
				    newWithClass: isa];

			key = [OFString stringWithCString: line_c
						   length: tmp - line_c];
			key = [OFString stringWithUTF8String: line_c
						      length: tmp - line_c];
			normalize_key(key);

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

			value = [OFString stringWithCString: tmp];
			value = [OFString stringWithUTF8String: tmp];

			if ((redirects > 0 && (status == 301 || status == 302 ||
			    status == 303) && [key isEqual: @"Location"]) &&
			    (redirectsFromHTTPSToHTTPAllowed ||
			    [scheme isEqual: @"http"] ||
			    ![value hasPrefix: @"http://"])) {
				OFURL *new;