Skip to content

Allow adding additional headers for Map/File resources - #862

Merged
TBlueF merged 3 commits into
BlueMap-Minecraft:masterfrom
iCiaran:allow-additional-headers
Sep 13, 2026
Merged

Allow adding additional headers for Map/File resources#862
TBlueF merged 3 commits into
BlueMap-Minecraft:masterfrom
iCiaran:allow-additional-headers

Conversation

@iCiaran

@iCiaran iCiaran commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Allow adding additional headers by config as mentioned in #833 (comment)

Some headers (ETag, Content-Type etc) which are calculated dynamically would break if overridden and cannot be modified.

Comment thread common/src/main/resources/de/bluecolored/bluemap/config/webserver.conf Outdated
Comment on lines -221 to 252
webRequestHandler.register(".*", new FileRequestHandler(webroot));
webRequestHandler.register(".*", new FileRequestHandler(webroot, webserverConfig.getAdditionalHeaders()));

// map route
for (var mapConfigEntry : configManager.getMapConfigs().entrySet()) {
String id = mapConfigEntry.getKey();
MapConfig mapConfig = mapConfigEntry.getValue();

MapRequestHandler mapRequestHandler;
BmMap map = maps.get(id);
if (map != null) {
LivePlayersDataSupplier livePlayersDataSupplier = pluginConfig.isLivePlayerMarkers() ?
new LivePlayersDataSupplier(serverInterface, map.getWorld(), livePlayerInfoTransformer, pluginConfig.isHideDifferentWorld()) :
null;
LiveMarkersDataSupplier liveMarkersDataSupplier = new LiveMarkersDataSupplier(map.getMarkerSets());

mapRequestHandler = new MapRequestHandler(map, livePlayersDataSupplier, liveMarkersDataSupplier, webserverConfig.isSseEnabled());
mapRequestHandler = new MapRequestHandler(
map,
livePlayersDataSupplier,
liveMarkersDataSupplier,
webserverConfig.isSseEnabled(),
webserverConfig.getAdditionalHeaders()
);
} else {
Storage storage = blueMap.getOrLoadStorage(mapConfig.getStorage());
mapRequestHandler = new MapRequestHandler(storage.map(id));
mapRequestHandler = new MapRequestHandler(storage.map(id), webserverConfig.getAdditionalHeaders());
}

webRequestHandler.register(
"maps/" + Pattern.quote(id) + "/(.*)",
"$1",
new BlueMapResponseModifier(mapRequestHandler)
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of adding the headers separately to each request-handler, maybe we can move the BlueMapResponseModifier from here up to the root (similar to how it's done here: c0999f7) and then we have to only pass it only to that one class which then takes care of adding them universally..

I would also be in favour of just removing both

response.addHeader("Cache-Control", "public");
response.addHeader("Cache-Control", "max-age=" + TimeUnit.DAYS.toSeconds(1));

completely in favour of adding them to the default config.

Or am i missing any issues that come with that?

Comment thread common/src/main/java/de/bluecolored/bluemap/common/web/MapRequestHandler.java Outdated
Comment thread implementations/cli/src/main/java/de/bluecolored/bluemap/cli/BlueMapCLI.java Outdated
Comment thread implementations/cli/src/main/java/de/bluecolored/bluemap/cli/BlueMapCLI.java Outdated

@TBlueF TBlueF left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@TBlueF
TBlueF merged commit 6162794 into BlueMap-Minecraft:master Sep 13, 2026
3 checks passed
@TBlueF TBlueF mentioned this pull request Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants