/** * Returns the final URL associated with this web request. * @return the Uniform Resource Locator for this Web request * @throws MalformedURLException if the URL is not o.k. **/ public URL getURL() throws MalformedURLException { if (getURLBase() == null || getURLBase().toString().indexOf( "?" ) < 0) { return newURL( getURLBase(), getURLString() ); } else { final String urlBaseString = getURLBase().toString(); URL newurlbase = new URL( urlBaseString.substring( 0, urlBaseString.indexOf( "?" ) ) ); return newURL( newurlbase, getURLString() ); } }
/** * Returns the final URL associated with this web request. * @return the Uniform Resource Locator for this Web request * @throws MalformedURLException if the URL is not o.k. **/ public URL getURL() throws MalformedURLException { if (getURLBase() == null || getURLBase().toString().indexOf( "?" ) < 0) { return newURL( getURLBase(), getURLString() ); } else { final String urlBaseString = getURLBase().toString(); URL newurlbase = new URL( urlBaseString.substring( 0, urlBaseString.indexOf( "?" ) ) ); return newURL( newurlbase, getURLString() ); } }
/** * Returns the final URL associated with this web request. * @return the Uniform Resource Locator for this Web request * @throws MalformedURLException if the URL is not o.k. **/ public URL getURL() throws MalformedURLException { if (getURLBase() == null || getURLBase().toString().indexOf( "?" ) < 0) { return newURL( getURLBase(), getURLString() ); } else { final String urlBaseString = getURLBase().toString(); URL newurlbase = new URL( urlBaseString.substring( 0, urlBaseString.indexOf( "?" ) ) ); return newURL( newurlbase, getURLString() ); } }
public String toString() { return getMethod() + " request for (" + getURLBase() + ") " + getURLString(); }
public String toString() { return getMethod() + " request for (" + getURLBase() + ") " + getURLString(); }
public String toString() { return getMethod() + " request for (" + getURLBase() + ") " + getURLString(); }
/** * Creates a new URL, handling the case where the relative URL begins with a '?' * @param base - the URL to start from * @param spec - additional specification string * @return the URL */ private URL newURL( final URL base, final String spec ) throws MalformedURLException { if (spec.toLowerCase().startsWith( "javascript:" )) { return new URL( "javascript", null, -1, spec.substring( "javascript:".length() ), JAVASCRIPT_STREAM_HANDLER ); } else if (spec.toLowerCase().startsWith( "https:" ) && !HttpsProtocolSupport.hasHttpsSupport()) { return new URL( "https", null, -1, spec.substring( "https:".length() ), HTTPS_STREAM_HANDLER ); } else { if (getURLBase() == null || getURLString().indexOf( ':' ) > 0) { if (getURLString().indexOf(':') <= 0) { throw new RuntimeException( "No protocol specified in URL '" + getURLString() + "'" ); } HttpsProtocolSupport.verifyProtocolSupport( getURLString().substring( 0, getURLString().indexOf( ':' ) ) ); } return spec.startsWith( "?" ) ? new URL( base + spec ) : newCombinedURL( base, spec ); } }
/** * Creates a new URL, handling the case where the relative URL begins with a '?' * @param base - the URL to start from * @param spec - additional specification string * @return the URL */ private URL newURL( final URL base, final String spec ) throws MalformedURLException { if (spec.toLowerCase().startsWith( "javascript:" )) { return new URL( "javascript", null, -1, spec.substring( "javascript:".length() ), JAVASCRIPT_STREAM_HANDLER ); } else if (spec.toLowerCase().startsWith( "https:" ) && !HttpsProtocolSupport.hasHttpsSupport()) { return new URL( "https", null, -1, spec.substring( "https:".length() ), HTTPS_STREAM_HANDLER ); } else { if (getURLBase() == null || getURLString().indexOf( ':' ) > 0) { if (getURLString().indexOf(':') <= 0) { throw new RuntimeException( "No protocol specified in URL '" + getURLString() + "'" ); } HttpsProtocolSupport.verifyProtocolSupport( getURLString().substring( 0, getURLString().indexOf( ':' ) ) ); } return spec.startsWith( "?" ) ? new URL( base + spec ) : newCombinedURL( base, spec ); } }
/** * Creates a new URL, handling the case where the relative URL begins with a '?' * @param base - the URL to start from * @param spec - additional specification string * @return the URL */ private URL newURL( final URL base, final String spec ) throws MalformedURLException { if (spec.toLowerCase().startsWith( "javascript:" )) { return new URL( "javascript", null, -1, spec.substring( "javascript:".length() ), JAVASCRIPT_STREAM_HANDLER ); } else if (spec.toLowerCase().startsWith( "https:" ) && !HttpsProtocolSupport.hasHttpsSupport()) { return new URL( "https", null, -1, spec.substring( "https:".length() ), HTTPS_STREAM_HANDLER ); } else { if (getURLBase() == null || getURLString().indexOf( ':' ) > 0) { if (getURLString().indexOf(':') <= 0) { throw new RuntimeException( "No protocol specified in URL '" + getURLString() + "'" ); } HttpsProtocolSupport.verifyProtocolSupport( getURLString().substring( 0, getURLString().indexOf( ':' ) ) ); } return spec.startsWith( "?" ) ? new URL( base + spec ) : newCombinedURL( base, spec ); } }