]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/HttpHeaderTools.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / HttpHeaderTools.h
index bec824ec02c82ec0635a745a871ddb3c8a1abcde..77fb6c2c97a1a223128cbc83435101d53595220f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -12,6 +12,7 @@
 #include "acl/forward.h"
 #include "format/Format.h"
 #include "HttpHeader.h"
+#include "sbuf/forward.h"
 
 #include <functional>
 #include <list>
@@ -25,7 +26,6 @@ class HeaderWithAcl;
 class HttpHeader;
 class HttpRequest;
 class StoreEntry;
-class String;
 
 typedef std::list<HeaderWithAcl> HeaderWithAclList;
 
@@ -117,9 +117,15 @@ public:
     bool quoted;
 };
 
-int httpHeaderParseOffset(const char *start, int64_t * off);
+/// A strtoll(10) wrapper that checks for strtoll() failures and other problems.
+/// XXX: This function is not fully compatible with some HTTP syntax rules.
+/// Just like strtoll(), allows whitespace prefix, a sign, and _any_ suffix.
+/// Requires at least one digit to be present.
+/// Sets "off" and "end" arguments if and only if no problems were found.
+/// \return true if and only if no problems were found.
+bool httpHeaderParseOffset(const char *start, int64_t *offPtr, char **endPtr = nullptr);
 
-int httpHeaderHasConnDir(const HttpHeader * hdr, const char *directive);
+bool httpHeaderHasConnDir(const HttpHeader * hdr, const SBuf &directive);
 int httpHeaderParseInt(const char *start, int *val);
 void httpHeaderPutStrf(HttpHeader * hdr, Http::HdrType id, const char *fmt,...) PRINTF_FORMAT_ARG3;