| 839 | } |
| 840 | |
| 841 | void |
| 842 | testContentLength() |
| 843 | { |
| 844 | response<empty_body> res{status::ok, 11}; |
| 845 | BEAST_EXPECT(res.count(field::content_length) == 0); |
| 846 | BEAST_EXPECT(res.count(field::transfer_encoding) == 0); |
| 847 | |
| 848 | res.content_length(0); |
| 849 | BEAST_EXPECT(res[field::content_length] == "0"); |
| 850 | |
| 851 | res.content_length(100); |
| 852 | BEAST_EXPECT(res[field::content_length] == "100"); |
| 853 | |
| 854 | res.content_length(boost::none); |
| 855 | BEAST_EXPECT(res.count(field::content_length) == 0); |
| 856 | |
| 857 | res.set(field::transfer_encoding, "chunked"); |
| 858 | res.content_length(0); |
| 859 | BEAST_EXPECT(res[field::content_length] == "0"); |
| 860 | BEAST_EXPECT(res.count(field::transfer_encoding) == 0); |
| 861 | |
| 862 | res.set(field::transfer_encoding, "chunked"); |
| 863 | res.content_length(100); |
| 864 | BEAST_EXPECT(res[field::content_length] == "100"); |
| 865 | BEAST_EXPECT(res.count(field::transfer_encoding) == 0); |
| 866 | |
| 867 | res.set(field::transfer_encoding, "chunked"); |
| 868 | res.content_length(boost::none); |
| 869 | BEAST_EXPECT(res.count(field::content_length) == 0); |
| 870 | BEAST_EXPECT(res.count(field::transfer_encoding) == 0); |
| 871 | |
| 872 | auto const check = [&](std::string s) |
| 873 | { |
| 874 | res.set(field::transfer_encoding, s); |
| 875 | res.content_length(0); |
| 876 | BEAST_EXPECT(res[field::content_length] == "0"); |
| 877 | BEAST_EXPECT(res[field::transfer_encoding] == s); |
| 878 | |
| 879 | res.set(field::transfer_encoding, s); |
| 880 | res.content_length(100); |
| 881 | BEAST_EXPECT(res[field::content_length] == "100"); |
| 882 | BEAST_EXPECT(res[field::transfer_encoding] == s); |
| 883 | |
| 884 | res.set(field::transfer_encoding, s); |
| 885 | res.content_length(boost::none); |
| 886 | BEAST_EXPECT(res.count(field::content_length) == 0); |
| 887 | BEAST_EXPECT(res[field::transfer_encoding] == s); |
| 888 | |
| 889 | res.set(field::transfer_encoding, s + ", chunked"); |
| 890 | res.content_length(0); |
| 891 | BEAST_EXPECT(res[field::content_length] == "0"); |
| 892 | BEAST_EXPECT(res[field::transfer_encoding] == s); |
| 893 | |
| 894 | res.set(field::transfer_encoding, s + ", chunked"); |
| 895 | res.content_length(100); |
| 896 | BEAST_EXPECT(res[field::content_length] == "100"); |
| 897 | BEAST_EXPECT(res[field::transfer_encoding] == s); |
| 898 |
nothing calls this directly
no outgoing calls
no test coverage detected