]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/http/ContentLengthInterpreter.h
2 * Copyright (C) 1996-2021 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_HTTP_CONTENTLENGTH_INTERPRETER_H
10 #define SQUID_SRC_HTTP_CONTENTLENGTH_INTERPRETER_H
12 #include "http/StatusCode.h"
19 /// Finds the intended Content-Length value while parsing message-header fields.
20 /// Deals with complications such as value lists and/or repeated fields.
21 class ContentLengthInterpreter
24 ContentLengthInterpreter();
26 /// updates history based on the given message-header field
27 /// \return true iff the field should be added/remembered for future use
28 bool checkField(const String
&field
);
30 /// prohibits Content-Length in 1xx and 204 responses
31 void applyStatusCodeRules(const StatusCode code
) {
32 if (!prohibitedAndIgnored_
&& ProhibitsContentLength(code
))
33 prohibitedAndIgnored_
= (code
== scNoContent
) ? "prohibited and ignored in the 204 response" :
34 "prohibited and ignored the 1xx response";
38 /// prohibits Content-Length in GET/HEAD requests
39 // void applyRequestMethodRules(const Http::MethodType method);
41 /// prohibits Content-Length in trailer
42 void applyTrailerRules() {
43 if (!prohibitedAndIgnored_
)
44 prohibitedAndIgnored_
= "prohibited in trailers";
47 const char *prohibitedAndIgnored() const { return prohibitedAndIgnored_
; }
49 /// intended Content-Length value if sawGood is set and sawBad is not set
50 /// meaningless otherwise
53 /* for debugging (declared here to minimize padding) */
54 const char *headerWideProblem
; ///< worst header-wide problem found (or nil)
55 const int debugLevel
; ///< debugging level for certain warnings
57 /// whether a malformed Content-Length value was present
60 /// whether all remembered fields should be removed
61 /// removed fields ought to be replaced with the intended value (if known)
62 /// irrelevant if sawBad is set
65 /// whether a valid field value was present, possibly among problematic ones
66 /// irrelevant if sawBad is set
70 const char *findDigits(const char *prefix
, const char *valueEnd
) const;
71 bool goodSuffix(const char *suffix
, const char * const end
) const;
72 bool checkValue(const char *start
, const int size
);
73 bool checkList(const String
&list
);
76 /// whether and why Content-Length is prohibited
77 const char *prohibitedAndIgnored_
;
82 #endif /* SQUID_SRC_HTTP_CONTENTLENGTH_INTERPRETER_H */