Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
actually stop following after N redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
atmos committed Jan 18, 2012
1 parent 05e0e9f commit b3e1af7
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions server.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b3e1af7

Please sign in to comment.