cgicc: HTTPResponseHeader.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

# HTTPResponseHeader.h

Go to the documentation of this file.

    00001 /* -*-mode:c++; c-file-style: "gnu";-*- */
    00002 /*
    00003  *  $Id: HTTPResponseHeader.h,v 1.9 2007/07/02 18:48:19 sebdiaz Exp $
    00004  *
    00005  *  Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
    00006  *                       2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
    00007  *  Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU Lesser General Public
    00011  *  License as published by the Free Software Foundation; either
    00012  *  version 3 of the License, or (at your option) any later version.
    00013  *
    00014  *  This library is distributed in the hope that it will be useful,
    00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00017  *  Lesser General Public License for more details.
    00018  *
    00019  *  You should have received a copy of the GNU Lesser General Public
    00020  *  License along with this library; if not, write to the Free Software
    00021  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
    00022  */
    00023
    00024 #ifndef _HTTPRESPONSEHEADER_H_
    00025 #define _HTTPRESPONSEHEADER_H_ 1
    00026
    00027 #ifdef __GNUG__
    00028 #  pragma interface
    00029 #endif
    00030
    00038 #include <string>
    00039 #include <vector>
    00040
    00041 #include "cgicc/MStreamable.h"
    00042 #include "cgicc/HTTPCookie.h"
    00043
    00044 namespace cgicc {
    00045
    00046   // ============================================================
    00047   // Class HTTPResponseHeader
    00048   // ============================================================
    00073   class CGICC_API HTTPResponseHeader : public MStreamable
    00074   {
    00075   public:
    00076
    00079
    00086     HTTPResponseHeader(const std::string& http_version,
    00087                        int status_code,
    00088                        const std::string& reason_phrase);
    00089
    00094     virtual ~HTTPResponseHeader();
    00096
    00097     // ============================================================
    00098
    00101
    00108     HTTPResponseHeader&
    00109     addHeader(const std::string& header);
    00110
    00118     HTTPResponseHeader&
    00119     addHeader(const std::string& name,
    00120               const std::string& value);
    00121
    00127     inline const std::vector<std::string>&
    00128     getHeaders()                                        const
    00129     { return fHeaders; }
    00131
    00134
    00139     HTTPResponseHeader&
    00140     setCookie(const HTTPCookie& cookie);
    00141
    00146     inline const std::vector<HTTPCookie>&
    00147     getCookies()                                        const
    00148     { return fCookies; }
    00150
    00151     // ============================================================
    00152
    00157
    00164     inline const std::string&
    00165     getHTTPVersion()                            const
    00166     { return fHTTPVersion; }
    00167
    00174     inline int
    00175     getStatusCode()                             const
    00176     { return fStatusCode; }
    00177
    00184     inline std::string
    00185     getReasonPhrase()                           const
    00186     { return fReasonPhrase; }
    00188
    00189     // ============================================================
    00190
    00195
    00203     inline HTTPResponseHeader&
    00204     getHTTPVersion(const std::string& http_version)
    00205     { fHTTPVersion = http_version; return *this; }
    00206
    00214     inline HTTPResponseHeader&
    00215     getStatusCode(int status_code)
    00216     { fStatusCode = status_code; return *this; }
    00217
    00225     inline HTTPResponseHeader&
    00226     getReasonPhrase(const std::string& reason_phrase)
    00227     { fReasonPhrase = reason_phrase; return *this; }
    00229
    00230     // ============================================================
    00231
    00234     virtual void
    00235     render(std::ostream& out)                   const;
    00237
    00238   private:
    00239     HTTPResponseHeader();
    00240
    00241     std::string                 fHTTPVersion;
    00242     int                         fStatusCode;
    00243     std::string                 fReasonPhrase;
    00244     std::vector<std::string>    fHeaders;
    00245     std::vector<HTTPCookie>     fCookies;
    00246   };
    00247
    00248 } // namespace cgicc
    00249
    00250 #endif /* ! _HTTPRESPONSEHEADER_H_ */