Ideally, java.net.URL should subclass URI. @see rfc-2396 @version 0.3-3 06/05/2001 @author Ronald Tschal�r @since V0.3-1
272829303132333435363738394041
{ System.err.println("Usage: java GetAuthInfo [-proxy_auth <username> <password>] <url>"); System.exit(1); } URI url = new URI(args[0]); DefaultAuthHandler.setAuthorizationPrompter(new MyAuthPrompter(pa_name, pa_pass)); HTTPConnection con = new HTTPConnection(url); HTTPResponse rsp = con.Head(url.getPathAndQuery()); int sts = rsp.getStatusCode(); if (sts < 300) System.out.println("No authorization required to access " + url); else if (sts >= 400 && sts != 401 && sts != 407)