Comments (5)
Providing a way to pass custom content type sniffer sounds sensible, but will be a very niche feature request if your default is something comprehenbsive like file-type
with magic bytes sniffing.
I think the question we could ask is when is content-type relevant:
- If we use
verified-fetch
in JS the same way asfetch
, thecontent-type
header won't matter.
End user will use.json()
,.text()
,.blob()
etc themselves. - If we use
verified-fetch
in service worker for web gateway implementation, then we pass response to browser renderer directly, and returned content-type matters. In this case hard-coding a few content types won't be enough anyway, and the user wants something more future-proof, likefile-type
.
That is to say, I think it is sensible to either:
- go with
file-type
everywhere (avoid maintaining "minimal list of types we support", ~5% bundle size increase does not sound like a lot when compared to UX/DX of content-type being taken care of) - OR skip setting content-type by default entierely, and only use it gateway contexts, in which you use
contentTypeParser
to passfile-type
that does the comprehensive magic bytes sniffing.
from helia.
My feeling is that if we don't need to do content type sniffing then let's not do it.
If we need to do it, we should do the minimum required (e.g. just support detecting a small subset of content types) and provide an extension mechanism for more comprehensive detection.
Given that we're billing this as fetch
-like, most people will just do .json()
, .blob()
, etc and get on with things which suggests that we don't need to detect content types - we just try to process the data as the requested type and fail loudly if we can't.
There are valid use-cases for content detection though (e.g. service worker gateway) so allowing users to configure a mime type sniffer if they need it seems like a good compromise.
from helia.
FYI that file-type
is fairly small compared to the entirety of @helia/verified-fetch
(currently totals 560.2kb) at only 26.7kb:
from helia.
Mostly agree with @lidel and @achingbrain, though I don't have a strong inclination either way.
If we don't include magic-byte sniffing by default, it should be as easy as possible to configure so it works smoothly in service workers.
from helia.
Sounds good. Ill get a PR out today that will not do content-type unless passed a function for it
from helia.
Related Issues (20)
- Parcel cannot resolve Helia and any @helia/x packages HOT 2
- How to pin to a remote kubo node?
- Possible memory leak?
- feat: `ipfs refs` command not supported?
- bug: endless session routing HOT 10
- fix: unnecessary new URL instance HOT 3
- Helia UnixFs `addFile` does not respect `wrapWithDirectory` HOT 3
- Share your feedback in the Helia feedback survey
- High Memory Usage with Persistent IPFS Node in Browser via Helia HOT 1
- Using Helia in Service Workers and Compatibility with Kubo
- Issue with Peer-discovery When Initializing with Custom Service (pure browser environment)
- Provide convenience wrappers for adding/reading IPLD blocks of raw bytes
- bug: @helia/http not passing gateways from config to httpGatewayRouting HOT 1
- How to use PubSub on TypeScript ?
- Ips
- Helia with Angular
- Attempted import error: 'RTCSessionDescription' is not exported HOT 3
- Issues with Yamux / race-signal
- CAR Exports by Default Export Multiple Blocks
- Provide a way to use delegatedHTTPRouting only for IPNS resolution
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from helia.