source: squid-ssl/trunk/fuentes/src/acl/ReplyHeaderStrategy.h @ 5495

Last change on this file since 5495 was 5495, checked in by Juanma, 2 years ago

Initial release

File size: 1.8 KB
Line 
1/*
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
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
9#ifndef SQUID_ACLREPLYHEADERSTRATEGY_H
10#define SQUID_ACLREPLYHEADERSTRATEGY_H
11
12class ACLChecklist;
13
14#include "acl/Acl.h"
15#include "acl/Data.h"
16#include "acl/FilledChecklist.h"
17#include "acl/Strategy.h"
18#include "HttpReply.h"
19
20template <http_hdr_type header>
21class ACLReplyHeaderStrategy : public ACLStrategy<char const *>
22{
23
24public:
25    virtual int match (ACLData<char const *> * &, ACLFilledChecklist *, ACLFlags &);
26    virtual bool requiresReply() const {return true;}
27
28    static ACLReplyHeaderStrategy *Instance();
29    /* Not implemented to prevent copies of the instance. */
30    /* Not private to prevent brain dead g+++ warnings about
31     * private constructors with no friends */
32    ACLReplyHeaderStrategy(ACLReplyHeaderStrategy const &);
33
34private:
35    static ACLReplyHeaderStrategy *Instance_;
36    ACLReplyHeaderStrategy() {}
37
38    ACLReplyHeaderStrategy&operator=(ACLReplyHeaderStrategy const &);
39};
40
41template <http_hdr_type header>
42int
43ACLReplyHeaderStrategy<header>::match (ACLData<char const *> * &data, ACLFilledChecklist *checklist, ACLFlags &)
44{
45    char const *theHeader = checklist->reply->header.getStr(header);
46
47    if (NULL == theHeader)
48        return 0;
49
50    return data->match(theHeader);
51}
52
53template <http_hdr_type header>
54ACLReplyHeaderStrategy<header> *
55ACLReplyHeaderStrategy<header>::Instance()
56{
57    if (!Instance_)
58        Instance_ = new ACLReplyHeaderStrategy<header>;
59
60    return Instance_;
61}
62
63template <http_hdr_type header>
64ACLReplyHeaderStrategy<header> * ACLReplyHeaderStrategy<header>::Instance_ = NULL;
65
66#endif /* SQUID_REPLYHEADERSTRATEGY_H */
67
Note: See TracBrowser for help on using the repository browser.