Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciussanchez committed Jan 9, 2024
1 parent d668457 commit 2e83e9c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 2 additions & 0 deletions samples/delphi/samples.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -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<TBytesStream>.SaveToFile(ExtractFilePath(ParamStr(0)) + 'horse-post.' + LType);
Expand Down
4 changes: 1 addition & 3 deletions src/Horse.OctetStream.pas
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2e83e9c

Please sign in to comment.