| 39 | } |
| 40 | |
| 41 | bool |
| 42 | UrlMappingPathIndex::Insert(url_mapping *mapping) |
| 43 | { |
| 44 | int scheme_idx; |
| 45 | int port = (mapping->fromURL).port_get(); |
| 46 | UrlMappingTrie *trie; |
| 47 | int from_path_len; |
| 48 | const char *from_path; |
| 49 | |
| 50 | trie = _GetTrie(&(mapping->fromURL), scheme_idx, port); |
| 51 | |
| 52 | if (!trie) { |
| 53 | trie = new UrlMappingTrie(); |
| 54 | m_tries.insert(UrlMappingGroup::value_type(UrlMappingTrieKey(scheme_idx, port), trie)); |
| 55 | Dbg(dbg_ctl_UrlMappingPathIndex_Insert, "Created new trie for scheme index, port combo <%d, %d>", scheme_idx, port); |
| 56 | } |
| 57 | |
| 58 | from_path = mapping->fromURL.path_get(&from_path_len); |
| 59 | if (!trie->Insert(from_path, mapping, mapping->getRank(), from_path_len)) { |
| 60 | Error("Couldn't insert into trie!"); |
| 61 | return false; |
| 62 | } |
| 63 | Dbg(dbg_ctl_UrlMappingPathIndex_Insert, "Inserted new element!"); |
| 64 | return true; |
| 65 | } |
| 66 | |
| 67 | url_mapping * |
| 68 | UrlMappingPathIndex::Search(URL *request_url, int request_port, bool normal_search /* = true */) const |
no test coverage detected