NanoHttpd / nanohttpd

Tiny, easily embeddable HTTP server in Java.
http://nanohttpd.org
BSD 3-Clause "New" or "Revised" License
6.92k stars 1.69k forks source link

Best practice for sending images and encoded files? #541

Open SirMangler opened 5 years ago

SirMangler commented 5 years ago

Loading the encoded file as a String and then sending it with newFixedLengthResponse doesn't work (SEVERE: Could not send response to the client), which I assume is because it is designed to send UTF-8 encoding, rather than ISO or any other encoding one might encounter.

My intention is to be able to access any resource that exists on the server. I can already send all regular encoded files (e.g html/css/js).

Thanks!

LordFokas commented 5 years ago

Read all data into a byte[], respond with that array and the correct Content-Type header. Done.