All pastes #973486 Raw Edit

Mine

public text v1 · immutable
#973486 ·published 2008-04-06 03:48 UTC
rendered paste body
#!/usr/bin/python

import httplib, time
from urlparse import urlparse

loc = "http://noslor-old/ubuntu-7.04-desktop-i386.iso"
file = open('output', 'wb')

def main():
    global loc, file
    connection = httplib.HTTPConnection(urlparse(loc)[1])
    begin, size = 0, 10485700
    place = begin
    end = begin + size

    connection.request('GET', urlparse(loc)[2])
    response = connection.getresponse()

    start_t = time.time()

    while True:
        data = response.read(4096)
        place += len(data)
        if data == '':
            break
        #file.write(data)
        if place > end:
            break

    end_t = time.time()

    connection.close()
    file.close()

    return end_t - start_t

if __name__ == '__main__':
    print main()