]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpRequestMethod.h
2 * $Id: HttpRequestMethod.h,v 1.12 2008/02/26 00:16:47 rousskov Exp $
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33 #ifndef SQUID_HTTPREQUESTMETHOD_H
34 #define SQUID_HTTPREQUESTMETHOD_H
38 #include "SquidString.h"
41 METHOD_NONE
, /* 000 */
43 METHOD_POST
, /* 010 */
45 METHOD_HEAD
, /* 100 */
46 METHOD_CONNECT
, /* 101 */
47 METHOD_TRACE
, /* 110 */
48 METHOD_PURGE
, /* 111 */
50 METHOD_DELETE
, /* RFC2616 section 9.7 */
72 METHOD_ENUM_END
// MUST be last, (yuck) this is used as an array-initialization index constant!
77 * This class represents an HTTP Request METHOD
78 * - i.e. PUT, POST, GET etc.
79 * It has a runtime extension facility to allow it to
80 * efficiently support new methods
83 class HttpRequestMethod
87 static void AddExtension(const char *methodString
);
88 static void Configure(SquidConfig
&Config
);
90 HttpRequestMethod() : theMethod(METHOD_NONE
), theImage() {}
92 HttpRequestMethod(_method_t
const aMethod
) : theMethod(aMethod
), theImage() {}
95 \param begin string to convert to request method.
96 \param end end of the method string (relative to begin). Use NULL if this is unknown.
98 \note DO NOT give end a default (ie NULL). That will cause silent char* conversion clashes.
100 HttpRequestMethod(char const * begin
, char const * end
);
102 HttpRequestMethod
& operator = (const HttpRequestMethod
& aMethod
)
104 theMethod
= aMethod
.theMethod
;
105 theImage
= aMethod
.theImage
;
109 HttpRequestMethod
& operator = (_method_t
const aMethod
)
116 bool operator == (_method_t
const & aMethod
) const { return theMethod
== aMethod
; }
117 bool operator == (HttpRequestMethod
const & aMethod
) const
119 return theMethod
== aMethod
.theMethod
&&
120 (theMethod
!= METHOD_OTHER
|| theImage
== aMethod
.theImage
);
123 bool operator != (_method_t
const & aMethod
) const { return theMethod
!= aMethod
; }
124 bool operator != (HttpRequestMethod
const & aMethod
) const
126 return !operator==(aMethod
);
129 /** Iterate through all HTTP method IDs. */
130 HttpRequestMethod
& operator++()
132 // TODO: when this operator is used in more than one place,
133 // replace it with HttpRequestMethods::Iterator API
134 // XXX: this interface can create METHOD_OTHER without an image
135 assert(theMethod
< METHOD_ENUM_END
);
136 theMethod
= (_method_t
)(1 + (int)theMethod
);
140 /** Get an ID representation of the method.
141 \retval METHOD_NONE the method is unset
142 \retval METHOD_OTHER the method is not recognized and has no unique ID
143 \retval * the method is on of the recognized HTTP methods.
145 _method_t
const id() const { return theMethod
; }
147 /** Get a char string representation of the method. */
148 char const* image() const;
150 bool isCacheble() const;
151 bool purgesOthers() const;
154 static const char *RequestMethodStr
[];
156 _method_t theMethod
; ///< Method type
157 String theImage
; ///< Used for store METHOD_OTHER only
160 inline std::ostream
&
161 operator << (std::ostream
&os
, HttpRequestMethod
const &method
)
163 os
<< method
.image();
168 RequestMethodStr(const _method_t m
)
170 return HttpRequestMethod(m
).image();
174 RequestMethodStr(const HttpRequestMethod
& m
)
179 #endif /* SQUID_HTTPREQUESTMETHOD_H */