Package DebTorrent :: Package BT1 :: Module HTTPDownloader :: Class SingleDownload
[hide private]
[frames] | no frames]

Class SingleDownload

source code

Control HTTP downloads from a single site.

Instance Methods [hide private]
 
__init__(self, downloader, url)
Initialize the instance.
source code
 
resched(self, len=None)
(Re)Schedule a download from the HTTP seed.
source code
call graph 
boolean
_want(self, index)
Determine whether the piece is needed.
source code
 
download(self)
Start a request for a piece.
source code
call graph 
 
_request(self)
Do the request.
source code
 
request_finished(self)
Process the completed request and schedule another.
source code
boolean
_got_data(self)
Process the returned data from the request.
source code
 
_get_requests(self)
Get the requests for a piece.
source code
boolean
_fulfill_requests(self)
Pass the downloaded data to the storage.
source code
 
_release_requests(self)
Release any pending requests for piece ranges.
source code
string
_request_ranges(self, offset, end)
Build a list of ranges to request from the site.
source code
Instance Variables [hide private]
int _retry_period
the server-specified time to wait before making another request
boolean active
whether there is a download underway
string baseurl
the complete URL to append download info to
boolean cancelled
whether the download has been cancelled
HTTPConnection connection
the connection to the HTTP server
int connection_status
the status code returned by the server for the most recent request
HTTPDownloader downloader
the collection of all HTTP downloads
boolean endflag
whether the download might be in end-game mode
string error
the error received from the server
int errorcount
the number of download errors that have occurred since the last successful download from the site
boolean goodseed
whether there has been a successful download from the seed
  headres
the HTTP headers to send in the request
int index
the piece index currently being downloaded
DebTorrent.CurrentRateMeasure.Measure measure
tracks the download rate from the site
string netloc
the webserver address and port to connect to (from the baseurl
string params
the parameters component from the baseurl
string query
the query component from the baseurl
string received_data
the data returned from the most recent request
int request_size
the total size of all requests
list of requests requests
a list of the requests for a piece's ranges
int retry_period
the time to wait before making another request
string seedurl
the path component from the baseurl
string url
the URL to request from the site
Method Details [hide private]

__init__(self, downloader, url)
(Constructor)

source code 
Initialize the instance.
Parameters:
  • downloader (HTTPDownloader) - the collection of all HTTP downloads
  • url (string) - the base URL to add download info to

resched(self, len=None)

source code 
call graph 
(Re)Schedule a download from the HTTP seed.
Parameters:
  • len (int) - the amount of time to wait before doing the download (seconds)

_want(self, index)

source code 
Determine whether the piece is needed.
Parameters:
  • index (int) - the piece index
Returns: boolean
whether the piece is needed

download(self)

source code 
call graph 

Start a request for a piece.

Finds a new piece to download from the picker, creates the URL for the request, and then starts the request.

_request(self)

source code 

Do the request.

Send the request to the server and wait for the response. Then process the response and save the result.

_got_data(self)

source code 

Process the returned data from the request.

Update the rate measures, pass the data to the storage, mark the piece as complete.
Returns: boolean
whether the data was good

_fulfill_requests(self)

source code 
Pass the downloaded data to the storage.
Returns: boolean
whether the piece was successfully received (hash checked)

_request_ranges(self, offset, end)

source code 
Build a list of ranges to request from the site.
Parameters:
  • offset (long) - the offset within the file that the piece starts at
  • end (long) - the offset within the file that the piece ends at
Returns: string
the comma separated ranges to request