Skip to content

Take string view in mime methods #12167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
987efba
Take string_view in MIMEField::name_set
hnakamur Apr 2, 2025
aa4c4d3
Take string_view in MIMEField::value_set
hnakamur Apr 2, 2025
579ad83
Take string_view in MIMEField::value_append
hnakamur Apr 2, 2025
84e3d77
Take string_view in MIMEField::value_get_index
hnakamur Apr 2, 2025
8ba3225
Take optional<string_view> in MIMEHdr::field_create
hnakamur Apr 2, 2025
1bc6868
Take string_view in MIMEHdr::field_create
hnakamur Apr 2, 2025
2fe059f
Take string_view in MIMEHdr::field_find
hnakamur Apr 6, 2025
3000f2d
Take string_view in MIMEHdr::field_delete
hnakamur Apr 6, 2025
fbc102d
Take string_view in MIMEHdr::value_get_index
hnakamur Apr 6, 2025
52f4ce2
Delete const char * version of MIMEHdr::value_get
hnakamur Apr 6, 2025
f472a08
Take string_view in MIMEHdr::value_get
hnakamur Apr 6, 2025
7cc69a0
Take string_view in MIMEHdr::value_get_int
hnakamur Apr 6, 2025
1b9807b
Take string_view in MIMEHdr::value_get_uint
hnakamur Apr 6, 2025
8f44828
Take string_view in MIMEHdr::value_get_int64
hnakamur Apr 6, 2025
2a50794
Take string_view in MIMEHdr::value_get_date
hnakamur Apr 6, 2025
404b05c
Take string_view in MIMEHdr::value_get_comma_list
hnakamur Apr 6, 2025
8fdec9b
Take string_view in MIMEHdr::value_set
hnakamur Apr 6, 2025
d5a7a8c
Take string_view in MIMEHdr::value_set_int
hnakamur Apr 6, 2025
2af32fa
Take string_view in MIMEHdr::value_set_uint
hnakamur Apr 6, 2025
d6578a2
Take string_view in MIMEHdr::value_set_int64
hnakamur Apr 6, 2025
dce53eb
Take string_view in MIMEHdr::value_set_date
hnakamur Apr 6, 2025
99a15bf
Take string_view in MIMEHdr::value_append
hnakamur Apr 6, 2025
37d16b7
Take string_view in MIMEHdr::field_value_replace
hnakamur Apr 6, 2025
d20a663
Take string_view in MIMEHdr::field_value_set
hnakamur Apr 6, 2025
a797219
Take string_view in MIMEHdr::field_value_append
hnakamur Apr 6, 2025
6318802
Take string_view in MIMEHdr::value_append_or_set
hnakamur Apr 6, 2025
e17b493
Take string_view in MIMEHdr::set_server
hnakamur Apr 6, 2025
304142c
Return std::tuple<MIMEField *, std::string_view, std::string_view> fr…
hnakamur Apr 6, 2025
038258a
Add assert to avoid false-positive nullptr-deref from clang-analyzer
hnakamur Apr 8, 2025
6677585
Add mime header name and value "constants" MIME_{FIELD,VALUE}_*_sv
hnakamur Apr 15, 2025
8a6c787
Delete const char *MIME_FIELD_* and MIME_VALUE_* and MIME_LEN constants
hnakamur Apr 15, 2025
76d3239
Add c_str_view
hnakamur Apr 16, 2025
7efea9e
Change type of MIME_FIELD_* and MIME_VALUE_* to c_str_view
hnakamur Apr 16, 2025
484acf5
Take string_view in mime_hdr_field_find
hnakamur Apr 15, 2025
400535c
Take string_view in _mime_hdr_field_list_search_by_string
hnakamur Apr 15, 2025
2957871
Take string_view in mime_field_create_named
hnakamur Apr 15, 2025
05f3d01
Take string_view in mime_hdr_prepare_for_value_set
hnakamur Apr 15, 2025
8380fa5
Take string_view in mime_field_name_set
hnakamur Apr 15, 2025
8f5218b
Take string_view in mime_field_value_set_comma_val
hnakamur Apr 15, 2025
f00a9f6
Take string_view in mime_field_value_extend_comma_val
hnakamur Apr 15, 2025
7f40eb7
Take string_view in mime_field_value_insert_comma_val
hnakamur Apr 15, 2025
4023adf
Take string_view in mime_field_value_set
hnakamur Apr 15, 2025
1e9d50e
Take string_view in mime_field_name_value_set
hnakamur Apr 15, 2025
a71ac27
Take string_view in mime_field_value_append
hnakamur Apr 16, 2025
48540c8
Take string_view in mime_mem_print{,_lc}
hnakamur Apr 16, 2025
84645e0
Take string_view in mime_str_u16_set
hnakamur Apr 16, 2025
673b9e5
Take string_view in mime_mem_print_
hnakamur Apr 16, 2025
d6c3c15
Improve implementation of c_str_view
hnakamur Apr 16, 2025
d87c1bf
Merge branch 'master' into take_string_view_in_mime_methods.tmp
hnakamur May 6, 2025
629bdf3
Add comment to c_str_view for its purpose and temporary use
hnakamur May 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions include/proxy/hdrs/HTTP.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#pragma once

