22// Licensed under the Apache 2.0 License.
33
44#include " ccf/crypto/key_pair.h"
5+ #include " ccf/http_accept.h"
56#include " ccf/http_query.h"
6- #include " http/http_accept.h"
77#include " http/http_builder.h"
88#include " http/http_parser.h"
99
@@ -565,12 +565,12 @@ DOCTEST_TEST_CASE("Query parser")
565565DOCTEST_TEST_CASE (" Parse Accept header" )
566566{
567567 {
568- const auto fields = http::parse_accept_header (" " );
568+ const auto fields = ccf:: http::parse_accept_header (" " );
569569 DOCTEST_REQUIRE (fields.empty ());
570570 }
571571
572572 {
573- const auto fields = http::parse_accept_header (" foo/bar;q=0.25" );
573+ const auto fields = ccf:: http::parse_accept_header (" foo/bar;q=0.25" );
574574 DOCTEST_REQUIRE (fields.size () == 1 );
575575 const auto & field = fields[0 ];
576576 DOCTEST_REQUIRE (field.mime_type == " foo" );
@@ -581,7 +581,7 @@ DOCTEST_TEST_CASE("Parse Accept header")
581581 {
582582 // Shuffled and modified version of Firefox 91 default value, to test
583583 // sorting
584- const auto fields = http::parse_accept_header (
584+ const auto fields = ccf:: http::parse_accept_header (
585585 " image/webp;q=0.8, "
586586 " image/*;q=0.8, "
587587 " text/html, "
@@ -591,31 +591,35 @@ DOCTEST_TEST_CASE("Parse Accept header")
591591 " */*;q=0.8" );
592592 DOCTEST_REQUIRE (fields.size () == 7 );
593593
594- DOCTEST_REQUIRE (fields[0 ] == http::AcceptHeaderField{" text" , " html" , 1 .0f });
595594 DOCTEST_REQUIRE (
596- fields[1 ] == http::AcceptHeaderField{" image " , " avif " , 1 .0f });
595+ fields[0 ] == ccf:: http::AcceptHeaderField{" text " , " html " , 1 .0f });
597596 DOCTEST_REQUIRE (
598- fields[2 ] == http::AcceptHeaderField{" application " , " xhtml+xml " , 1 .0f });
597+ fields[1 ] == ccf:: http::AcceptHeaderField{" image " , " avif " , 1 .0f });
599598 DOCTEST_REQUIRE (
600- fields[3 ] == http::AcceptHeaderField{" application" , " xml" , 0 .9f });
599+ fields[2 ] ==
600+ ccf::http::AcceptHeaderField{" application" , " xhtml+xml" , 1 .0f });
601601 DOCTEST_REQUIRE (
602- fields[4 ] == http::AcceptHeaderField{" image" , " webp" , 0 .8f });
603- DOCTEST_REQUIRE (fields[5 ] == http::AcceptHeaderField{" image" , " *" , 0 .8f });
604- DOCTEST_REQUIRE (fields[6 ] == http::AcceptHeaderField{" *" , " *" , 0 .8f });
602+ fields[3 ] == ccf::http::AcceptHeaderField{" application" , " xml" , 0 .9f });
603+ DOCTEST_REQUIRE (
604+ fields[4 ] == ccf::http::AcceptHeaderField{" image" , " webp" , 0 .8f });
605+ DOCTEST_REQUIRE (
606+ fields[5 ] == ccf::http::AcceptHeaderField{" image" , " *" , 0 .8f });
607+ DOCTEST_REQUIRE (fields[6 ] == ccf::http::AcceptHeaderField{" *" , " *" , 0 .8f });
605608 }
606609
607610 {
608- DOCTEST_REQUIRE_THROWS (http::parse_accept_header (" not_a_mime_type" ));
609- DOCTEST_REQUIRE_THROWS (http::parse_accept_header (" valid/mime;q=notnum" ));
610- DOCTEST_REQUIRE_THROWS (http::parse_accept_header (" ," ));
611+ DOCTEST_REQUIRE_THROWS (ccf::http::parse_accept_header (" not_a_mime_type" ));
612+ DOCTEST_REQUIRE_THROWS (
613+ ccf::http::parse_accept_header (" valid/mime;q=notnum" ));
614+ DOCTEST_REQUIRE_THROWS (ccf::http::parse_accept_header (" ," ));
611615 }
612616}
613617
614618DOCTEST_TEST_CASE (" Accept header MIME matching" )
615619{
616- const auto a = http::AcceptHeaderField{" foo" , " bar" , 1 .0f };
617- const auto b = http::AcceptHeaderField{" foo" , " *" , 1 .0f };
618- const auto c = http::AcceptHeaderField{" *" , " *" , 1 .0f };
620+ const auto a = ccf:: http::AcceptHeaderField{" foo" , " bar" , 1 .0f };
621+ const auto b = ccf:: http::AcceptHeaderField{" foo" , " *" , 1 .0f };
622+ const auto c = ccf:: http::AcceptHeaderField{" *" , " *" , 1 .0f };
619623
620624 DOCTEST_REQUIRE (a.matches (" foo/bar" ));
621625 DOCTEST_REQUIRE_FALSE (a.matches (" foo/baz" ));
0 commit comments