protected static String generateRequestLine ( HttpConnection connection , String name , String requestPath , String query , String version ) { LOG . trace ( "enter HttpMethodBase.generateRequestLine(HttpConnection, " + "String, String, String, String)" ) ; StringBuffer buf = new StringBuffer ( ) ; // Append method name buf . append ( name ) ; buf . append ( " " ) ; // Absolute or relative URL? if ( ! connection . isTransparent ( ) ) { Protocol protocol = connection . getProtocol ( ) ; buf . append ( protocol . getScheme ( ) . toLowerCase ( Locale . ENGLISH ) ) ; buf . append ( "://" ) ; buf . append ( connection . getHost ( ) ) ; if ( ( connection . getPort ( ) != - 1 ) && ( connection . getPort ( ) != protocol . getDefaultPort ( ) ) ) { buf . append ( ":" ) ; buf . append ( connection . getPort ( ) ) ; } } // Append path, if any if ( requestPath == null ) { buf . append ( "/" ) ; } else { if ( ! connection . isTransparent ( ) && ! requestPath . startsWith ( "/" ) ) { buf . append ( "/" ) ; } buf . append ( requestPath ) ; } // Append query, if any if ( query != null ) { // ZAP: If commented out to not change the intended request URI (i.e. if the query component starts with a "?" char) //if (query.indexOf("?") != 0) { buf . append ( "?" ) ; //} buf . append ( query ) ; } // Append protocol buf . append ( " " ) ; buf . append ( version ) ; buf . append ( "\r\n" ) ; return buf . toString ( ) ; }
Generates HTTP request line according to the specified attributes .