Closed costas80 closed 4 months ago
Hi, what about this https://github.com/filip26/titanium-json-ld/issues/132#issuecomment-826282856 ? Does it work for you?
Yes it does! Don't know how I missed that... Many thanks @filip26!
@costas80 if you have an idea on how to make the code more modular, configurable, then please don't hesitate to open PR. I would only recommend to contact me before making huge changes.
No, I think that your solution covers this perfectly. I was trying to work directly with the DefaultHttpLoader
when in fact using the HttpLoader
was the way to go. In hindsight we can keep things as-is.
Is your feature request related to a problem? Please describe.
I have an issue loading a JSON-LD remote context over HTTP which is (incorrectly) being returned with a Content Type of
text/plain
. Checking the implementation ofDefaultHttpLoader
I see that the resulting error could easily be avoided if thefallbackContentType
was set toMediaType.JSON
, exactly as theFileLoader
already does.Describe the solution you'd like
It seems that this could be very easily resolved if the
fallbackContentType
forDefaultHttpLoader
were set toMediaType.JSON
. Alternatively this could be done when setting up your ownDocumentLoader
s whereby we could replace the defaultDefaultHttpLoader
with a new instance on which thefallbackContentType
is set. Frustratingly however, classDefaultHttpLoader
is not public meaning that I cannot reuse it to create such an instance.I would suggest two minor updates to resolve this:
DefaultHttpLoader
to setfallbackContentType
toMediaType.JSON
.DefaultHttpLoader
to make it public.Describe alternatives you've considered
The alternative to what I propose would be a complete rewrite (copy basically) of the
DefaultHttpLoader
which seems complete overkill to simply add one method call.Additional context
If you confirm that doing these changes don't break anything I am unaware of, and don't go against any design principles I'd be happy to submit a PR making these changes.