2017-01-27 16:37:51 +01:00
|
|
|
unit uCEFResponse;
|
|
|
|
|
2018-05-12 14:50:54 +02:00
|
|
|
{$IFDEF FPC}
|
|
|
|
{$MODE OBJFPC}{$H+}
|
|
|
|
{$ENDIF}
|
|
|
|
|
2017-02-05 20:56:46 +01:00
|
|
|
{$I cef.inc}
|
|
|
|
|
2022-02-19 18:56:41 +01:00
|
|
|
{$IFNDEF TARGET_64BITS}{$ALIGN ON}{$ENDIF}
|
|
|
|
{$MINENUMSIZE 4}
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2017-03-16 19:09:42 +01:00
|
|
|
uCEFBaseRefCounted, uCEFInterfaces, uCEFTypes;
|
2017-01-27 16:37:51 +01:00
|
|
|
|
|
|
|
type
|
2017-03-16 19:09:42 +01:00
|
|
|
TCefResponseRef = class(TCefBaseRefCountedRef, ICefResponse)
|
2018-04-20 12:45:06 +02:00
|
|
|
protected
|
|
|
|
function IsReadOnly: Boolean;
|
|
|
|
function GetError: TCefErrorCode;
|
|
|
|
procedure SetError(error: TCefErrorCode);
|
|
|
|
function GetStatus: Integer;
|
|
|
|
procedure SetStatus(status: Integer);
|
|
|
|
function GetStatusText: ustring;
|
|
|
|
procedure SetStatusText(const StatusText: ustring);
|
|
|
|
function GetMimeType: ustring;
|
|
|
|
procedure SetMimeType(const mimetype: ustring);
|
2019-06-16 10:31:13 +02:00
|
|
|
function GetCharset: ustring;
|
|
|
|
procedure SetCharset(const charset: ustring);
|
2019-10-30 10:26:48 +01:00
|
|
|
function GetHeaderByName(const name: ustring): ustring;
|
|
|
|
procedure SetHeaderByName(const name, value: ustring; overwrite: boolean);
|
2018-04-20 12:45:06 +02:00
|
|
|
procedure GetHeaderMap(const headerMap: ICefStringMultimap);
|
|
|
|
procedure SetHeaderMap(const headerMap: ICefStringMultimap);
|
|
|
|
function GetURL: ustring;
|
|
|
|
procedure SetURL(const url: ustring);
|
|
|
|
|
|
|
|
public
|
|
|
|
class function UnWrap(data: Pointer): ICefResponse;
|
|
|
|
class function New: ICefResponse;
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
uCEFMiscFunctions, uCEFLibFunctions;
|
|
|
|
|
|
|
|
|
|
|
|
class function TCefResponseRef.New: ICefResponse;
|
|
|
|
begin
|
2018-05-12 14:50:54 +02:00
|
|
|
Result := UnWrap(cef_response_create());
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefResponseRef.GetError: TCefErrorCode;
|
|
|
|
begin
|
|
|
|
Result := PCefResponse(FData)^.get_error(FData);
|
|
|
|
end;
|
|
|
|
|
2019-10-30 10:26:48 +01:00
|
|
|
function TCefResponseRef.GetHeaderByName(const name: ustring): ustring;
|
2017-01-27 16:37:51 +01:00
|
|
|
var
|
2018-04-20 12:45:06 +02:00
|
|
|
TempName : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-04-20 12:45:06 +02:00
|
|
|
TempName := CefString(name);
|
2019-10-30 10:26:48 +01:00
|
|
|
Result := CefStringFreeAndGet(PCefResponse(FData)^.get_header_by_name(PCefResponse(FData), @TempName));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefResponseRef.SetHeaderByName(const name, value: ustring; overwrite: boolean);
|
|
|
|
var
|
|
|
|
TempName, TempValue : TCefString;
|
|
|
|
begin
|
|
|
|
TempName := CefString(name);
|
|
|
|
TempValue := CefString(value);
|
|
|
|
PCefResponse(FData)^.set_header_by_name(PCefResponse(FData), @TempName, @TempValue, ord(overwrite));
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefResponseRef.GetHeaderMap(const headerMap: ICefStringMultimap);
|
|
|
|
begin
|
|
|
|
PCefResponse(FData)^.get_header_map(PCefResponse(FData), headermap.Handle);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefResponseRef.GetMimeType: ustring;
|
|
|
|
begin
|
|
|
|
Result := CefStringFreeAndGet(PCefResponse(FData)^.get_mime_type(PCefResponse(FData)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefResponseRef.GetStatus: Integer;
|
|
|
|
begin
|
|
|
|
Result := PCefResponse(FData)^.get_status(PCefResponse(FData));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefResponseRef.GetStatusText: ustring;
|
|
|
|
begin
|
|
|
|
Result := CefStringFreeAndGet(PCefResponse(FData)^.get_status_text(PCefResponse(FData)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefResponseRef.IsReadOnly: Boolean;
|
|
|
|
begin
|
|
|
|
Result := PCefResponse(FData)^.is_read_only(PCefResponse(FData)) <> 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefResponseRef.SetError(error: TCefErrorCode);
|
|
|
|
begin
|
|
|
|
PCefResponse(FData)^.set_error(FData, error);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefResponseRef.SetHeaderMap(const headerMap: ICefStringMultimap);
|
|
|
|
begin
|
|
|
|
PCefResponse(FData)^.set_header_map(PCefResponse(FData), headerMap.Handle);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefResponseRef.SetMimeType(const mimetype: ustring);
|
|
|
|
var
|
2018-04-20 12:45:06 +02:00
|
|
|
TempType : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-04-20 12:45:06 +02:00
|
|
|
TempType := CefString(mimetype);
|
|
|
|
PCefResponse(FData)^.set_mime_type(PCefResponse(FData), @TempType);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
2019-06-16 10:31:13 +02:00
|
|
|
function TCefResponseRef.GetCharset: ustring;
|
|
|
|
begin
|
|
|
|
Result := CefStringFreeAndGet(PCefResponse(FData)^.get_charset(PCefResponse(FData)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefResponseRef.SetCharset(const charset: ustring);
|
|
|
|
var
|
|
|
|
TempCharset : TCefString;
|
|
|
|
begin
|
|
|
|
TempCharset := CefString(charset);
|
|
|
|
PCefResponse(FData)^.set_charset(PCefResponse(FData), @TempCharset);
|
|
|
|
end;
|
|
|
|
|
2017-01-27 16:37:51 +01:00
|
|
|
procedure TCefResponseRef.SetStatus(status: Integer);
|
|
|
|
begin
|
|
|
|
PCefResponse(FData)^.set_status(PCefResponse(FData), status);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefResponseRef.SetStatusText(const StatusText: ustring);
|
|
|
|
var
|
2018-04-20 12:45:06 +02:00
|
|
|
TempStatus : TCefString;
|
2017-01-27 16:37:51 +01:00
|
|
|
begin
|
2018-04-20 12:45:06 +02:00
|
|
|
TempStatus := CefString(StatusText);
|
|
|
|
PCefResponse(FData)^.set_status_text(PCefResponse(FData), @TempStatus);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TCefResponseRef.GetURL : ustring;
|
|
|
|
begin
|
|
|
|
Result := CefStringFreeAndGet(PCefResponse(FData)^.get_url(PCefResponse(FData)));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TCefResponseRef.SetURL(const url : ustring);
|
|
|
|
var
|
|
|
|
TempURL : TCefString;
|
|
|
|
begin
|
|
|
|
TempURL := CefString(url);
|
|
|
|
PCefResponse(FData)^.set_url(PCefResponse(FData), @TempURL);
|
2017-01-27 16:37:51 +01:00
|
|
|
end;
|
|
|
|
|
|
|
|
class function TCefResponseRef.UnWrap(data: Pointer): ICefResponse;
|
|
|
|
begin
|
2018-04-20 12:45:06 +02:00
|
|
|
if (data <> nil) then
|
|
|
|
Result := Create(data) as ICefResponse
|
|
|
|
else
|
2017-01-27 16:37:51 +01:00
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
end.
|