| 163 | } |
| 164 | |
| 165 | DataStatus |
| 166 | EsiProcessor::_getIncludeStatus(const DocNode &node) |
| 167 | { |
| 168 | DBG("[%s] inside getIncludeStatus", __FUNCTION__); |
| 169 | if (node.type == DocNode::TYPE_INCLUDE) { |
| 170 | const Attribute &url = node.attr_list.front(); |
| 171 | |
| 172 | if (url.value_len == 0) { // allow empty url |
| 173 | return STATUS_DATA_AVAILABLE; |
| 174 | } |
| 175 | |
| 176 | string raw_url(url.value, url.value_len); |
| 177 | StringHash::iterator iter = _include_urls.find(raw_url); |
| 178 | if (iter == _include_urls.end()) { |
| 179 | TSError("[%s] Data not requested for URL [%.*s]; no data to include", __FUNCTION__, url.value_len, url.value); |
| 180 | return STATUS_ERROR; |
| 181 | } |
| 182 | const string &processed_url = iter->second; |
| 183 | DataStatus status = _fetcher.getRequestStatus(processed_url); |
| 184 | DBG("[%s] Got status %d successfully for URL [%.*s]", __FUNCTION__, status, int(processed_url.size()), processed_url.data()); |
| 185 | return status; |
| 186 | } else if (node.type == DocNode::TYPE_SPECIAL_INCLUDE) { |
| 187 | int include_data_id = 0; |
| 188 | SpecialIncludeHandler *handler = nullptr; |
| 189 | for (AttributeList::const_iterator attr_iter = node.attr_list.begin(); attr_iter != node.attr_list.end(); ++attr_iter) { |
| 190 | if (attr_iter->name == INCLUDE_DATA_ID_ATTR) { |
| 191 | include_data_id = attr_iter->value_len; |
| 192 | handler = reinterpret_cast<SpecialIncludeHandler *>(const_cast<char *>(attr_iter->value)); |
| 193 | break; |
| 194 | } |
| 195 | } |
| 196 | if (include_data_id == 0 || handler == nullptr) { |
| 197 | TSError("[%s] Fail to find the special include data id attribute", __FUNCTION__); |
| 198 | return STATUS_ERROR; |
| 199 | } |
| 200 | DataStatus status = handler->getIncludeStatus(include_data_id); |
| 201 | DBG("[%s] Successfully got status %d for special include with id %d", __FUNCTION__, int(status), int(include_data_id)); |
| 202 | |
| 203 | return status; |
| 204 | } |
| 205 | DBG("[%s] node of type %s", __FUNCTION__, DocNode::type_names_[node.type]); |
| 206 | return STATUS_DATA_AVAILABLE; |
| 207 | } |
| 208 | |
| 209 | bool |
| 210 | EsiProcessor::_getIncludeData(const DocNode &node, const char **content_ptr /* = 0 */, int *content_len_ptr /* = 0 */) |
nothing calls this directly
no test coverage detected