From 2e83e9c7149535754ce2e18f279f199475ec29b2 Mon Sep 17 00:00:00 2001 From: Vinicius Sanchez Date: Tue, 9 Jan 2024 08:33:06 -0300 Subject: [PATCH] Bug fix --- samples/delphi/samples.dpr | 2 ++ src/Horse.OctetStream.pas | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/delphi/samples.dpr b/samples/delphi/samples.dpr index 4ec46de..cd86014 100644 --- a/samples/delphi/samples.dpr +++ b/samples/delphi/samples.dpr @@ -38,6 +38,8 @@ begin var LType: string; begin + if not MatchText(Req.RawWebRequest.ContentType, THorseOctetStreamConfig.GetInstance.AcceptContentType.ToArray) then + raise EHorseException.New.Error('Unknown Content-Type: ' + Req.RawWebRequest.ContentType).Status(THTTPStatus.BadRequest); // here you could get the Req.ContentType and save the file based on that LType := Copy(Req.RawWebRequest.ContentType, Pos('/', Req.RawWebRequest.ContentType) + 1, Req.RawWebRequest.ContentType.Length); Req.Body.SaveToFile(ExtractFilePath(ParamStr(0)) + 'horse-post.' + LType); diff --git a/src/Horse.OctetStream.pas b/src/Horse.OctetStream.pas index 1711190..d98c113 100644 --- a/src/Horse.OctetStream.pas +++ b/src/Horse.OctetStream.pas @@ -102,9 +102,7 @@ procedure OctetStream(Req: THorseRequest; Res: THorseResponse; Next: {$IF DEFINE LContentTMemoryStream := TMemoryStream(LContent); GetAllDataAsStream(Req, LContentTMemoryStream); Req.Body(LContent); - end - else - raise EHorseException.New.Error('Unknown Content-Type: ' + Req.RawWebRequest.ContentType).Status(THTTPStatus.BadRequest); + end; end; Next;