Code example for HttpRequest

Methods: addHeader, containsHeader, getRequestLine

0
    public void process(final HttpRequest request, final HttpContext context)
            throws HttpException, IOException { 
        if (request == null) {
            throw new IllegalArgumentException("HTTP request may not be null");
        } 
 
        String method = request.getRequestLine().getMethod();
        if (method.equalsIgnoreCase("CONNECT")) {
            return; 
        } 
 
        if (!request.containsHeader(HTTP.CONN_DIRECTIVE)) {
            // Default policy is to keep connection alive 
            // whenever possible 
            request.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
        } 
    } 
 
}