HTTPResponseHeader.h Source File

Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members Related Pages

# HTTPResponseHeader.h

Go to the documentation of this file.

    00001 /* -*-c++-*- */
    00002 /*
    00003  *  $Id: HTTPResponseHeader.h,v 1.3 2002/03/06 02:49:55 sbooth Exp $
    00004  *
    00005  *  Copyright (C) 1996 - 2002 Stephen F. Booth
    00006  *
    00007  *  This library is free software; you can redistribute it and/or
    00008  *  modify it under the terms of the GNU Lesser General Public
    00009  *  License as published by the Free Software Foundation; either
    00010  *  version 2.1 of the License, or (at your option) any later version.
    00011  *
    00012  *  This library is distributed in the hope that it will be useful,
    00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015  *  Lesser General Public License for more details.
    00016  *
    00017  *  You should have received a copy of the GNU Lesser General Public
    00018  *  License along with this library; if not, write to the Free Software
    00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00020  */
    00021
    00022 #ifndef _HTTPRESPONSEHEADER_H_
    00023 #define _HTTPRESPONSEHEADER_H_ 1
    00024
    00025 #ifdef __GNUG__
    00026 #  pragma interface
    00027 #endif
    00028
    00036 #include <string>
    00037 #include <vector>
    00038
    00039 #include "cgicc/MStreamable.h"
    00040 #include "cgicc/HTTPCookie.h"
    00041
    00042 CGICC_BEGIN_NAMESPACE
    00043
    00044 // ============================================================
    00045 // Class HTTPResponseHeader
    00046 // ============================================================
    00071 class CGICC_API HTTPResponseHeader : public MStreamable
    00072 {
    00073 public:
    00074
    00077
    00084   HTTPResponseHeader(const STDNS string& http_version,
    00085                      int status_code,
    00086                      const STDNS string& reason_phrase);
    00087
    00092   virtual ~HTTPResponseHeader();
    00094
    00095   // ============================================================
    00096
    00099
    00106   HTTPResponseHeader&
    00107   addHeader(const STDNS string& header);
    00108
    00115   HTTPResponseHeader&
    00116   addHeader(const STDNS string& name,
    00117             const STDNS string& value);
    00118
    00124   inline const STDNS vector<STDNS string>&
    00125   getHeaders()                                  const
    00126   { return fHeaders; }
    00128
    00131
    00136   HTTPResponseHeader&
    00137   setCookie(const HTTPCookie& cookie);
    00138
    00143   inline const STDNS vector<HTTPCookie>&
    00144   getCookies()                                  const
    00145   { return fCookies; }
    00147
    00148   // ============================================================
    00149
    00154
    00161   inline const STDNS string&
    00162   getHTTPVersion()                              const
    00163   { return fHTTPVersion; }
    00164
    00171   inline int
    00172   getStatusCode()                               const
    00173   { return fStatusCode; }
    00174
    00181   inline STDNS string
    00182   getReasonPhrase()                             const
    00183   { return fReasonPhrase; }
    00185
    00186   // ============================================================
    00187
    00192
    00200   inline HTTPResponseHeader&
    00201   getHTTPVersion(const STDNS string& http_version)
    00202   { fHTTPVersion = http_version; return *this; }
    00203
    00211   inline HTTPResponseHeader&
    00212   getStatusCode(int status_code)
    00213   { fStatusCode = status_code; return *this; }
    00214
    00222   inline HTTPResponseHeader&
    00223   getReasonPhrase(const STDNS string& reason_phrase)
    00224   { fReasonPhrase = reason_phrase; return *this; }
    00226
    00227   // ============================================================
    00228
    00231   virtual void
    00232   render(STDNS ostream& out)                    const;
    00234
    00235 private:
    00236   HTTPResponseHeader();
    00237
    00238   STDNS string                  fHTTPVersion;
    00239   int                           fStatusCode;
    00240   STDNS string                  fReasonPhrase;
    00241   STDNS vector<STDNS string>    fHeaders;
    00242   STDNS vector<HTTPCookie>      fCookies;
    00243 };
    00244
    00245 CGICC_END_NAMESPACE
    00246
    00247 #endif /* ! _HTTPRESPONSEHEADER_H_ */