/* libzzinet
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2000-2006, Toni Thomsson <toni@tonjac.org> 
*/

#ifdef _WIN32
#pragma warning(disable: 4786)
#endif

#ifndef zz_cgi_h
#define zz_cgi_h

#include <zz_string.h>
#include <map>
#include <zz_mime_body.h>
#include <zz_export.h>
#include <zz_parameter_map.h>
#include <zz_cgi_parameter_parser.h>
#include <zz_log.h>

/**
    Parses CGI-parameters.
    Supports POST and GET encoded as:
    application/x-www-form-urlencoded or
    multipart/form-data

    @author Toni Thomsson, toni@tonjac.org
*/
class ZZ_API CzzCGI : public CzzCGIParameterParser
{
public:

    /** 
        Constructor
    */
    CzzCGI( void );

    virtual ~CzzCGI();


    /**
        Get variabel

        @param  var Name
    */
    virtual CzzString operator[]( const CzzString& var );

    /**
        Returns path to file uploaded via POST
        
        @param  name Name
    */
    CzzString getFile( const CzzString& name );

    /** Length of raw request buffer */
    int getLength( void );
    
    /** Raw request buffer */
    char* request( void );

protected:

    void parseHeaders( char* hdrs );

    CzzString m_Type;
    CzzString m_Method;
    char* m_Request;
    long m_Length;
    CzzMIMEBody* m_MIME;
    CzzLog m_Log;
};

#endif // zz_cgi_h