// Path: client/src/main/java/com/nesscomputing/httpclient/HttpClientResponse.java
// public interface HttpClientResponse {
// 	/**
// 	 * Returns the status code for the request.
// 	 *
// 	 * @return the status code, use the related {@link HttpServletRequest} constants
// 	 */
// 	int getStatusCode();
// 
// 	/**
// 	 * Returns the status text for the request.
// 	 *
// 	 * @return the status text
// 	 */
// 	String getStatusText();
// 
// 	/**
// 	 * Returns an input stream for the response body.
// 	 *
// 	 * @return the input stream
// 	 * @throws IOException on error
// 	 */
// 	InputStream getResponseBodyAsStream() throws IOException;
// 
// 	/** @return the URI of the request. */
// 	URI getUri();
// 
// 	/** @return Content type of the response. */
// 	String getContentType();
// 
// 	/**
// 	 * @return Length of the content, if present. Can be null (not present), -1 (chunked) or 0 (no
// 	 *         content).
// 	 */
// 	@CheckForNull
// 	Long getContentLength();
// 
// 	/** @return Content charset if present in the header. Can be null. */
// 	@CheckForNull
// 	String getCharset();
// 
// 	/**
// 	 * @param name the header name
// 	 * @return The named header from the response. Response can be null.
// 	 */
// 	@CheckForNull
// 	String getHeader(String name);
// 
// 	/**
// 	 * @param name the header name
// 	 * @return all values for the given header. Response can be null.
// 	 */
// 	@CheckForNull
// 	List<String> getHeaders(String name);
// 
// 	/** @return Map of header name -> list of values for each header name */
//     @Nonnull
// 	public Map<String, List<String>> getAllHeaders();
// 
// 	/** @return true if the response redirects to another object. */
// 	boolean isRedirected();
// }


import com.nesscomputing.httpclient.HttpClientResponse;
/**
 * Copyright (C) 2012 Ness Computing, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.nesscomputing.httpclient.response;


/**
 * Indicates a redirection response from a server.
 */
public class RedirectedException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    private final int statusCode;
    private final String url;

    /**
     * Creates a new Redirection execption.
     */
    public RedirectedException(final int statusCode, final String url)
    {
        super();
        this.statusCode = statusCode;
        this.url = url;
    }

    /**
     * Creates a new Redirection execption with message.
     */
    public RedirectedException(final int statusCode, final String url, final String message)
    {
        super(message);
        this.statusCode = statusCode;
        this.url = url;
    }

    /**
     * Creates a new Redirection execption from a {@link HttpClientResponse}.
     */
    public RedirectedException(final HttpClientResponse response)
    {
        this(response.getStatusCode(), response.getHeader("Location"));
    }

    /**
     * Creates a new Redirection execption from a {@link HttpClientResponse} with message.
     */
// Path: client/src/main/java/com/nesscomputing/httpclient/HttpClientResponse.java
// public interface HttpClientResponse {
// 	/**
// 	 * Returns the status code for the request.
// 	 *
// 	 * @return the status code, use the related {@link HttpServletRequest} constants
// 	 */
// 	int getStatusCode();
// 
// 	/**
// 	 * Returns the status text for the request.
// 	 *
// 	 * @return the status text
// 	 */
// 	String getStatusText();
// 
// 	/**
// 	 * Returns an input stream for the response body.
// 	 *
// 	 * @return the input stream
// 	 * @throws IOException on error
// 	 */
// 	InputStream getResponseBodyAsStream() throws IOException;
// 
// 	/** @return the URI of the request. */
// 	URI getUri();
// 
// 	/** @return Content type of the response. */
// 	String getContentType();
// 
// 	/**
// 	 * @return Length of the content, if present. Can be null (not present), -1 (chunked) or 0 (no
// 	 *         content).
// 	 */
// 	@CheckForNull
// 	Long getContentLength();
// 
// 	/** @return Content charset if present in the header. Can be null. */
// 	@CheckForNull
// 	String getCharset();
// 
// 	/**
// 	 * @param name the header name
// 	 * @return The named header from the response. Response can be null.
// 	 */
// 	@CheckForNull
// 	String getHeader(String name);
// 
// 	/**
// 	 * @param name the header name
// 	 * @return all values for the given header. Response can be null.
// 	 */
// 	@CheckForNull
// 	List<String> getHeaders(String name);
// 
// 	/** @return Map of header name -> list of values for each header name */
//     @Nonnull
// 	public Map<String, List<String>> getAllHeaders();
// 
// 	/** @return true if the response redirects to another object. */
// 	boolean isRedirected();
// }


// Path: client/src/main/java/com/nesscomputing/httpclient/response/RedirectedException.java
import com.nesscomputing.httpclient.HttpClientResponse;

/**
 * Copyright (C) 2012 Ness Computing, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.nesscomputing.httpclient.response;


/**
 * Indicates a redirection response from a server.
 */
public class RedirectedException extends RuntimeException
{
    private static final long serialVersionUID = 1L;

    private final int statusCode;
    private final String url;

    /**
     * Creates a new Redirection execption.
     */
    public RedirectedException(final int statusCode, final String url)
    {
        super();
        this.statusCode = statusCode;
        this.url = url;
    }

    /**
     * Creates a new Redirection execption with message.
     */
    public RedirectedException(final int statusCode, final String url, final String message)
    {
        super(message);
        this.statusCode = statusCode;
        this.url = url;
    }

    /**
     * Creates a new Redirection execption from a {@link HttpClientResponse}.
     */
    public RedirectedException(final HttpClientResponse response)
    {
        this(response.getStatusCode(), response.getHeader("Location"));
    }

    /**
     * Creates a new Redirection execption from a {@link HttpClientResponse} with message.
     */
    public RedirectedException(final HttpClientResponse response, final String message)