From b3e1af78e7cb5befa4efecf7d23aff6779812812 Mon Sep 17 00:00:00 2001 From: Corey Donohoe Date: Tue, 17 Jan 2012 18:19:10 -0800 Subject: [PATCH] actually stop following after N redirects --- server.coffee | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/server.coffee b/server.coffee index 99d38cf..d7b3e77 100644 --- a/server.coffee +++ b/server.coffee @@ -95,13 +95,15 @@ process_url = (url, transferred_headers, resp, remaining_redirects) -> when 301, 302 if remaining_redirects <= 0 four_oh_four(resp, "Exceeded max depth") - is_finished = false - newUrl = Url.parse srcResp.headers['location'] - unless newUrl.host? and newUrl.hostname? - newUrl.host = newUrl.hostname = url.hostname - newUrl.protocol = url.protocol - - process_url newUrl, transferred_headers, resp, remaining_redirects - 1 + else + is_finished = false + newUrl = Url.parse srcResp.headers['location'] + unless newUrl.host? and newUrl.hostname? + newUrl.host = newUrl.hostname = url.hostname + newUrl.protocol = url.protocol + + console.log newUrl + process_url newUrl, transferred_headers, resp, remaining_redirects - 1 when 304 resp.writeHead srcResp.statusCode, newHeaders else