Code example for HttpRequest

Methods: getRequestLine

0
     * example, if the URI is "http://localhost/remote/library/files?type=audio" 
     * and the prefix is "/library", then the target is "/files".  
     */ 
    public static String getUriTarget(HttpRequest request, String uriPrefix) throws IOException {
        // Get uri string. 
        String uriStr = request.getRequestLine().getUri();
         
        // Strip off uri prefix. 
        int pos = uriStr.indexOf(uriPrefix);
        if (pos < 0) throw new IOException("Invalid URI");
        String uriTarget = uriStr.substring(pos + uriPrefix.length());
         
        // Strip off query parameters. 
        pos = uriTarget.indexOf("?");
        return (pos < 0) ? uriTarget : uriTarget.substring(0, pos);
    } 
     
    /** 
     * Returns a map of name/value pairs corresponding to the query parameters 
     * in the specified request. 
     */