[jcifs] Hosts and shares enumeration
Michael B Allen
mba2000 at ioplex.com
Wed Jun 30 00:21:20 GMT 2004
eglass1 at comcast.net said:
> This fixes the HTTP POST issues seen previously; should also work with the
> XML-RPC stuff (I *think*).
Two things are a little awkward.
1) Authentication failure generates an "IllegalStateException: Already
connected". I haven't traced this down but would it be possible to throw a
regular exception (e.g. IOException) with the SmbAuthException text? That
would be much more infomative.
$ java -Djcifs.properties=../miallen.prp HttpURL
http://myserver:8080/jcifs/TestServlet
Exception in thread "main" java.lang.IllegalStateException: Already connected
at java.net.URLConnection.setRequestProperty(URLConnection.java:913)
at
sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:1501)
at
jcifs.http.NtlmHttpURLConnection.doHandshake(NtlmHttpURLConnection.java:444)
at
jcifs.http.NtlmHttpURLConnection.handshake(NtlmHttpURLConnection.java:103)
at
jcifs.http.NtlmHttpURLConnection.getInputStream(NtlmHttpURLConnection.java:240)
at java.net.URL.openStream(URL.java:913)
at HttpURL.main(HttpURL.java:14)
2) When specifying credentials in the HTTP URL the domain separator is '\'
or '/' which are both illegal characters in the authority component. I
think it was determined at one time that the only valid separator
character in the authority component that is not already reserved is ';'.
That's what the SMB URL uses.
Finally, how do I do a POST request? The following code does not work. It
doesn't even send an HTTP request at all.
import java.io.*;
import java.net.*;
public class HttpPut {
public static void main( String[] args ) throws Exception {
jcifs.Config.registerSmbURLHandler();
URL url = new URL(args[0]);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod("PUT");
con.connect();
PrintStream out = new PrintStream( con.getOutputStream() );
out.println( "This is some POST data" );
out.flush();
Thread.sleep( 10000 );
}
}
Mike
More information about the jcifs
mailing list