/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (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.mozilla.org/MPL/
 * 
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 * 
 * The Original Code is Mozilla.
 * 
 * The Initial Developer of the Original Code is Netscape
 * Communications.  Portions created by Netscape Communications are
 * Copyright (C) 2001 by Netscape Communications.  All
 * Rights Reserved.
 * 
 * Contributor(s): 
 *   Gagan Saksena <gagan@netscape.com> (original author) 
 *   Darin Fisher <darin@netscape.com>
 */

#include "nsIChannel.idl"

interface nsIHttpHeaderVisitor;

[scriptable, uuid(d78b53c8-d03f-4fd8-b2ee-7b36fcd150d1)]
interface nsIHttpChannel : nsIChannel
{
    /**************************************************************************
     * Request info...
     */

    /**
     * The request method is case insensitive
     */
    attribute string requestMethod;

    /**
     * Get/set the referrer URI on the request.  This is the address (URI) of
     * the resource from which this channel's URI was obtained (see RFC2616
     * section 14.36).  The referrer type may be used to block the referrer
     * from being sent in certain cases.
     */
    readonly attribute nsIURI referrer;
    void setReferrer(in nsIURI referrer, in unsigned long referrerType);

    /* possible values for the referrerType */
    const unsigned long REFERRER_NONE = 0;
    const unsigned long REFERRER_LINK_CLICK = 1; // http link clicks
    const unsigned long REFERRER_INLINES = 2;    // images and other inlines
    const unsigned long REFERRER_NON_HTTP = 3;   // e.g. news or FTP clicks

    /**
     * Header strings are case insensitive
     */
    string getRequestHeader(in string header);
    void   setRequestHeader(in string header, in string value);
    void   visitRequestHeaders(in nsIHttpHeaderVisitor visitor);

    /**
     * Get the stream (to be) uploaded by this HTTP channel.
     */
    readonly attribute nsIInputStream uploadStream;

    /**************************************************************************
     * Response info...
     */

    readonly attribute unsigned long responseStatus;
    readonly attribute string responseStatusText;

    /**
     * Header strings are case insensitive
     */
    string getResponseHeader(in string header);
    void   setResponseHeader(in string header, in string value);
    void   visitResponseHeaders(in nsIHttpHeaderVisitor visitor);

    /**
     * True if the server sent a "Cache-control: no-store" response header.
     */
    boolean isNoStoreResponse();

    /**
     * True if the server sent the equivalent of a "Cache-control: no-cache"
     * response header.  Other equivalent response headers include: "Pragma:
     * no-cache" and "Expires" with a date-value in the past.
     */
    boolean isNoCacheResponse();

    /**
     * Get the charset for the response, which may be NULL if not specified
     * by the server (ie. the Content-Type header may not specify a charset).
     */
    readonly attribute string charset;

    /**
     * This attribute holds the MIME type corresponding to the outermost
     * Content-Encoding on the channel.  If you want the actual
     * Content-Encoding value, use getResponseHeader("Content-Encoding")
     */
    readonly attribute string contentEncoding;

    /**
     * This attribute controls whether or not content conversion should be
     * done per the Content-Encoding response header.  Its value is true
     * by default.
     */
    attribute boolean applyConversion;

    /**
     * This attribute specifies the number of redirects this channel is allowed
     * to make.  If zero, the channel will fail to redirect and will generate
     * a NS_ERROR_REDIRECT_LOOP failure status.
     */
    attribute unsigned long redirectionLimit;
};

/**
 * Implement this interface to visit http headers.
 */
[scriptable, uuid(0cf40717-d7c1-4a94-8c1e-d6c9734101bb)]
interface nsIHttpHeaderVisitor : nsISupports
{
    void visitHeader(in string header, in string value);
};
