Skip to content

Commit 08b8e03

Browse files
authored
Merge pull request ceph#50510 from cbodley/wip-rgw-server-name
rgw: add default Server response header Reviewed-by: Adam C. Emerson <[email protected]>
2 parents bd0eee3 + 7a1e4e6 commit 08b8e03

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

src/rgw/rgw_asio_client.cc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ using namespace rgw::asio;
1414

1515
ClientIO::ClientIO(parser_type& parser, bool is_ssl,
1616
const endpoint_type& local_endpoint,
17-
const endpoint_type& remote_endpoint,
18-
std::string_view extra_response_headers)
17+
const endpoint_type& remote_endpoint)
1918
: parser(parser), is_ssl(is_ssl),
2019
local_endpoint(local_endpoint),
2120
remote_endpoint(remote_endpoint),
22-
extra_response_headers(extra_response_headers),
2321
txbuf(*this)
2422
{
2523
}
@@ -151,11 +149,6 @@ size_t ClientIO::complete_header()
151149
sent += txbuf.sputn(timestr, strlen(timestr));
152150
}
153151

154-
if (extra_response_headers.size()) {
155-
sent += txbuf.sputn(extra_response_headers.data(),
156-
extra_response_headers.size());
157-
}
158-
159152
if (parser.keep_alive()) {
160153
constexpr char CONN_KEEP_ALIVE[] = "Connection: Keep-Alive\r\n";
161154
sent += txbuf.sputn(CONN_KEEP_ALIVE, sizeof(CONN_KEEP_ALIVE) - 1);

src/rgw/rgw_asio_client.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class ClientIO : public io::RestfulClient,
2525
using endpoint_type = boost::asio::ip::tcp::endpoint;
2626
endpoint_type local_endpoint;
2727
endpoint_type remote_endpoint;
28-
std::string_view extra_response_headers;
2928

3029
RGWEnv env;
3130

@@ -35,8 +34,7 @@ class ClientIO : public io::RestfulClient,
3534
public:
3635
ClientIO(parser_type& parser, bool is_ssl,
3736
const endpoint_type& local_endpoint,
38-
const endpoint_type& remote_endpoint,
39-
std::string_view extra_response_headers);
37+
const endpoint_type& remote_endpoint);
4038
~ClientIO() override;
4139

4240
int init_env(CephContext *cct) override;

src/rgw/rgw_asio_frontend.cc

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "common/async/shared_mutex.h"
1717
#include "common/errno.h"
1818
#include "common/strtol.h"
19-
#include "ceph_ver.h"
2019

2120
#include "rgw_asio_client.h"
2221
#include "rgw_asio_frontend.h"
@@ -79,10 +78,8 @@ class StreamIO : public rgw::asio::ClientIO {
7978
rgw::asio::parser_type& parser, yield_context yield,
8079
parse_buffer& buffer, bool is_ssl,
8180
const tcp::endpoint& local_endpoint,
82-
const tcp::endpoint& remote_endpoint,
83-
std::string_view extra_response_headers)
84-
: ClientIO(parser, is_ssl, local_endpoint, remote_endpoint,
85-
extra_response_headers),
81+
const tcp::endpoint& remote_endpoint)
82+
: ClientIO(parser, is_ssl, local_endpoint, remote_endpoint),
8683
cct(cct), stream(stream), timeout(timeout), yield(yield),
8784
buffer(buffer)
8885
{}
@@ -196,7 +193,6 @@ void handle_connection(boost::asio::io_context& context,
196193
SharedMutex& pause_mutex,
197194
rgw::dmclock::Scheduler *scheduler,
198195
const std::string& uri_prefix,
199-
std::string_view extra_response_headers,
200196
boost::system::error_code& ec,
201197
yield_context yield)
202198
{
@@ -269,8 +265,7 @@ void handle_connection(boost::asio::io_context& context,
269265
}
270266

271267
StreamIO real_client{cct, stream, timeout, parser, yield, buffer,
272-
is_ssl, local_endpoint, remote_endpoint,
273-
extra_response_headers};
268+
is_ssl, local_endpoint, remote_endpoint};
274269

275270
auto real_client_io = rgw::io::add_reordering(
276271
rgw::io::add_buffering(cct,
@@ -442,8 +437,6 @@ class AsioFrontend {
442437
std::unique_ptr<dmc::ClientConfig> client_config;
443438
void accept(Listener& listener, boost::system::error_code ec);
444439

445-
std::string extra_response_headers;
446-
447440
public:
448441
AsioFrontend(RGWProcessEnv& env, RGWFrontendConfig* conf,
449442
dmc::SchedulerCtx& sched_ctx)
@@ -565,9 +558,6 @@ int AsioFrontend::init()
565558
boost::system::error_code ec;
566559
auto& config = conf->get_config_map();
567560

568-
// format the Server response header
569-
extra_response_headers = "Server: Ceph Object Gateway (" CEPH_RELEASE_NAME ")\r\n";
570-
571561
if (auto i = config.find("prefix"); i != config.end()) {
572562
uri_prefix = i->second;
573563
}
@@ -1045,7 +1035,7 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec)
10451035
conn->buffer.consume(bytes);
10461036
handle_connection(context, env, stream, timeout, header_limit,
10471037
conn->buffer, true, pause_mutex, scheduler.get(),
1048-
uri_prefix, extra_response_headers, ec, yield);
1038+
uri_prefix, ec, yield);
10491039
if (!ec) {
10501040
// ssl shutdown (ignoring errors)
10511041
stream.async_shutdown(yield[ec]);
@@ -1064,7 +1054,7 @@ void AsioFrontend::accept(Listener& l, boost::system::error_code ec)
10641054
boost::system::error_code ec;
10651055
handle_connection(context, env, conn->socket, timeout, header_limit,
10661056
conn->buffer, false, pause_mutex, scheduler.get(),
1067-
uri_prefix, extra_response_headers, ec, yield);
1057+
uri_prefix, ec, yield);
10681058
conn->socket.shutdown(tcp_socket::shutdown_both, ec);
10691059
}, make_stack_allocator());
10701060
}

src/rgw/rgw_rest.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <boost/algorithm/string.hpp>
99
#include <boost/tokenizer.hpp>
10+
#include "ceph_ver.h"
1011
#include "common/Formatter.h"
1112
#include "common/HTMLFormatter.h"
1213
#include "common/utf8.h"
@@ -615,7 +616,13 @@ void end_header(req_state* s, RGWOp* op, const char *content_type,
615616
if (content_type) {
616617
dump_header(s, "Content-Type", content_type);
617618
}
618-
dump_header_if_nonempty(s, "Server", g_conf()->rgw_service_provider_name);
619+
620+
std::string srv = g_conf().get_val<std::string>("rgw_service_provider_name");
621+
if (!srv.empty()) {
622+
dump_header(s, "Server", srv);
623+
} else {
624+
dump_header(s, "Server", "Ceph Object Gateway (" CEPH_RELEASE_NAME ")");
625+
}
619626

620627
try {
621628
RESTFUL_IO(s)->complete_header();

0 commit comments

Comments
 (0)