~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/mod/nwg/shl/HttpReply.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Anibal Monsalve Salazar
  • Date: 2011-03-16 21:31:18 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110316213118-gk4k3ez3e5d2huna
Tags: 2.0.0-1
* QA upload.
* New upstream release
* Debian source format is 3.0 (quilt)
* Fix debhelper-but-no-misc-depends
* Fix ancient-standards-version
* Fix package-contains-linda-override
* debhelper compatibility is 7
* Fix dh-clean-k-is-deprecated

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// ---------------------------------------------------------------------------
2
 
// - HttpReply.hpp                                                           -
3
 
// - afnix:nwg module - http reply class definition                          -
4
 
// ---------------------------------------------------------------------------
5
 
// - This program is free software;  you can redistribute it  and/or  modify -
6
 
// - it provided that this copyright notice is kept intact.                  -
7
 
// -                                                                         -
8
 
// - This program  is  distributed in  the hope  that it will be useful, but -
9
 
// - without  any  warranty;  without  even   the   implied    warranty   of -
10
 
// - merchantability or fitness for a particular purpose.  In no event shall -
11
 
// - the copyright holder be liable for any  direct, indirect, incidental or -
12
 
// - special damages arising in any way out of the use of this software.     -
13
 
// ---------------------------------------------------------------------------
14
 
// - copyright (c) 1999-2007 amaury darsch                                   -
15
 
// ---------------------------------------------------------------------------
16
 
 
17
 
#ifndef  AFNIX_HTTPREPLY_HPP
18
 
#define  AFNIX_HTTPREPLY_HPP
19
 
 
20
 
#ifndef  AFNIX_MIME_HPP
21
 
#include "Mime.hpp"
22
 
#endif
23
 
 
24
 
#ifndef  AFNIX_COOKIE_HPP
25
 
#include "Cookie.hpp"
26
 
#endif
27
 
 
28
 
#ifndef  AFNIX_HTTPPROTO_HPP
29
 
#include "HttpProto.hpp"
30
 
#endif
31
 
 
32
 
namespace afnix {
33
 
 
34
 
  /// The HttpReply class is a simple designed to format a http reply.
35
 
  /// When the write method is called, the header and the buffer are 
36
 
  /// formatted to the output stream argument. The class creates initially
37
 
  /// the 'content-type' property which is initialized to the 'text/plain'
38
 
  /// mime value. The object can also be filled with a mime document. This
39
 
  /// kind of reply is usefull when responding to cgi request. In that case,
40
 
  /// the content-type is changed according to the mime document type.
41
 
  /// @author amaury darsch
42
 
 
43
 
  class HttpReply : public HttpProto {
44
 
  protected:
45
 
    /// the http buffer
46
 
    Buffer d_hbuf;
47
 
 
48
 
  public:
49
 
    /// create an empty http reply
50
 
    HttpReply (void);
51
 
 
52
 
    /// create an empty reply with a content type
53
 
    /// @param type the content type to use
54
 
    HttpReply (const String& type);
55
 
 
56
 
    /// @return the class name
57
 
    String repr (void) const;
58
 
 
59
 
    /// set a cookie in the header
60
 
    /// @param cook the cookie to set
61
 
    virtual void setcook (const Cookie& cook);
62
 
 
63
 
    /// add a string to the http buffer
64
 
    /// @param lval the literal value to add
65
 
    virtual void addhbuf (const Literal& lval);
66
 
 
67
 
    /// add a buffer content to the http buffer
68
 
    /// @param buf the buffer to add
69
 
    virtual void addhbuf (const Buffer& buf);
70
 
 
71
 
    /// add a mime document to the http buffer
72
 
    /// @param mime the document to add
73
 
    virtual void addhbuf (const Mime& mime);
74
 
 
75
 
    /// set the hhtp reply status code
76
 
    /// @param code the http status code
77
 
    virtual void setstatus (const long code);
78
 
 
79
 
    /// reply a redirect status with a url
80
 
    /// @param url the target url
81
 
    virtual void redirect (const String& url);
82
 
 
83
 
    /// write the http reply to an output stream
84
 
    /// @param os the output stream
85
 
    void write (Output& os) const;
86
 
 
87
 
    /// write the http reply to a buffer
88
 
    /// @param buf the target buffer
89
 
    void write (Buffer& buf) const;
90
 
 
91
 
  private:
92
 
    // make the copy constructor private
93
 
    HttpReply (const HttpReply&);
94
 
    // make the assignment operator private
95
 
    HttpReply& operator = (const HttpReply&);
96
 
 
97
 
  public:
98
 
    /// create a new object in a generic object
99
 
    /// @param argv the argument vector
100
 
    static Object* mknew (Vector* argv);
101
 
 
102
 
    /// @return true if the given quark is defined
103
 
    bool isquark (const long quark, const bool hflg) const;
104
 
 
105
 
    /// apply this object with a set of arguments and a quark
106
 
    /// @param robj  the current runnable
107
 
    /// @param nset  the current nameset    
108
 
    /// @param quark the quark to apply these arguments
109
 
    /// @param argv  the arguments to apply
110
 
    Object* apply (Runnable* robj, Nameset* nset, const long quark,
111
 
                   Vector* argv);
112
 
  };
113
 
}
114
 
 
115
 
#endif