]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/helper/Reply.h
2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef _SQUID_SRC_HELPER_REPLY_H
10 #define _SQUID_SRC_HELPER_REPLY_H
12 #include "base/CbcPointer.h"
13 #include "helper/forward.h"
14 #include "helper/ResultCode.h"
24 * This object stores the reply message from a helper lookup
25 * It provides parser routing to accept a raw buffer and process the
26 * helper reply into fields for easy access by callers
31 // copy are prohibited for now
32 Reply(const Helper::Reply
&r
);
33 Reply
&operator =(const Helper::Reply
&r
);
36 explicit Reply(Helper::ResultCode res
) : result(res
), notes(), whichServer(NULL
) {}
38 /// Creates a NULL reply
41 const MemBuf
&other() const {return other_
.isNull() ? emptyBuf() : other_
;};
43 /** parse a helper response line format:
44 * line := [ result ] *#( kv-pair )
45 * kv-pair := OWS token '=' ( quoted-string | token )
47 * token are URL-decoded.
48 * quoted-string are \-escape decoded and the quotes are stripped.
50 // XXX: buf should be const but we may need strwordtok() and rfc1738_unescape()
51 //void parse(char *buf, size_t len);
54 bool accumulate(const char *buf
, size_t len
);
57 /// The helper response 'result' field.
58 Helper::ResultCode result
;
60 // list of key=value pairs the helper produced
63 /// for stateful replies the responding helper 'server' needs to be preserved across callbacks
64 CbcPointer
<helper_stateful_server
> whichServer
;
67 void parseResponseKeys();
69 /// Return an empty MemBuf.
70 const MemBuf
&emptyBuf() const;
72 /// the remainder of the line
78 std::ostream
&operator <<(std::ostream
&os
, const Helper::Reply
&r
);
80 #endif /* _SQUID_SRC_HELPER_REPLY_H */