cli
cli copied to clipboard
Detect Content-Type of stdin via file util / "magic" heuristics
When setting the body of a request via piped input (stdin), it would be nice to still auto-detect the Content-Type, using pymagic or python-magic or similar.
I'd love to see this feature in HTTPie but the problem is the additional dependencies.
In addition to introducing dependency on python-magic (which seems to be the better one), there are further dependencies that python-magic needs.
Hi! Revisiting the issue after a while, some thoughts:
- Needs more thinking as we currently auto-supply json/formencode
- It is problematic with streaming as the mentioned libraries need some minimal amount of data to be able to decide
- We are conservative about adding dependencies
- Since it uses libmagic, cross platform installation would get more complicated
- It is a thin wrapper, most of the heavy work is done by the underlying C library which is complicated to compile/distribute
The feature is something we'd love to have, but it needs a reliable cross-platform solution, ideally in Python. Also needs further thinking into how it would affect the rest of the HTTPie.