#include <cassert>
#include <string_view>

using namespace std::literals;

#include "tscore/Arena.h"
#include "tscore/CryptoHash.h"
#include "tscore/HTTPVersion.h"
Expand Down Expand Up @@ -869,9 +873,9 @@ is_header_keep_alive(const HTTPVersion &http_version, const MIMEField *con_hdr)
// *unknown_tokens = false;

if (con_hdr) {
if (con_hdr->value_get_index("keep-alive", 10) >= 0)
if (con_hdr->value_get_index("keep-alive"sv) >= 0)
con_token = CON_TOKEN_KEEP_ALIVE;
else if (con_hdr->value_get_index("close", 5) >= 0)
else if (con_hdr->value_get_index("close"sv) >= 0)
con_token = CON_TOKEN_CLOSE;
}

Expand All @@ -895,11 +899,11 @@ inline HTTPKeepAlive
HTTPHdr::keep_alive_get() const
{
HTTPKeepAlive retval = HTTP_NO_KEEPALIVE;
const MIMEField *pc = this->field_find(MIME_FIELD_PROXY_CONNECTION, MIME_LEN_PROXY_CONNECTION);
const MIMEField *pc = this->field_find(static_cast<std::string_view>(MIME_FIELD_PROXY_CONNECTION));
if (pc != nullptr) {
retval = is_header_keep_alive(this->version_get(), pc);
} else {
const MIMEField *c = this->field_find(MIME_FIELD_CONNECTION, MIME_LEN_CONNECTION);
const MIMEField *c = this->field_find(static_cast<std::string_view>(MIME_FIELD_CONNECTION));
retval = is_header_keep_alive(this->version_get(), c);
}
return retval;
Expand Down
3 changes: 3 additions & 0 deletions include/proxy/hdrs/HdrToken.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "tscore/ink_assert.h"
#include "tscore/ink_atomic.h"
#include "tscore/ink_defs.h"
#include "tscore/ink_memory.h"
#include "tscore/ink_string.h"
#include "tscore/Allocator.h"
#include "tsutil/Regex.h"
Expand Down Expand Up @@ -107,6 +108,8 @@ extern int hdrtoken_tokenize(const char *string, int string_len, const c
extern int hdrtoken_method_tokenize(const char *string, int string_len);
extern const char *hdrtoken_string_to_wks(const char *string);
extern const char *hdrtoken_string_to_wks(const char *string, int length);
extern c_str_view hdrtoken_string_to_wks_sv(const char *string);
extern c_str_view hdrtoken_string_to_wks_sv(const char *string, int length);

/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
Expand Down
Loading