ObjFW  Diff

Differences From Artifact [382795589b]:

To Artifact [01bffed1c2]:


643
644
645
646
647
648
649
650




651
652

653
654

655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676



677
678
679


680
681
682
683



684
685
686
687
688
689
690
643
644
645
646
647
648
649

650
651
652
653
654

655


656

657
658
659
660
661
662
663

664
665
666

667
668
669
670
671
672



673
674
675
676


677
678

679
680
681
682
683
684
685
686
687
688
689
690
691







-
+
+
+
+

-
+
-
-
+
-







-



-






-
-
-
+
+
+

-
-
+
+
-



+
+
+







			else if (status == 303)
				follow = true;
			else
				follow = false;
		}

		if (follow) {
			OFHTTPRequest *newRequest;
			OFHTTPRequest *newRequest =
			    [[request copy] autorelease];
			OFMutableDictionary *newHeaders =
			    [[headers mutableCopy] autorelease];

			newRequest = [OFHTTPRequest requestWithURL: newURL];
			if (![[newURL host] isEqual: [URL host]])
			[newRequest setMethod: method];
			[newRequest setHeaders: headers];
				[newHeaders removeObjectForKey: @"Host"];
			[newRequest setBody: body];

			/*
			 * 303 means the request should be converted to a GET
			 * request before redirection. This also means stripping
			 * the entity of the request.
			 */
			if (status == 303) {
				OFMutableDictionary *newHeaders;
				OFEnumerator *keyEnumerator, *objectEnumerator;
				id key, object;

				newHeaders = [OFMutableDictionary dictionary];
				keyEnumerator = [headers keyEnumerator];
				objectEnumerator = [headers objectEnumerator];
				while ((key = [keyEnumerator nextObject]) !=
				    nil &&
				    (object = [objectEnumerator nextObject]) !=
				    nil)
					if (![key hasPrefix: @"Content-"])
						[newHeaders setObject: object
							       forKey: key];
					if ([key hasPrefix: @"Content-"])
						[newHeaders
						    removeObjectForKey: key];

				[newRequest
				    setMethod: OF_HTTP_REQUEST_METHOD_GET];
				[newRequest setMethod:
				    OF_HTTP_REQUEST_METHOD_GET];
				[newRequest setHeaders: newHeaders];
				[newRequest setBody: nil];
			}

			[newRequest setURL: newURL];
			[newRequest setHeaders: newHeaders];

			[newRequest retain];
			objc_autoreleasePoolPop(pool);
			[newRequest autorelease];

			return [self performRequest: newRequest
					  redirects: redirects - 1];
		}