HTTPResponseHeader.h
Go to the documentation of this file.
1 /* -*-mode:c++; c-file-style: "gnu";-*- */
2 /*
3  * $Id: HTTPResponseHeader.h,v 1.9 2007/07/02 18:48:19 sebdiaz Exp $
4  *
5  * Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
6  * 2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
7  * Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
22  */
23 
24 #ifndef _HTTPRESPONSEHEADER_H_
25 #define _HTTPRESPONSEHEADER_H_ 1
26 
27 #ifdef __GNUG__
28 # pragma interface
29 #endif
30 
38 #include <string>
39 #include <vector>
40 
41 #include "cgicc/MStreamable.h"
42 #include "cgicc/HTTPCookie.h"
43 
44 namespace cgicc {
45 
46  // ============================================================
47  // Class HTTPResponseHeader
48  // ============================================================
73  class CGICC_API HTTPResponseHeader : public MStreamable
74  {
75  public:
76 
79 
86  HTTPResponseHeader(const std::string& http_version,
87  int status_code,
88  const std::string& reason_phrase);
89 
94  virtual ~HTTPResponseHeader();
96 
97  // ============================================================
98 
101 
109  addHeader(const std::string& header);
110 
119  addHeader(const std::string& name,
120  const std::string& value);
121 
127  inline const std::vector<std::string>&
128  getHeaders() const
129  { return fHeaders; }
131 
134 
140  setCookie(const HTTPCookie& cookie);
141 
146  inline const std::vector<HTTPCookie>&
147  getCookies() const
148  { return fCookies; }
150 
151  // ============================================================
152 
157 
164  inline const std::string&
165  getHTTPVersion() const
166  { return fHTTPVersion; }
167 
174  inline int
175  getStatusCode() const
176  { return fStatusCode; }
177 
184  inline std::string
185  getReasonPhrase() const
186  { return fReasonPhrase; }
188 
189  // ============================================================
190 
195 
203  inline HTTPResponseHeader&
204  getHTTPVersion(const std::string& http_version)
205  { fHTTPVersion = http_version; return *this; }
206 
214  inline HTTPResponseHeader&
215  getStatusCode(int status_code)
216  { fStatusCode = status_code; return *this; }
217 
225  inline HTTPResponseHeader&
226  getReasonPhrase(const std::string& reason_phrase)
227  { fReasonPhrase = reason_phrase; return *this; }
229 
230  // ============================================================
231 
234  virtual void
235  render(std::ostream& out) const;
237 
238  private:
240 
241  std::string fHTTPVersion;
242  int fStatusCode;
243  std::string fReasonPhrase;
244  std::vector<std::string> fHeaders;
245  std::vector<HTTPCookie> fCookies;
246  };
247 
248 } // namespace cgicc
249 
250 #endif /* ! _HTTPRESPONSEHEADER_H_ */

GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996 - 2004 Stephen F. Booth
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front Cover Texts, and with no Back-Cover Texts.
Documentation generated Tue May 14 2013 02:07:54 for cgicc by doxygen 1.8.3.1