how to tell the http server stop sending redundant bytes that i previously
requested through "get"?
Say I want to download a file on a http server which supports segmenting
downloading. For example:
url to the file: www.music.com/rock.mp3
length of file: 4000 bytes
Say I launched two threads and each is downloading half of bytes of file.
thread t1 downloads bytes from 0 to 1999
thread t2 downloads bytes from 2000 to 3999
Say that t2 finished downloading down the later half, and t1 only
downloaded up to bytes 1199 yet, so t1 still has bytes 1200 to 1999 to go,
which is 800 bytes in total.
Now I want t1 keep downloading, up to bytes 1599, and let t2 start
download from byte 1600 to byte 1999. I see no problem of doing this with
t2, I just need to send another get message with range from 1600 to 1999.
But when I launched t1, it originally sent get message from range 0 to
1999, not from 0 to 1599, so it will keep getting bytes until the byte
1999 is delivered to my machine, which in t1's perspective include some
redundant bytes..
So for t1, is there any way to tell the server that, "ok plan changed I
only need up to 1599, don't send bytes from 1600"? One workaround that I
can come up with is just letting t1 not storing any bytes from byte 1599,
but it still consumes the bandwith and affect the network throughput. I am
doing this to make a dynamic segment downloading scheme to boost up the
downloading speed, so that's why I am concerned with speed and throughput
here. I imagine if it's a larg file, say maybe 1G, and using two threads,
then in worst case, the redundant bytes I have to discard would be a
lot....
In above scenario, when t2 finished its job from 2000 to 3999 and about to
grab bytes from 1600 to 1999, will t2 use the same http connection to grab
new range of bytes in default or I should do something before hand to make
it happen? And I am right that in such case, using same connection is
better than closing and opening another connection?
No comments:
Post a Comment