Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/shared/Utils.h

Issue 4974480757620736: Issue #1356 - Improve detection of the issuer of the request (Closed)
Patch Set: Revert the incorrect cleanup Created Oct. 31, 2014, 3:08 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/plugin/PluginWbPassThrough.cpp ('K') | « src/plugin/SinkPolicy.inl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
Felix Dahlke 2014/11/03 04:58:16 1. I think we generally capitalise it like this: E
Oleksandr 2014/11/03 11:37:37 2. Http headers can be seperated by '\0' as well.
sergei 2014/11/03 14:17:46 If we really want to have it in utils then tests a
Oleksandr 2014/11/04 12:02:42 Yes, I can see how the changes to make this more g
Felix Dahlke 2014/11/04 16:13:25 Fully agree, good points Sergei.
+{
+ 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
« src/plugin/PluginWbPassThrough.cpp ('K') | « src/plugin/SinkPolicy.inl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld