]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/HttpRequestMethod.cc
5 * DEBUG: section 73 HTTP Request
6 * AUTHOR: Duane Wessels
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
34 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
37 #include "squid-old.h"
38 #include "HttpRequestMethod.h"
41 const char* HttpRequestMethod::RequestMethodStr
[] = {
76 _method_t
&operator++ (_method_t
&aMethod
)
78 int tmp
= (int)aMethod
;
79 aMethod
= (_method_t
)(++tmp
);
84 * Construct a HttpRequestMethod from a NULL terminated string such as "GET"
85 * or from a range of chars, * such as "GET" from "GETFOOBARBAZ"
86 * (pass in pointer to G and pointer to F.)
88 HttpRequestMethod::HttpRequestMethod(char const *begin
, char const *end
) : theMethod (METHOD_NONE
)
94 * This check for '%' makes sure that we don't
95 * match one of the extension method placeholders,
96 * which have the form %EXT[0-9][0-9]
103 * if e is NULL, b must be NULL terminated and we
104 * make e point to the first whitespace character
108 end
= begin
+ strcspn(begin
, w_space
);
111 theMethod
= METHOD_NONE
;
115 for (++theMethod
; theMethod
< METHOD_ENUM_END
; ++theMethod
) {
116 if (0 == strncasecmp(begin
, RequestMethodStr
[theMethod
], end
-begin
)) {
121 // if method not found and method string is not null then it is other method
122 theMethod
= METHOD_OTHER
;
123 theImage
.limitInit(begin
,end
-begin
);
126 /** \todo AYJ: this _should_ be obsolete. Since all such methods fit nicely into METHOD_OTHER now. */
128 HttpRequestMethod::AddExtension(const char *mstr
)
130 #if 0 /* obsolete now that we have METHOD_OTHER always enabled */
131 _method_t method
= METHOD_NONE
;
133 for (++method
; method
< METHOD_ENUM_END
; ++method
) {
134 if (0 == strcmp(mstr
, RequestMethodStr
[method
])) {
135 debugs(23, 2, "Extension method '" << mstr
<< "' already exists");
139 if (0 != strncmp("%EXT", RequestMethodStr
[method
], 4))
142 /* Don't free statically allocated "%EXTnn" string */
143 RequestMethodStr
[method
] = xstrdup(mstr
);
145 debugs(23, 1, "Extension method '" << mstr
<< "' added, enum=" << method
);
150 debugs(23, 1, "WARNING: Could not add new extension method '" << mstr
<< "' due to lack of array space");
155 HttpRequestMethod::Configure(SquidConfig
&cfg
)
157 #if 0 /* extension methods obsolete now that we have METHOD_OTHER always enabled */
158 wordlist
*w
= cfg
.ext_methods
;
163 for (s
= w
->key
; *s
; s
++)
166 AddExtension(w
->key
);
174 HttpRequestMethod::image() const
176 if (METHOD_OTHER
!= theMethod
) {
177 return RequestMethodStr
[theMethod
];
179 if (theImage
.size()>0) {
180 return theImage
.termedBuf();
182 return "METHOD_OTHER";
188 HttpRequestMethod::isCacheble() const
190 // TODO: optimize the lookup with a precomputed flags array
191 // XXX: the list seems wrong; e.g., Is METHOD_DELETE really cachable?
192 // see also http.cc::httpCachable()
194 if (theMethod
== METHOD_CONNECT
)
197 if (theMethod
== METHOD_TRACE
)
200 if (theMethod
== METHOD_PUT
)
203 if (theMethod
== METHOD_POST
)
206 if (theMethod
== METHOD_OTHER
)
213 HttpRequestMethod::purgesOthers() const
215 // TODO: optimize the lookup with a precomputed flags array
218 /* common sense suggests purging is not required? */
219 case METHOD_GET
: // XXX: but we do purge HEAD on successful GET
225 case METHOD_PROPFIND
:
226 case METHOD_BPROPFIND
:
234 /* purging mandated by RFC 2616 */
240 /* purging suggested by common sense */
245 * RFC 2616 sayeth, in section 13.10, final paragraph:
246 * A cache that passes through requests for methods it does not
247 * understand SHOULD invalidate any entities referred to by the
255 return true; // not reached, but just in case