Debian Codegraph @

src/files/castledownload_mime.inc

raw
1 {%MainUnit castledownload.pas}
2 {
3 Copyright 2021-2021 Michalis Kamburelis.
4
5 This file is part of "Castle Game Engine".
6
7 "Castle Game Engine" is free software; see the file COPYING.txt,
8 included in this distribution, for details about the copyright.
9
10 "Castle Game Engine" is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 ----------------------------------------------------------------------------
15 }
16
17 {$ifdef read_interface}
18
19 { @exclude
20 CastleUriUtils.UriMimeType actually calls this, for now.
21 Maybe it should be in higher unit, used by both CastleDownload and CastleUriUtils,
22 like CastleUrls. }
23 function InternalUriMimeType(const URI: string; out Gzipped: boolean): string; overload;
24
25 {$endif}
26
27 {$ifdef read_implementation}
28
29 function InternalUriMimeType(const URI: string; out Gzipped: boolean): string;
30 var
31 P: string;
32 RegisteredProtocol: TRegisteredProtocol;
33 begin
34 Result := '';
35 Gzipped := false;
36
37 P := URIProtocol(URI);
38 RegisteredProtocol := RegisteredProtocols.Find(P);
39 if (RegisteredProtocol <> nil) and
40 (Assigned(RegisteredProtocol.MimeTypeEvent)) then
41 begin
42 Result := RegisteredProtocol.MimeTypeEvent(URI, Gzipped);
43 end else
44 begin
45 WritelnWarning('Querying MIME type for URL protocol "%s" not supported', [P]);
46 end;
47 end;
48
49 {$endif}