Bugfix: detect file type and send appropriate Content-Type.

This commit is contained in:
tastytea 2018-11-29 13:40:50 +01:00
parent b3593a95f0
commit ec140aad01
Signed by untrusted user: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 6 additions and 2 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.2)
project(libravatarserv
VERSION 0.6.2
VERSION 0.6.3
LANGUAGES CXX
)

View File

@ -17,6 +17,7 @@
#include <iostream>
#include <sstream>
#include <array>
#include <algorithm>
#include "libravatarserv.hpp"
using std::cout;
@ -67,7 +68,10 @@ const Image image::get(const string &digest, const uint16_t size)
void image::write(Image &image)
{
cout << "Content-type: image/png\n\n";
string magick = image.image.magick();
std::transform(magick.begin(), magick.end(), magick.begin(), ::tolower);
cout << "Content-Type: image/" << magick << "\n\n";
cout.flush(); // We need to flush before we use /dev/stdout directly.
image.image.write("/dev/stdout");
}