http put method

I'm testing http put meyjhod with jigsaw server. And there's no way to make
it work.
I define a PutableDirectory resource (named '/putable'), and I use as
client, the java api 'upload' that you published in this list.

The Api is as follows:
// upload.java

 import java.io.*;

 import java.net.*;

 import w3c.www.mime.*;

 import w3c.www.http.*;

import w3c.www.protocol.http.*;



/**

* Upload a single file, using HTTP.

*/



public class PutApi {

protected static boolean debug = true;



/**

* Copy the given source of given type, to given location.

* @param type The MIME type of the source.

* @param src The source to copy.

* @param dst The destination URL.

*/



protected static boolean copy(MimeType type, File src, URL dst)

throws IOException, HttpException

{

HttpManager manager = HttpManager.getManager();

// Get a handle to the source stream:

InputStream in = new BufferedInputStream(new FileInputStream(src));

// Prepare an HTTP request:

Request request = manager.createRequest();

request.setMethod("PUT");

request.setURL(dst);

request.setContentLength((int) src.length());

request.setContentType(type);

request.setOutputStream(in);

if ( debug )

request.dump(System.out);

// Run the request:

Reply reply = manager.runRequest(request);

if ( debug )

reply.dump(System.out);

in.close();

// Check the reply status:

return (reply.getStatus() / 200 == 2);

}



public static void usage() {

System.out.println("PutApi [-t <mime-type>] [-d] <src> <dst>");

System.out.println("src: URL of source.");

System.out.println("dst: URL of destination.");

System.exit(1);

}



public static void main(String args[]) {

File src = null;

URL dst = null;

MimeType type = MimeType.TEXT_HTML;



// Check args:

for (int i = 0 ; i < args.length ; i++) {

if ( args[i].equals("-t") && (i+1 < args.length)) {

try {

type = new MimeType(args[++i]);

} catch (Exception ex) {

System.out.println("Invalid mime type: "+args[i]);

}

} else if ( args[i].equals("-d") ) {

debug = true;

} else if ( i + 2 == args.length ) {

// Get the source:

src = new File(args[i]);

if ( ! src.exists() ) {

System.out.println("Couldn't find "+args[i]);

System.exit(1);

}

// Get the destination:

try {

dst = new URL(args[++i]);

} catch (Exception ex) {

System.out.println(args[i]+": invalid URL.");

}

} else {

usage();

}

}

if ((src == null) || (dst == null))

usage();

// Perform the task:

try {

if ( copy(type, src, dst) )

System.out.println("Copy failed.");

else

System.out.println("Copy done.");

} catch (Exception ex) {

ex.printStackTrace();

}

System.exit(0);

}

}


The answer I get is as follows:

C:\java\prova>java PutApi cv.txt http://127.1.1.1:8000/putable
PUT /putable HTTP/1.1
Date: Wed, 10 Sep 1997 16:47:17 GMT
Content-Length: 7847
Content-Type: text/html
Accept: */*
Host: 127.1.1.1:8000
User-Agent: Jigsaw/1.0b

HTTP/1.1 302 Moved Temporarily
Date: Wed, 10 Sep 1997 16:47:18 GMT
Content-Length: 188
Content-Type: text/html
Location: http://127.1.1.1:8000/putable/
Server: 1.0beta1

Copy done.

C:\java\prova>

Where's the problem???

Thanks

oooooooooooooooooooooo
    Pere Mayol de Tord
       perem@ibm.net
oooooooooooooooooooooo

Received on Thursday, 11 September 1997 14:23:09 UTC