| 823 | } |
| 824 | |
| 825 | SC::Result SC::HttpClientSession::appendMatchingCookies(StringSpan url, size_t& numHeaders) |
| 826 | { |
| 827 | ParsedUrl parsed; |
| 828 | SC_TRY_MSG(parseUrl(url, parsed), "HttpClientSession: invalid request URL"); |
| 829 | |
| 830 | const size_t cookieHeaderStart = headerScratchUsed; |
| 831 | bool wroteCookie = false; |
| 832 | for (size_t idx = 0; idx < sessionMemory.cookies.sizeInElements(); ++idx) |
| 833 | { |
| 834 | const HttpClientSessionCookie& cookie = sessionMemory.cookies[idx]; |
| 835 | if (not cookie.isInUse()) |
| 836 | { |
| 837 | continue; |
| 838 | } |
| 839 | if ((cookie.flags & HttpClientSessionCookie::Secure) != 0 and not parsed.isHttps) |
| 840 | { |
| 841 | continue; |
| 842 | } |
| 843 | if (not cookieDomainMatches(cookie, parsed.host) or not cookiePathMatches(cookie, parsed.path)) |
| 844 | { |
| 845 | continue; |
| 846 | } |
| 847 | |
| 848 | SC_TRY(appendScratch(cookie.name, wroteCookie)); |
| 849 | SC_TRY(appendScratch(StringSpan("="), false)); |
| 850 | SC_TRY(appendScratch(cookie.value, false)); |
| 851 | wroteCookie = true; |
| 852 | } |
| 853 | |
| 854 | if (wroteCookie) |
| 855 | { |
| 856 | const StringSpan value( |
| 857 | {sessionMemory.headerScratch.data() + cookieHeaderStart, headerScratchUsed - cookieHeaderStart}, false, |
| 858 | StringEncoding::Ascii); |
| 859 | SC_TRY(appendPreparedHeader(StringSpan("Cookie"), value, numHeaders)); |
| 860 | } |
| 861 | return Result(true); |
| 862 | } |
| 863 | |
| 864 | SC::Result SC::HttpClientSession::prepareRequest(const HttpClientRequest& source, HttpClientRequest& prepared) |
| 865 | { |
nothing calls this directly
no test coverage detected