Skip to content

Commit

Permalink
bp/Response: move code to resource_tag_append_etag_encoding()
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Jan 22, 2025
1 parent e628936 commit b60ed80
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/bp/Response.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ GetEncodingCacheKey(AllocatorPtr alloc,
if (const auto etag = response_headers.GetSloppy(etag_header);
etag.data() != nullptr)
return StringWithHash{
alloc.ConcatView(resource_tag, "|etag="sv, etag, "."sv, encoding),
resource_tag_append_etag_encoding(alloc, resource_tag, etag, encoding),
};

return StringWithHash{nullptr};
Expand Down
10 changes: 10 additions & 0 deletions src/resource_tag.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
#include "http/List.hxx"
#include "AllocatorPtr.hxx"

using std::string_view_literals::operator""sv;

std::string_view
resource_tag_append_etag_encoding(AllocatorPtr alloc, std::string_view tag,
std::string_view etag,
std::string_view encoding) noexcept
{
return alloc.ConcatView(tag, "|etag="sv, etag, "."sv, encoding);
}

const char *
resource_tag_append_etag(AllocatorPtr alloc, const char *tag,
const StringMap &headers) noexcept
Expand Down
11 changes: 11 additions & 0 deletions src/resource_tag.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,20 @@

#pragma once

#include <string_view>

class AllocatorPtr;
class StringMap;

/**
* A tag which addresses a resource in the filter cache.
*/
[[gnu::pure]]
std::string_view
resource_tag_append_etag_encoding(AllocatorPtr alloc, std::string_view tag,
std::string_view etag,
std::string_view encoding) noexcept;

/**
* A tag which addresses a resource in the filter cache.
*/
Expand Down

0 comments on commit b60ed80

Please sign in to comment.