Beast Logo

PrevUpHomeNext

http::ext_list

A list of extensions in a comma separated HTTP field value.

class ext_list
Types

Name

Description

const_iterator

A constant iterator to the list.

value_type

The type of each element in the list.

Member Functions

Name

Description

begin

Return a const iterator to the beginning of the list.

cbegin

Return a const iterator to the beginning of the list.

cend

Return a const iterator to the end of the list.

end

Return a const iterator to the end of the list.

exists

Return true if a token is present in the list.

ext_list

Construct a list.

find

Find a token in the list.

This container allows iteration of the extensions in a HTTP field value. The extension list is a comma separated list of token parameter list pairs.

If a parsing error is encountered while iterating the string, the behavior of the container will be as if a string containing only characters up to but excluding the first invalid character was used to construct the list.

BNF
ext-list    = *( "," OWS ) ext *( OWS "," [ OWS ext ] )
ext         = token param-list
param-list  = *( OWS ";" OWS param )
param       = token OWS [ "=" OWS ( token / quoted-string ) ]

To use this class, construct with the string to be parsed and then use begin and end, or range-for to iterate each item:

Example
for(auto const& ext : ext_list{"none, 7z;level=9, zip;no_context_takeover;bits=15"})
{
    std::cout << ext.first << "\n";
    for(auto const& param : ext.second)
    {
        std::cout << ";" << param.first;
        if(! param.second.empty())
            std::cout << "=" << param.second;
        std::cout << "\n";
    }
}
Requirements

Header: beast/http/rfc7230.hpp

Convenience header: beast/http.hpp


PrevUpHomeNext