Index: src/shared/Utils.h |
=================================================================== |
--- a/src/shared/Utils.h |
+++ b/src/shared/Utils.h |
@@ -50,4 +50,21 @@ |
return trimmed; |
} |
+template <class T> |
+T ExtractHTTPHeader(const T& allHeaders, const T& targetHeaderName, const T& delimiter) |
+{ |
+ auto targetHeaderBeginsAt = allHeaders.find(targetHeaderName); |
+ if (targetHeaderBeginsAt == T::npos) |
+ { |
+ return T(); |
+ } |
+ targetHeaderBeginsAt += targetHeaderName.length(); |
+ auto targetHeaderEndsAt = allHeaders.find(delimiter, targetHeaderBeginsAt); |
+ if (targetHeaderEndsAt == T::npos) |
+ { |
+ return T(); |
+ } |
+ return allHeaders.substr(targetHeaderBeginsAt, targetHeaderEndsAt - targetHeaderBeginsAt); |
+} |
+ |
#endif // UTILS_H |