Re: [SOLVED] PUT with Content-Range Header

Tiffany Dodge <[email protected]>
Newsgroups gmane.comp.jakarta.slide.user
Message-ID <[email protected]>
Hello,

I cannot post the actual code I added to slide to get this to work,  
but I will verbally describe what I did.  This fix/patch will only  
work with webdav servers that support the Content-Range header for  
PUTs.  At the moment, I only know of Apache's mod_dav that supports  
it, but that doesn't mean others don't.  Also, I have only tested  
this with Apache's mod_dav.  Here's the specifics on what I am using:

Slide 2.1
Apache/1.3.33 (Darwin)
DAV/1.0.3

In WebdavResource.java, I copied the method 'public boolean putMethod 
(String path, byte[] data)', renamed it to putPartialMethod, and  
added three more arguments to it: the beginning index, the ending  
index, and the full length of the file/resource.  In the method, I  
keep everything exactly the same but add a few lines to add the  
Content-Range header.  Here are the rules about the Content-Range  
header: http://www.w3.org/Protocols/rfc2616/rfc2616- 
sec14.html#sec14.16 .

The caller of putPartialMethod should only pass the chunk of the file/ 
resource that should be uploaded.  And the data argument's length  
should be the exact length of the chunk being uploaded.  So the data  
argument's length should be (ending index - beginning index + 1).   
That's about it.  Here's a few items to remember when using the  
putPartialMethod ....

- The beginning and ending indexes are inclusive.  So, if you upload  
bytes 4-7 of a file with length 9, then bytes 4, 5, 6, and 7 will be  
uploaded.  http://www.w3.org/Protocols/rfc2616/rfc2616- 
sec14.html#sec14.16 has an example.
- The ending index cannot be equal to the full file's length.  So, if  
a file's length is 9 and you want to upload all the bytes, then the  
beginning index would be 0 and the ending index would be 8.

We have found the putPartialMethod to be useful for resumed uploads  
and for logging a file's upload progress.  We upload a chunk of a  
file, log the progress, upload a chunk, log the progress, etc.

Hope that helps,
Tiff

On Aug 24, 2006, at 12:19 PM, Tiffany Dodge wrote:

> Hello,
>
> I recently read that Apache's mod_dav supports PUTs with the  
> Content-Range header and I am interested in using it.
>
> I am working on a non-gui client app that uses slide.  I added a  
> new put method to slide (to WebdavResource.java, specifically) that  
> adds the Content-Range header.  Basically, I copied one of the  
> existing put methods (the one that takes a path and file argument)  
> and just added the bit of code that adds the Content-Range header.   
> It did not work; webdav had the full file (not the chunk  
> specified).  I was wondering if anyone else had tried this and if  
> they had been successful?  Here are the headers from the test I  
> used ....
>
> request headers ...
>
> [DEBUG] wire - ->> "PUT /blahDir/blah.aes HTTP/1.1[\r][\n]"
> [DEBUG] wire - ->> "Content-Range: bytes 0-524288/2945360[\r][\n]"
> [DEBUG] wire - ->> "Content-Type: httpd/unix-directory[\r][\n]"
> [DEBUG] wire - ->> "User-Agent: Jakarta Commons-HttpClient/2.0final 
> [\r][\n]"
> [DEBUG] wire - ->> "Host: blah.blah.com[\r][\n]"
> [DEBUG] wire - ->> "Content-Length: 2945360[\r][\n]"
> [DEBUG] wire - ->> "[\r][\n]"
>
> response headers ...
>
> [DEBUG] wire - -<< "HTTP/1.1 201 Created[\r][\n]"
> [DEBUG] wire - -<< "Date: Thu, 24 Aug 2006 01:31:52 GMT[\r][\n]"
> [DEBUG] wire - -<< "Server: Apache/1.3.33 (Darwin) PHP/5.1.2  
> mod_fastcgi/2.4.2 DAV/1.0.3 mod_ssl/2.8.24 OpenSSL/0.9.7i[\r][\n]"
> [DEBUG] wire - -<< "Cache-Control: max-age=60[\r][\n]"
> [DEBUG] wire - -<< "Expires: Thu, 24 Aug 2006 01:32:52 GMT[\r][\n]"
> [DEBUG] wire - -<< "Connection: close[\r][\n]"
> [DEBUG] wire - -<< "Transfer-Encoding: chunked[\r][\n]"
> [DEBUG] wire - -<< "Content-Type: text/html[\r][\n]"
>
> Any help would be appreciated.
>
> Thanks,
> Tiff
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.