]> git.ipfire.org Git - thirdparty/squid.git/blame - src/helper/Reply.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / helper / Reply.h
CommitLineData
bbc27441 1/*
ef57eb7b 2 * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
bbc27441
AJ
3 *
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.
7 */
8
24438ec5
AJ
9#ifndef _SQUID_SRC_HELPER_REPLY_H
10#define _SQUID_SRC_HELPER_REPLY_H
0272dd08
AJ
11
12#include "base/CbcPointer.h"
24438ec5
AJ
13#include "helper/forward.h"
14#include "helper/ResultCode.h"
0272dd08 15#include "MemBuf.h"
7bbefa01 16#include "Notes.h"
0272dd08 17
0272dd08 18#include <ostream>
0272dd08 19
24438ec5
AJ
20namespace Helper
21{
0272dd08
AJ
22
23/**
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
27 */
24438ec5 28class Reply
0272dd08
AJ
29{
30private:
e166785a 31 // copy are prohibited for now
24438ec5
AJ
32 Reply(const Helper::Reply &r);
33 Reply &operator =(const Helper::Reply &r);
0272dd08
AJ
34
35public:
32fd6d8a 36 explicit Reply(Helper::ResultCode res = Helper::Unknown) : result(res), notes(), whichServer(NULL) {
3c2c35d3
AJ
37 other_.init(1,1);
38 other_.terminate();
39 }
40
0272dd08 41 // create/parse details from the msg buffer provided
7bbefa01 42 // XXX: buf should be const but parse() needs non-const for now
24438ec5 43 Reply(char *buf, size_t len);
0272dd08
AJ
44
45 const MemBuf &other() const { return other_; }
46
47 /// backward compatibility:
48 /// access to modifiable blob, required by redirectHandleReply()
49 /// and by urlParse() in ClientRequestContext::clientRedirectDone()
50 /// and by token blob/arg parsing in Negotiate auth handler
51 MemBuf &modifiableOther() const { return *const_cast<MemBuf*>(&other_); }
52
7bbefa01 53 /** parse a helper response line format:
fd7f26ea
AJ
54 * line := [ result ] *#( kv-pair )
55 * kv-pair := OWS token '=' ( quoted-string | token )
7bbefa01 56 *
05e52854
AJ
57 * token are URL-decoded.
58 * quoted-string are \-escape decoded and the quotes are stripped.
7bbefa01
AJ
59 */
60 // XXX: buf should be const but we may need strwordtok() and rfc1738_unescape()
05e52854 61 void parse(char *buf, size_t len);
ab332e27 62
0272dd08
AJ
63public:
64 /// The helper response 'result' field.
24438ec5 65 Helper::ResultCode result;
0272dd08 66
7bbefa01 67 // list of key=value pairs the helper produced
cf9f0261 68 NotePairs notes;
0272dd08
AJ
69
70 /// for stateful replies the responding helper 'server' needs to be preserved across callbacks
71 CbcPointer<helper_stateful_server> whichServer;
72
73private:
05e52854 74 void parseResponseKeys();
7bbefa01 75
0272dd08
AJ
76 /// the remainder of the line
77 MemBuf other_;
78};
79
24438ec5
AJ
80} // namespace Helper
81
82std::ostream &operator <<(std::ostream &os, const Helper::Reply &r);
0272dd08 83
24438ec5 84#endif /* _SQUID_SRC_HELPER_REPLY_H */
f53969cc 85