2 * Copyright (C) 1996-2020 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/ReservationId.h"
15 #include "helper/ResultCode.h"
25 * This object stores the reply message from a helper lookup
26 * It provides parser routing to accept a raw buffer and process the
27 * helper reply into fields for easy access by callers
32 // copy are prohibited for now
33 Reply(const Helper::Reply
&r
);
34 Reply
&operator =(const Helper::Reply
&r
);
37 explicit Reply(Helper::ResultCode res
) : result(res
), notes() {}
39 /// Creates a NULL reply
42 const MemBuf
&other() const {return other_
.isNull() ? emptyBuf() : other_
;};
44 /** parse a helper response line format:
45 * line := [ result ] *#( kv-pair )
46 * kv-pair := OWS token '=' ( quoted-string | token )
48 * token are URL-decoded.
49 * quoted-string are \-escape decoded and the quotes are stripped.
51 // XXX: buf should be const but we may need strwordtok() and rfc1738_unescape()
52 //void parse(char *buf, size_t len);
55 bool accumulate(const char *buf
, size_t len
);
58 /// The helper response 'result' field.
59 Helper::ResultCode result
;
61 // list of key=value pairs the helper produced
64 /// The stateful replies should include the reservation ID
65 Helper::ReservationId reservationId
;
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 */