views:

45

answers:

1

Hi! I'm trying to guarantee a file transfer. I guess that I could do it with some kind of checksum.

Also, because of some inner issues, I need to do it with streaming.

I thought of calculating a digest before and after the transfer but the error would appear only at the end of the transfer. I'm searching for some kind of chunked checksum with re-send if any error.

Any suggestion?

Thanks!

A: 

I think you're going to have to do something at a higher level in the stack - HTTP doesn't have the capability to retransmit part of the response mid-stream. Once the client makes an HTTP request, it must receive the entire HTTP response before it can make another request. HTTP chunking is mostly to facilitate keep-alive connections without having to calculate the content-length of the response ahead of time.

If we're talking about a custom client and server here (which I assume we are since this question wouldn't make sense if you're talking about a browser) then maybe one way to do it would be for the server to chop the file into pieces and have the client request each piece of the file one at a time using a keep-alive connection. If you send back a checksum for each piece in the response (i.e. in an ETag header), you could calculate the checksum on the client to ensure you received the correct bytes. If the checksum doesn't match, just have the client request that chunk over again.

Marc Novakowski
I was thinking in some way to add a tag to the header, like you said, with the digest. I don't know how to do it, but let's study! I'll look into the ETag suggestion. Thanks!One thing is a surprise for me: there's no library for this?
daigorocub
If you're using Java then I recommend using the Apache HttpClient library to make your life easier. You'll have a lot more control over the client connections and how they are handled (i.e. keep alives, headers, etc.)
Marc Novakowski
thanks! I'm studying the Apache HttpClient library. But I found the word I was missing: transactional. Does it ring any bell? Transactional file upload with java?
daigorocub