Skip to content

Commit 51c4bb7

Browse files
namedgraphclaude
andcommitted
ProxyRequestFilter: document HTML bypass rationale; cache MediaTypes instance
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9b45c97 commit 51c4bb7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/com/atomgraph/linkeddatahub/server/filter/request/ProxyRequestFilter.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@
8282
* </ol>
8383
* ACL is not checked for proxy requests: the proxy is a global transport function, not a document
8484
* operation. Access control is enforced by the target endpoint.
85+
* <p>
86+
* This filter intentionally does <em>not</em> proxy (X)HTML responses. When the client accepts only
87+
* (X)HTML (e.g. a browser navigating directly), it would receive the same LDH application shell it
88+
* already has — an unnecessary round-trip with no benefit. Instead those requests fall through to the
89+
* downstream handler, which serves the shell; the client-side Saxon-JS layer then fetches RDF via a
90+
* second request that <em>does</em> hit this filter. The bypass is implemented by building the
91+
* candidate variant list from Core's {@link MediaTypes} (RDF/SPARQL types only, no HTML) and treating
92+
* a {@code null} result from {@link Request#selectVariant} as the bypass signal.
8593
*
8694
* @author Martynas Jusevičius {@literal <martynas@atomgraph.com>}
8795
*/
@@ -91,6 +99,7 @@ public class ProxyRequestFilter implements ContainerRequestFilter
9199
{
92100

93101
private static final Logger log = LoggerFactory.getLogger(ProxyRequestFilter.class);
102+
private static final MediaTypes MEDIA_TYPES = new MediaTypes();
94103

95104
@Inject com.atomgraph.linkeddatahub.Application system;
96105
@Inject jakarta.inject.Provider<Optional<Ontology>> ontology;
@@ -358,7 +367,7 @@ public Optional<Ontology> getOntology()
358367
*/
359368
public MediaTypes getMediaTypes()
360369
{
361-
return new MediaTypes();
370+
return MEDIA_TYPES;
362371
}
363372

364373
/**

0 commit comments

Comments
 (0)