#ifndef __DCL_HTTP_HEADER_H__
#define __DCL_HTTP_HEADER_H__       20050509

#ifndef __DCL_INCLUDED_TIME_H
#include <dcl/core/_time.h>
#endif

#ifndef __DCL_STRING_H__
    #include <dcl/core/String.h>
#endif
#ifndef __DCL_COLLECTION_BASE_H__
    #include <dcl/core/CollectionBase.h>
#endif

#ifdef __DCL_DEBUG
static const char* __pszHttpHeader_h__ = "dcl/net/HttpHeader.h";
#undef __THIS_FILE__
#define __THIS_FILE__ __pszHttpHeader_h__
#endif

__DCL_BEGIN_NAMESPACE

class DCLNAPI HttpHeader 
{
protected:
    String m_strName;
    String m_strContent;
public:
    HttpHeader();
    HttpHeader(const HttpHeader& src);
    HttpHeader(const char* pszName, const char* pszContent = NULL);
    const String& name() const;
    const String& content() const;
    String toString() const;
};

class DCLNAPI HttpSetCookie : public HttpHeader
{
public:
    // http://www.faqs.org/rfcs/rfc2109.html
#ifdef RFC2109
    HttpSetCookie(const char* pszName, 
            const char* pszValue = NULL,
            const char* pszComment = NULL,
            const char* pszDomain = NULL,
            int nMaxAge = 0,        // 초 단위
            const char* pszPath = NULL,
            bool bSecure = false,
            int nVersion = 0
            );
#endif  // RFC2109
    // php style
    HttpSetCookie(const char* pszName, 
            const char* pszValue = NULL,
            time_t timeExpires = 0,
            const char* pszPath = NULL,
            const char* pszDomain = NULL,
            bool bSecure = false
            );
};

// http://www.faqs.org/rfcs/rfc2965.html
class DCLNAPI HttpSetCookie2 : public HttpHeader
{

};

class DCLNAPI HttpExpires : public HttpHeader
{
public:
    HttpExpires(time_t timeExpires);
};

inline HttpHeader::HttpHeader()
{
}

inline HttpHeader::HttpHeader(const HttpHeader& src)
{
    m_strName = src.m_strName;
    m_strContent = src.m_strContent;
}

inline HttpHeader::HttpHeader(const char* pszName, const char* pszContent /* = NULL */)
{
    __DCL_ASSERT(pszName != NULL);
    __DCL_ASSERT(*pszName != '\0');

    m_strName = pszName;
    
    if (pszContent != NULL)
        m_strContent = pszContent;
}

inline const String& HttpHeader::name() const
{
    return m_strName;
}

inline const String& HttpHeader::content() const
{
    return m_strContent;
}

inline bool operator == (const HttpHeader& x, const HttpHeader& y)
{
    return (x.name() == y.name()) && (x.content() == y.content());
}

__DCL_END_NAMESPACE

#ifdef __DCL_DEBUG
#undef __THIS_FILE__
#define __THIS_FILE__   __FILE__
#endif

#endif  // __DCL_HTTP_HEADER_H__