From 33405111d53ac0288adbd2881f3e5a7c1cacc999 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 18 Nov 2021 00:19:49 +0100 Subject: send_file: Make sure send file header value contains the right amount of slashes --- example/travels.conf | 4 ++-- src/send_file.cc | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/example/travels.conf b/example/travels.conf index 3972bc0..89bba59 100644 --- a/example/travels.conf +++ b/example/travels.conf @@ -11,5 +11,5 @@ geojson.database = timezones.geojson.json # nginx site.sendfile.header = X-Accel-Redirect -site.sendfile.path = /media/ -site.sendfile.static_path = /static/ +site.sendfile.path = /media +site.sendfile.static_path = /static diff --git a/src/send_file.cc b/src/send_file.cc index 8611b6f..e5bf92b 100644 --- a/src/send_file.cc +++ b/src/send_file.cc @@ -29,7 +29,11 @@ public: } auto resp = transport->create_ok_data(""); - resp->add_header(header_, path_ + std::string(relative_path)); + std::string value = path_; + if (relative_path.empty() || relative_path.front() != '/') + value.push_back('/'); + value.append(relative_path); + resp->add_header(header_, std::move(value)); return resp; } -- cgit v1.2.3-70-g09d2