93.33% Lines (14/15) 100.00% Functions (1/1)
TLA Baseline Branch
Line Hits Code Line Hits Code
1   // 1   //
2   // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com) 2   // Copyright (c) 2021 Vinnie Falco (vinnie.falco@gmail.com)
3   // 3   //
4   // Distributed under the Boost Software License, Version 1.0. (See accompanying 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) 5   // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6   // 6   //
7   // Official repository: https://github.com/cppalliance/http 7   // Official repository: https://github.com/cppalliance/http
8   // 8   //
9   9  
10   #include <boost/http/rfc/upgrade_rule.hpp> 10   #include <boost/http/rfc/upgrade_rule.hpp>
11   #include <boost/http/rfc/token_rule.hpp> 11   #include <boost/http/rfc/token_rule.hpp>
12   #include <boost/url/grammar/error.hpp> 12   #include <boost/url/grammar/error.hpp>
13   #include <boost/url/grammar/parse.hpp> 13   #include <boost/url/grammar/parse.hpp>
14   14  
15   namespace boost { 15   namespace boost {
16   namespace http { 16   namespace http {
17   namespace implementation_defined { 17   namespace implementation_defined {
18   18  
19   auto 19   auto
HITCBC 20   47 upgrade_protocol_rule_t:: 20   47 upgrade_protocol_rule_t::
21   parse( 21   parse(
22   char const*& it, 22   char const*& it,
23   char const* end) const noexcept -> 23   char const* end) const noexcept ->
24   system::result<value_type> 24   system::result<value_type>
25   { 25   {
HITCBC 26   47 value_type t; 26   47 value_type t;
27   // token 27   // token
28   { 28   {
HITCBC 29   47 auto rv = grammar::parse( 29   47 auto rv = grammar::parse(
30   it, end, token_rule); 30   it, end, token_rule);
HITCBC 31   47 if(! rv) 31   47 if(! rv)
HITCBC 32   4 return rv.error(); 32   4 return rv.error();
HITCBC 33   43 t.name = *rv; 33   43 t.name = *rv;
34   } 34   }
35   // [ "/" token ] 35   // [ "/" token ]
HITCBC 36   43 if( it == end || 36   43 if( it == end ||
HITCBC 37   11 *it != '/') 37   11 *it != '/')
HITCBC 38   33 return t; 38   33 return t;
HITCBC 39   10 ++it; 39   10 ++it;
HITCBC 40   10 auto rv = grammar::parse( 40   10 auto rv = grammar::parse(
41   it, end, token_rule); 41   it, end, token_rule);
HITCBC 42   10 if(! rv) 42   10 if(! rv)
MISUBC 43   return rv.error(); 43   return rv.error();
HITCBC 44   10 t.version = *rv; 44   10 t.version = *rv;
HITCBC 45   10 return t; 45   10 return t;
46   } 46   }
47   47  
48   } // implementation_defined 48   } // implementation_defined
49   } // http 49   } // http
50   } // boost 50   } // boost