Exemplo n.º 1
0
bool HttpHeaders::Has(const StringPiece& header_name) const {
    std::vector<std::pair<std::string, std::string> >::const_iterator iter;
    for (iter = m_headers.begin(); iter != m_headers.end(); ++iter) {
        if (header_name.ignore_case_equal(iter->first)) {
            return true;
        }
    }
    return false;
}
Exemplo n.º 2
0
// Used when a http header appears multiple times.
// return false if it doesn't exist.
bool HttpHeaders::Get(const StringPiece& header_name,
                      std::vector<std::string>* header_values) const {
    header_values->clear();
    std::vector<std::pair<std::string, std::string> >::const_iterator iter;
    for (iter = m_headers.begin(); iter != m_headers.end(); ++iter) {
        if (header_name.ignore_case_equal(iter->first)) {
            header_values->push_back(iter->second);
        }
    }
    return header_values->size() > 0;
}
Exemplo n.º 3
0
// Get a header value. return false if it does not exist.
// the header name is not case sensitive.
bool HttpHeaders::Get(const StringPiece& header_name,
                      std::string** header_value) {
    std::vector<std::pair<std::string, std::string> >::iterator iter;
    for (iter = m_headers.begin(); iter != m_headers.end(); ++iter) {
        if (header_name.ignore_case_equal(iter->first)) {
            *header_value = &iter->second;
            return true;
        }
    }
    return false;
}
Exemplo n.º 4
0
bool HttpHeaders::Remove(const StringPiece& header_name) {
    bool result = false;
    std::vector<std::pair<std::string, std::string> >::iterator iter;
    for (iter = m_headers.begin(); iter != m_headers.end();) {
        if (header_name.ignore_case_equal(iter->first)) {
            iter = m_headers.erase(iter);
            result = true;
        } else {
            ++iter;
        }
    }
    return result;
}