Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com) | ||
3 | // | ||
4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
6 | // | ||
7 | // Official repository: https://github.com/CPPAlliance/http_proto | ||
8 | // | ||
9 | |||
10 | #ifndef BOOST_HTTP_PROTO_RFC_IMPL_UPGRADE_RULE_IPP | ||
11 | #define BOOST_HTTP_PROTO_RFC_IMPL_UPGRADE_RULE_IPP | ||
12 | |||
13 | #include <boost/http_proto/rfc/upgrade_rule.hpp> | ||
14 | #include <boost/http_proto/rfc/token_rule.hpp> | ||
15 | #include <boost/url/grammar/error.hpp> | ||
16 | #include <boost/url/grammar/parse.hpp> | ||
17 | |||
18 | namespace boost { | ||
19 | namespace http_proto { | ||
20 | |||
21 | auto | ||
22 | 41 | upgrade_protocol_rule_t:: | |
23 | parse( | ||
24 | char const*& it, | ||
25 | char const* end) const noexcept -> | ||
26 | result<value_type> | ||
27 | { | ||
28 | 41 | value_type t; | |
29 | // token | ||
30 | { | ||
31 | auto rv = grammar::parse( | ||
32 | 41 | it, end, token_rule); | |
33 |
2/2✓ Branch 1 taken 3 times.
✓ Branch 2 taken 38 times.
|
41 | if(! rv) |
34 | 3 | return rv.error(); | |
35 | 38 | t.name = *rv; | |
36 | } | ||
37 | // [ "/" token ] | ||
38 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 30 times.
|
38 | if( it == end || |
39 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 7 times.
|
8 | *it != '/') |
40 | 31 | return t; | |
41 | 7 | ++it; | |
42 | auto rv = grammar::parse( | ||
43 | 7 | it, end, token_rule); | |
44 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
|
7 | if(! rv) |
45 | ✗ | return rv.error(); | |
46 | 7 | t.version = *rv; | |
47 | 7 | return t; | |
48 | } | ||
49 | |||
50 | } // http_proto | ||
51 | } // boost | ||
52 | |||
53 | #endif | ||
54 |