#65 Redirect limit is cumulative across multiple requests

open
nobody
None
5
2007-10-18
2007-10-18
Quietust
No

When using Snoopy to post multiple pages in a long sequence, the class variable "_redirectdepth" is not reset after each request - thus, after enough redirects have been made across ANY number of requests (e.g. fetch 5 URLs, each of which redirects once, using the default max depth of 5 requests), all subsequent redirects will not be followed, instead causing Snoopy to report status 3xx Moved instead of 200 OK.

My fix was simply to add the following line to the beginning of fetch() and submit():

$this->_redirectdepth = 0;

Discussion

  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2010-02-09

    Of course, that causes infinite redirects.

    Instead, you could do
    $this->_redirectdepth--;
    in many places to counteract the increments.

     
  • Quietust

    Quietust - 2010-02-09

    Maybe it's just me, but decrementing _redirectdepth to counteract the increments seems like it would rather defeat the purpose of tracking the redirect depth in the first place.

    My fix failed to take into account that fetch() and submit() are called both by end-user code AND the redirect logic (which seems a bit odd) - a proper fix would be to either use distinct functions for the two cases (e.g. have the redirect logic call _fetch() and _submit() instead) and only set _redirectdepth to 0 in the user-called versions, or to instead set _redirectdepth to 0 at the *end* of processing (i.e. once the page finishes downloading or the redirect limit is reached).

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks