diff options
| author | levlam <levlam@telegram.org> | 2026-01-12 01:03:41 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2026-01-12 01:03:41 +0300 |
| commit | 7c01a8a4ebcd73205f99a00e5d8af978ea26a9aa (patch) | |
| tree | 54551f23eb6c336c9d8f0e8a33dc5cc0935f4a78 | |
| parent | a5903d841b679c4069fdf207b430f313de302559 (diff) | |
Add HttpHeaderCreator::get_host_header.
| -rw-r--r-- | tdnet/td/net/HttpHeaderCreator.cpp | 7 | ||||
| -rw-r--r-- | tdnet/td/net/HttpHeaderCreator.h | 3 |
2 files changed, 6 insertions, 4 deletions
diff --git a/tdnet/td/net/HttpHeaderCreator.cpp b/tdnet/td/net/HttpHeaderCreator.cpp index ddeea558d..dd70bcb49 100644 --- a/tdnet/td/net/HttpHeaderCreator.cpp +++ b/tdnet/td/net/HttpHeaderCreator.cpp @@ -10,10 +10,9 @@ namespace td { -string HttpHeaderCreator::get_host_header(HttpUrl::Protocol protocol, Slice host, int32 port); - if ((protocol == HttpUrl::Protocol::Https && port == 443) || - (protocol == HttpUrl::Protocol::Http && port == 80)) { - return host; +string HttpHeaderCreator::get_host_header(HttpUrl::Protocol protocol, Slice host, int32 port) { + if ((protocol == HttpUrl::Protocol::Https && port == 443) || (protocol == HttpUrl::Protocol::Http && port == 80)) { + return host.str(); } else { return PSTRING() << host << ':' << port; } diff --git a/tdnet/td/net/HttpHeaderCreator.h b/tdnet/td/net/HttpHeaderCreator.h index ca92b5af3..021f72c17 100644 --- a/tdnet/td/net/HttpHeaderCreator.h +++ b/tdnet/td/net/HttpHeaderCreator.h @@ -6,6 +6,7 @@ // #pragma once +#include "td/utils/HttpUrl.h" #include "td/utils/Slice.h" #include "td/utils/SliceBuilder.h" #include "td/utils/Status.h" @@ -64,6 +65,8 @@ class HttpHeaderCreator { add_header("Connection", "keep-alive"); } + static string get_host_header(HttpUrl::Protocol protocol, Slice host, int32 port); + Result<Slice> finish(Slice content = {}) TD_WARN_UNUSED_RESULT; private: |
