hello,

when I "put" a file using the command line client, here is what I see, at the HTTP level (client side).

PUT /slide/files/octa/run.bat HTTP/1.1
Transfer-Encoding: chunked
Expect: 100-continue
Cookie: $Version=1;JSESSIONID=27nd1jad7peet; $Path=/slide; $Domain=localhost
Host: localhost:8081
User-Agent: Jakarta HTTP Client/1.0

c1
@echo off
set CP2=%CLASSPATH%;../lib/webdav.jar;../lib/jaxp.jar;../lib/crimson.jar;../lib/commons-httpclient.jar
java -classpath %CP2% org.apache.webdav.cmd.Slide %1 %2 %3 %4 %5 %6 %7 %8 %9


0


when I use a java class, built on top of the WebDAV library, I get this:


PROPFIND /slide/files/octa/ HTTP/1.1
Content-Length: 207
Content-Type: text/xml; charset=utf-8
Host: localhost:8081
Depth: 0
User-Agent: Jakarta HTTP Client/1.0

<?xml version="1.0" encoding="utf-8" ?><D:propfind xmlns:D="DAV:"><D:prop><D:displayname/><D:getcontentlength/><D:getcontenttype/><D:resourcetype/><D:getlastmodified/><D:lockdiscovery/></D:prop></D:propfind>PUT / HTTP/1.1
Transfer-Encoding: chunked
Expect: 100-continue
Cookie: $Version=1
Host: localhost:8081
User-Agent: Jakarta HTTP Client/1.0


95


Why does my command line client (extremely simple, code included, 30 lines) do use the "PROPFIND" method instead of the POST?


Any idea?

Thanks a lot,

Stan.
/**
 *
 *
 */
package com.axone.repository;

import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.MalformedURLException;

import org.apache.webdav.lib.WebdavResource;

import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.util.HttpURL;

/**
 * This class acts as a facade to specific 
 * implementations of WebDav libraries.
 * Basic functionalities provided are:
 * - add a file to the WebDav filesystem.
 *
 * NOTE: at first, we implement a flat storage strategy.
 */
public class WebDavClient
{
    private String user = "root";
    private String password = "root";
    private String hostPort = "";
    private String davPath = "";
    
    /**
     * add a file to the repository.
     */
    public URI addFile(String path) throws MalformedURLException, 
                                           HttpException,
                                           IOException, 
                                           URISyntaxException
    {        
        File file = new File(path);
        //InputStream stream = new FileInputStream(path);
        String fileName = file.getName();
        WebdavResource resource = getResource();

        if (!file.exists())
        {
            throw new IOException("file does not exist: " + file);
        }

        //resource.setDebug(8);
        System.out.println("adding: [" + fileName + "]");        
        //boolean succeeded = resource.putMethod(fileName, "test data...\n");
        boolean succeeded = resource.putMethod(fileName, file);
        if (!succeeded)
        {
            throw new IOException(resource.getStatusMessage());
        }
        return new URI(hostPort + davPath + fileName);
    }

    private WebdavResource getResource() throws MalformedURLException, 
                                               HttpException,
                                               IOException
    {
        HttpURL url = new HttpURL(hostPort + davPath);
        //HttpURL url = new HttpURL("http:://localhost:8086/slide/files/octa/");
        url.setUserInfo(user, password);
        return new WebdavResource(url);
    }

    public void list() throws Exception
    {
        WebdavResource resource = getResource();
        String[] paths = resource.list();
        
        for (int i=0; i<paths.length; i++)
        {
            System.out.println("path: " + paths[i]);
        }
    }

    public static void main(String[] args) throws Exception
    {

        if (args.length != 3)
        {
            System.out.println("Usage: java com.axone.repository.WebDavClient 
davServer davPath documentPath");
            System.exit(1);
        }       
        WebDavClient client = new WebDavClient();
        client.hostPort = args[0];
        client.davPath = args[1];
        System.out.println("added: [" + client.addFile(args[2]) + "]");        
        //client.list();
    }
}

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.507 / Virus Database: 304 - Release Date: 04/08/2003

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to