import java.io.*;
import java.util.*;
import java.net.*;

import java.net.*;

public class Source   {

    static Socket con;	

    public static void main(String args[]) throws Exception    {
        String address = InetAddress.getLocalHost().toString();
        String host = address.substring(address.lastIndexOf("/")+1);
//        System.out.println(host);

		con = new Socket(host,8080);
        InputStream   is = con.getInputStream();
        OutputStream  os = con.getOutputStream();

//		String path="/webdav/Domain.xml";
		String path="/slide/files/a";
        
        
        String body = "";

        body  = "<?xml version=\"1.0\" ?>";
        body += "<A:propertyupdate xmlns:A=\"DAV:\" xmlns:Z=\"DAV:\">";
        body +=   "<A:set>";
        body +=     "<A:prop>";
        body +=       "<Z:test>dirk</Z:test>";
        body +=     "</A:prop>";
        body +=   "</A:set>";
        body += "</A:propertyupdate>";

        	     

        os.write(("PROPPATCH " + path + " HTTP/1.1\r\n").getBytes());
		os.write(("Host: "+host+":8080\r\n").getBytes());
        os.write("Connection: TE\r\n".getBytes());
        os.write("TE: trailers, deflate, gzip, compress\r\n".getBytes());
		os.write("Content-Type: text/xml\r\n".getBytes());
		os.write(("Content-Length: "+body.length() + "\r\n").getBytes());

		os.write("\r\n".getBytes());

		os.write(body.getBytes());





	System.out.println("=============== Outbound Message Headers =================");
	System.out.println("PROPPATCH " + path + " HTTP/1.1");
	System.out.println("Host: "+host+":8080");
    System.out.println("Connection: TE");
    System.out.println("TE: trailers, deflate, gzip, compress");
	System.out.println("Content-Type: text/xml");
	System.out.println("Content-Length: "+body.length());
//	System.out.println("\n");
//	System.out.println(body);
//	System.out.println("\n\n");
	System.out.println("=============== Outbound Message Body =================");
	System.out.println(body);
	System.out.println("=============== Inbound Stream =================");


	try
	{
		int ch=0;
//		System.out.println("First");
		while ((ch = is.read())!=-1) {
//			System.out.println("Next");
			System.out.print((char) ch);
		}
	}
	catch(Exception ex){
		System.out.println(ex);
	}
	
	System.out.println();
	System.out.println("=============== Inbound Stream Complete =================");
	
    }   
}   

