Home Units Hierarchy Routines All identifiers

Class unaHTTPparser

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type unaHTTPparser = class(unaObject)

Description

HTTP-like protocols parser

Hierarchy

Overview

Methods

Public constructor create();
Public function getFullHeader(): aString;
Public function getHeaderCount(): int;
Public function getHeaderName(index: int): string;
Public function getHeaderValue(const headerName: string; trim: bool = false): string; overload;
Public function getHeaderValue(index: int; trim: bool = false): string; overload;
Public function getPayload(): aString;
Public function getPayloadComplete(connected: bool; defaultCL: int = -1): bool;
Public function getPayloadSize(): int;
Public function getReqMethod(): string;
Public function getReqProtoVersion(): string;
Public function getReqURI(): string;
Public function getRespCode(): int;
Public function getRespCodeString(): string;
Public function getRespProtoVersion(): string;
Public procedure BeforeDestruction(); override;
Public procedure cleanup();
Public procedure dropIfComplete(defaultCL: int = -1);
Public procedure feed(data: pointer; len: int);
Protected procedure doCleanup(); virtual;
Protected procedure setHeaderDelimiter(newDelimiter: char);

Properties

Public property data: paChar read f_buf;
Public property dataSize: int read f_bufSize;
Public property headerComplete: bool read getHC;
Public property headerSize: int read f_headerSize;

Description

Methods

Public constructor create();

Initializes instance.

Public function getFullHeader(): aString;
 
Returns

full header.

Public function getHeaderCount(): int;
 
Returns

number of headers.

Public function getHeaderName(index: int): string;

Parameters
index
header index (starting from 0)
Returns

specified header name.

Public function getHeaderValue(const headerName: string; trim: bool = false): string; overload;

Parameters
headerName
name of header
Returns

specified header value

Public function getHeaderValue(index: int; trim: bool = false): string; overload;

Parameters
index
header index (starting from 0)
Returns

specified header value by index.

Public function getPayload(): aString;
 
Returns

payload data (if any).

Public function getPayloadComplete(connected: bool; defaultCL: int = -1): bool;

True if complete payload was received.

Parameters
connected
True if socket is still connected
defaultCL
Default value if Contnent-Length header is missing. Some protocols (like RTSP) require this to be 0 by default.
Returns

True if payload is "completely" present: [Contnent-Length=0 or missing and default is 0 or default is -1 and connection is closed | or at least Contnent-Length bytes of payload is present]

Public function getPayloadSize(): int;
 
Returns

current payload size.

Public function getReqMethod(): string;
 
Returns

requested method (if any).

Public function getReqProtoVersion(): string;
 
Returns

request protocol version (if any).

Public function getReqURI(): string;
 
Returns

requested URI (if any).

Public function getRespCode(): int;
 
Returns

response code (if any).

Public function getRespCodeString(): string;
 
Returns

response code as string (if provided in response).

Public function getRespProtoVersion(): string;
 
Returns

response protocol version (if any).

Public procedure BeforeDestruction(); override;

Cleans up the instance.

Public procedure cleanup();

Cleans internal buffers and prepares parser for new data.

Public procedure dropIfComplete(defaultCL: int = -1);

Drops complete Request/Response with payload (if any).

Public procedure feed(data: pointer; len: int);

Feeds parser with new portion of data.

Parameters
data
Pointer to new portion of text.
len
Size of data in bytes.
Protected procedure doCleanup(); virtual;

//

Protected procedure setHeaderDelimiter(newDelimiter: char);

//

Properties

Public property data: paChar read f_buf;

RAW data access.

Public property dataSize: int read f_bufSize;

Returns data size, that is size of data written to parser so far, inlcuding header.

Public property headerComplete: bool read getHC;

True if complete header was received.

Public property headerSize: int read f_headerSize;

Returns header size (valid when headerComplete is true).

(c) 2012 Lake of Soft


Generated by PasDoc 0.12.1 on 2012-10-09