TROHttpApiResult

Overview

This class allows to send back method result AS IS, without wrapping it into a JSON object.

usage:

  [ROHttpAPIMethod('test')]
  function TestMethod(): Binary;
...
function TMyService.TestMethod(): Binary;
begin
  Result := TROHttpApiResult.Create(HTTP_200_code, id_ContentType_image_jpeg,'test.jpg',false);
  Result.LoadFromFile(..image file location here..);
end;

Check more at Raw Method Result

Location

 

constructor Create  overload    (declared in TROBinaryMemoryStream)

Creates a new instance.

constructor Create

constructor Create (Integer, string, string, Boolean)

constructor Create(aHttpStatusCode: Integer; aContentType: string; aContentFileName: string = ''; aContentIsInline: Boolean = True)

Parameters:

  • aHttpStatusCode:
  • aContentType:
  • aContentFileName:
  • aContentIsInline:

constructor Create (AnsiString)  overload    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

constructor Create(const Value: AnsiString)

Parameters:

  • Value: given string

constructor Create (ROAnsiString)  overload    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

constructor Create(const Value: ROAnsiString)

Parameters:

  • Value: given string

Assign  override

Copies the contents of another, similar object.

procedure Assign(Source: TStream)

Parameters:

  • Source: Source object

CapacityIncrement    (declared in TROBinaryMemoryStream)

The amount by which the capacity of the stream is automatically incremented when its size becomes greater than its capacity.

property CapacityIncrement: Integer read write

Clone    (declared in TROBinaryMemoryStream)

Creates and returns a new memory stream that is an identical copy of the current stream. The new stream will receive its own copy of the data, and any changes to data or stream position will not affect the original version.

function Clone: TROBinaryMemoryStream

ContentFileName

This optional property allows to set default file name that will be used by the user's browser to save the downloaded data.

property ContentFileName: string read write

ContentIsInline

Allows to set the Content-Disposition header value.
The ContentIsInline property controls whether the header value will contain inline or attachment prefix

property ContentIsInline: Boolean read write

ContentType

Allows to set a custom value of the response's Content-Type header. By default Http API responses have Content-Type header value set to application/json. This feature allows to set it to a custom value.

property ContentType: string read write

GenerateContentDisposition

Generates Content-Disposition header value. Depends on ContentIsInline value

function GenerateContentDisposition: string

HttpStatusCode

Allows to set any possible HTTP response code

property HttpStatusCode: Integer read write

LoadFromHexString    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

procedure LoadFromHexString(const Value: ROAnsiString)

Parameters:

  • Value: given string

LoadFromString (AnsiString)  overload    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

procedure LoadFromString(const Value: AnsiString)

Parameters:

  • Value: given string

LoadFromString (ROAnsiString)  overload    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

procedure LoadFromString(const Value: ROAnsiString)

Parameters:

  • Value: given string

LoadFromUTF8String    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

procedure LoadFromUTF8String(const Value: UnicodeString)

Parameters:

  • Value: given string

ToHexString    (declared in TROBinaryMemoryStream)

Emits the data in the stream as a string containing hexadecimal characters. For each byte in the original stream, two characters between '0' and 'F' will be emitted to the string.

function ToHexString: ROAnsiString

ToReadableString    (declared in TROBinaryMemoryStream)

Emits the data in the stream as an ansi string for display purposes. For each byte in the original stream, the corresponding ASCII character will be emitted to the string if the value is $0D or between $20 and $7F, and a "period" character will be emitted otherwise. This results in a string that can cleanly be displayed and does not contain ASCII control characters.

function ToReadableString: ROAnsiString

ToString    (declared in TROBinaryMemoryStream)

Emits the data in the stream as an ansi string. For each byte in the original stream, the corresponding ANSI character will be emitted to the string.

function ToString: ROAnsiString

WriteAnsiString    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

function WriteAnsiString(const Value: ROAnsiString): Integer

Parameters:

  • Value: given string

 

CapacityIncrement    (declared in TROBinaryMemoryStream)

The amount by which the capacity of the stream is automatically incremented when its size becomes greater than its capacity.

property CapacityIncrement: Integer read write

ContentFileName

This optional property allows to set default file name that will be used by the user's browser to save the downloaded data.

property ContentFileName: string read write

ContentIsInline

Allows to set the Content-Disposition header value.
The ContentIsInline property controls whether the header value will contain inline or attachment prefix

property ContentIsInline: Boolean read write

ContentType

Allows to set a custom value of the response's Content-Type header. By default Http API responses have Content-Type header value set to application/json. This feature allows to set it to a custom value.

property ContentType: string read write

HttpStatusCode

Allows to set any possible HTTP response code

property HttpStatusCode: Integer read write

 

constructor Create  overload    (declared in TROBinaryMemoryStream)

Creates a new instance.

constructor Create

constructor Create (Integer, string, string, Boolean)

constructor Create(aHttpStatusCode: Integer; aContentType: string; aContentFileName: string = ''; aContentIsInline: Boolean = True)

Parameters:

  • aHttpStatusCode:
  • aContentType:
  • aContentFileName:
  • aContentIsInline:

constructor Create (AnsiString)  overload    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

constructor Create(const Value: AnsiString)

Parameters:

  • Value: given string

constructor Create (ROAnsiString)  overload    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

constructor Create(const Value: ROAnsiString)

Parameters:

  • Value: given string

Assign  override

Copies the contents of another, similar object.

procedure Assign(Source: TStream)

Parameters:

  • Source: Source object

Clone    (declared in TROBinaryMemoryStream)

Creates and returns a new memory stream that is an identical copy of the current stream. The new stream will receive its own copy of the data, and any changes to data or stream position will not affect the original version.

function Clone: TROBinaryMemoryStream

GenerateContentDisposition

Generates Content-Disposition header value. Depends on ContentIsInline value

function GenerateContentDisposition: string

LoadFromHexString    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

procedure LoadFromHexString(const Value: ROAnsiString)

Parameters:

  • Value: given string

LoadFromString (AnsiString)  overload    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

procedure LoadFromString(const Value: AnsiString)

Parameters:

  • Value: given string

LoadFromString (ROAnsiString)  overload    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

procedure LoadFromString(const Value: ROAnsiString)

Parameters:

  • Value: given string

LoadFromUTF8String    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

procedure LoadFromUTF8String(const Value: UnicodeString)

Parameters:

  • Value: given string

ToHexString    (declared in TROBinaryMemoryStream)

Emits the data in the stream as a string containing hexadecimal characters. For each byte in the original stream, two characters between '0' and 'F' will be emitted to the string.

function ToHexString: ROAnsiString

ToReadableString    (declared in TROBinaryMemoryStream)

Emits the data in the stream as an ansi string for display purposes. For each byte in the original stream, the corresponding ASCII character will be emitted to the string if the value is $0D or between $20 and $7F, and a "period" character will be emitted otherwise. This results in a string that can cleanly be displayed and does not contain ASCII control characters.

function ToReadableString: ROAnsiString

ToString    (declared in TROBinaryMemoryStream)

Emits the data in the stream as an ansi string. For each byte in the original stream, the corresponding ANSI character will be emitted to the string.

function ToString: ROAnsiString

WriteAnsiString    (declared in TROBinaryMemoryStream)

Creates a new instance from given string.

function WriteAnsiString(const Value: ROAnsiString): Integer

Parameters:

  • Value: given string