common/src/main/java/HTTPClient/RedirectionModule.java
/**
     * The Location header field must be an absolute URI, but too many broken
     * servers use relative URIs. So, we always resolve relative to the
     * full request URI.
     *
     * @param  loc the Location header field
     * @param  req the Request to resolve relative URI's relative to
     * @return an absolute URI corresponding to the Location header field
     * @exception ProtocolException if the Location header field is completely
     *                            unparseable
     */
The Location header field must be an absolute URI, but too many broken
servers use relative URIs. So, we always resolve relative to the
full request URI.

@param  loc the Location header field
@param  req the Request to resolve relative URI's relative to
@return an absolute URI corresponding to the Location header field
@exception ProtocolException if the Location header field is completely
unparseable
The Location header field must be an absolute URI but too many broken servers use relative URIs . So we always resolve relative to the full request URI . @param loc the Location header field @param req the Request to resolve relative URI ' s relative to @return an absolute URI corresponding to the Location header field @exception ProtocolException if the Location header field is completely unparseable
private URI resLocHdr(String loc, RoRequest req)  throws ProtocolException
    {
	try
	{
	    URI base = new URI(req.getConnection().getProtocol(),
			       req.getConnection().getHost(),
			       req.getConnection().getPort(), null);
	    base = new URI(base, req.getRequestURI());
	    URI res = new URI(base, loc);
	    if (res.getHost() == null)
		throw new ProtocolException("Malformed URL in Location header: `" + loc +
					    "' - missing host field");
	    return res;
	}
	catch (ParseException pe)
	{
	    throw new ProtocolException("Malformed URL in Location header: `" + loc +
					"' - exception was: " + pe.getMessage());
	}
    }
private URI resLocHdr ( String loc , RoRequest req ) throws ProtocolException { try { URI base = new URI ( req . getConnection ( ) . getProtocol ( ) , req . getConnection ( ) . getHost ( ) , req . getConnection ( ) . getPort ( ) , null ) ; base = new URI ( base , req . getRequestURI ( ) ) ; URI res = new URI ( base , loc ) ; if ( res . getHost ( ) == null ) throw new ProtocolException ( "Malformed URL in Location header: `" + loc + "' - missing host field" ) ; return res ; } catch ( ParseException pe ) { throw new ProtocolException ( "Malformed URL in Location header: `" + loc + "' - exception was: " + pe . getMessage ( ) ) ; } }
The Location header field must be an absolute URI, but too many broken
 servers use relative URIs.
The Location header field must be an absolute URI but too many broken servers use relative URIs .