diff --git a/panda/src/downloader/httpChannel.I b/panda/src/downloader/httpChannel.I index 456489b956..75cb4d77e8 100644 --- a/panda/src/downloader/httpChannel.I +++ b/panda/src/downloader/httpChannel.I @@ -510,8 +510,30 @@ INLINE void HTTPChannel:: reset() { reset_for_new_request(); reset_to_new(); + _status_list.clear(); } +//////////////////////////////////////////////////////////////////// +// Function: HTTPChannel::preserve_status +// Access: Published +// Description: Preserves the previous status code (presumably a +// failure) from the previous connection attempt. If +// the subsequent connection attempt also fails, the +// returned status code will be the better of the +// previous code and the current code. +// +// This can be called to daisy-chain subsequent attempts +// to download the same document from different servers. +// After all servers have been attempted, the final +// status code will reflect the attempt that most nearly +// succeeded. +//////////////////////////////////////////////////////////////////// +INLINE void HTTPChannel:: +preserve_status() { + _status_list.push_back(_status_entry); +} + + //////////////////////////////////////////////////////////////////// // Function: HTTPChannel::clear_extra_headers // Access: Published diff --git a/panda/src/downloader/httpChannel.cxx b/panda/src/downloader/httpChannel.cxx index 150577604c..d0a50c37c5 100644 --- a/panda/src/downloader/httpChannel.cxx +++ b/panda/src/downloader/httpChannel.cxx @@ -757,11 +757,16 @@ reached_done_state() { } } _status_entry = _status_list[best_i]; + _status_list.clear(); } return false; + } - } else if (_download_dest == DD_none) { + // We don't need the list of previous failures any more--we've connected. + _status_list.clear(); + + if (_download_dest == DD_none) { // All done. return false; @@ -806,7 +811,7 @@ run_try_next_proxy() { close_connection(); reconsider_proxy(); _state = S_connecting; - nassertr(_status_list.size() == _proxy_next_index - 1, false); + return false; } @@ -2170,7 +2175,6 @@ reset_for_new_request() { _last_status_code = 0; _status_entry = StatusEntry(); - _status_list.clear(); _response_type = RT_none; _redirect_trail.clear(); diff --git a/panda/src/downloader/httpChannel.h b/panda/src/downloader/httpChannel.h index 52947193d3..00d5006b15 100644 --- a/panda/src/downloader/httpChannel.h +++ b/panda/src/downloader/httpChannel.h @@ -147,6 +147,7 @@ PUBLISHED: void write_headers(ostream &out) const; INLINE void reset(); + INLINE void preserve_status(); INLINE void clear_extra_headers(); INLINE void send_extra_header(const string &key, const string &value);