List of usage examples for org.apache.commons.httpclient HttpConnection isTransparent
public boolean isTransparent()
From source file:edu.utah.further.core.ws.HttpResponseTo.java
/** * Generates HTTP request line according to the specified attributes. * // w w w.j a v a 2 s. co m * @param connection * the {@link HttpConnection connection} used to execute this HTTP method * @param name * the method name generate a request for * @param requestPath * the path string for the request * @param query * the query string for the request * @param version * the protocol version to use (e.g. HTTP/1.0) * * @return HTTP request line */ protected static String generateRequestLine(final HttpConnection connection, final String name, final String requestPath, final String query, final String version) { final StringBuffer buf = new StringBuffer(); // Append method name buf.append(name).append(Strings.SPACE_STRING); // Absolute or relative URL? if (!connection.isTransparent()) { final Protocol protocol = connection.getProtocol(); buf.append(protocol.getScheme().toLowerCase()); 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) { if (query.indexOf("?") != 0) { buf.append("?"); } buf.append(query); } // Append protocol buf.append(Strings.SPACE_STRING).append(version).append(Strings.UNIX_NEW_LINE_STRING); return buf.toString(); }