public void setRequestMethod(String method) throws ProtocolException {
        if (connected) {
            throw new ProtocolException("Can't reset method: already connected");
        }
        // This restriction will prevent people from using this class to
        // experiment w/ new HTTP methods using java.  But it should
        // be placed for security - the request String could be
        // arbitrarily long.

        for (int i = 0; i < methods.length; i++) {
            if (methods[i].equals(method)) {
                if (method.equals("TRACE")) {
                    SecurityManager s = System.getSecurityManager();
                    if (s != null) {
                        s.checkPermission(new NetPermission("allowHttpTrace"));
                    }
                }
                this.method = method;
                return;
            }
        }
        throw new ProtocolException("Invalid HTTP method: " + method);
    }
public void setRequestMethod ( String method ) throws ProtocolException { if ( connected ) { throw new ProtocolException ( "Can't reset method: already connected" ) ; } for ( int i = 0 ; i < methods . length ; i ++ ) { if ( methods [ i ] . equals ( method ) ) { if ( method . equals ( "TRACE" ) ) { SecurityManager s = System . getSecurityManager ( ) ; if ( s != null ) { s . checkPermission ( new NetPermission ( "allowHttpTrace" ) ) ; } } this . method = method ; return ; } } throw new ProtocolException ( "Invalid HTTP method: " + method ) ; }
Set the method for the URL request, one of:
<UL>
<LI>GET
<LI>POST
<LI>HEAD
<LI>OPTIONS
<LI>PUT
<LI>DELETE
<LI>TRACE
</UL> are legal, subject to protocol restrictions.  The default
method is GET.

@param method the HTTP method
@exception ProtocolException if the method cannot be reset or if
the requested method isn't valid for HTTP.
@exception SecurityException if a security manager is set and the
method is "TRACE", but the "allowHttpTrace"
NetPermission is not granted.
@see #getRequestMethod()