bastion-dev / Bastion

Java test library for HTTP APIs
http://bastion.rocks
GNU General Public License v3.0
13 stars 8 forks source link

Using Apache Tika to detect resource MIME type #89

Closed FrelliBB closed 7 years ago

FrelliBB commented 7 years ago

Related issues: https://github.com/bastion-dev/Bastion/issues/63 https://github.com/bastion-dev/Bastion/issues/77

Files.probeContentType() was inconsistent across different Operating systems. Apache Tika seems to be more consistent and does not have the issue of failing for classpath: resources on Windows.

I also changed the default return type for unknown file types to application/octet-stream. This seems to be what Apache Tika recommends as a default MIME type and it seems fair. If you want plain/text, send a .txt file, otherwise interpret it as a binary stream.