* @brief Iterates through all User-Agent headers and fields and classifies them using provided classifier. * @param c classifier * @param buf marshal buffer from the request * @param hdrs headers handle from the request * @param classname reference to the string where the class name will be returned */
| 146 | * @param classname reference to the string where the class name will be returned |
| 147 | */ |
| 148 | static bool |
| 149 | classifyUserAgent(const Classifier &c, TSMBuffer buf, TSMLoc hdrs, String &classname) |
| 150 | { |
| 151 | TSMLoc field; |
| 152 | bool matched = false; |
| 153 | |
| 154 | field = TSMimeHdrFieldFind(buf, hdrs, TS_MIME_FIELD_USER_AGENT, TS_MIME_LEN_USER_AGENT); |
| 155 | while (field != TS_NULL_MLOC && !matched) { |
| 156 | const char *value; |
| 157 | int len; |
| 158 | int count = TSMimeHdrFieldValuesCount(buf, hdrs, field); |
| 159 | |
| 160 | for (int i = 0; i < count; ++i) { |
| 161 | value = TSMimeHdrFieldValueStringGet(buf, hdrs, field, i, &len); |
| 162 | const String val(value, len); |
| 163 | if (c.classify(val, classname)) { |
| 164 | matched = true; |
| 165 | break; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | field = ::nextDuplicate(buf, hdrs, field); |
| 170 | } |
| 171 | |
| 172 | TSHandleMLocRelease(buf, hdrs, field); |
| 173 | return matched; |
| 174 | } |
| 175 | |
| 176 | static String |
| 177 | getUri(TSMBuffer buf, TSMLoc url) |
no test coverage detected