From 07805e249d17a59c7c056cfb886b9b3e39870d71 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 6 Apr 2023 19:48:37 +0100 Subject: If Accept header specifies no preference first, shortcut to default serializer --- icespider/core/ihttpRequest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/icespider/core/ihttpRequest.cpp b/icespider/core/ihttpRequest.cpp index 97cdcd7..c575c82 100644 --- a/icespider/core/ihttpRequest.cpp +++ b/icespider/core/ihttpRequest.cpp @@ -114,6 +114,12 @@ namespace IceSpider { if (acceptHdr) { auto accepts = parseAccept(*acceptHdr); auto & strm = getOutputStream(); + if (accepts.empty()) { + throw Http400_BadRequest(); + } + if (!accepts.front().group && !accepts.front().type) { + return handler->defaultSerializer(strm); + } for (auto & a : accepts) { ContentTypeSerializer serializer = handler->getSerializer(a, strm); if (serializer.second) { -- cgit v1.2.3