HttpMessage
in package
Represents a base HTTP message.
Table of Contents
Methods
- __construct() : mixed
- getContent() : IHttpContent|null
- Retrieves message body contents, if present.
- getHeader() : HttpHeader
- Retrieves a header by name.
- getHeaderFirstLine() : string
- Gets the first line of a header.
- getHeaderLine() : string
- Gets the contents of a header as a string.
- getHeaderLines() : array<string|int, string>
- Gets lines of a header.
- getHeaders() : array<string|int, HttpHeader>
- Retrieves the collection of headers for this HTTP message.
- getHttpVersion() : string
- Retrieves the HTTP version of this message.
- hasContent() : bool
- Checks whether this HTTP message has body contents.
- hasHeader() : bool
- Checks if a header is present.
- isBencodedContent() : bool
- Checks if the body content is BencodedContent.
- isFormContent() : bool
- Checks if the body content is FormContent.
- isJsonContent() : bool
- Checks if the body content is JsonContent.
- isStreamContent() : bool
- Checks if the body content is StreamContent.
- isStringContent() : bool
- Checks if the body content is StringContent.
Methods
__construct()
public
__construct(string $version, HttpHeaders $headers, IHttpContent|null $content) : mixed
Parameters
- $version : string
-
HTTP message version.
- $headers : HttpHeaders
-
HTTP message headers.
- $content : IHttpContent|null
-
Body contents.
getContent()
Retrieves message body contents, if present.
public
getContent() : IHttpContent|null
Return values
IHttpContent|null —Body contents, null if none present.
getHeader()
Retrieves a header by name.
public
getHeader(string $name) : HttpHeader
Parameters
- $name : string
-
Name of the header.
Tags
Return values
HttpHeader —Instance of the requested header.
getHeaderFirstLine()
Gets the first line of a header.
public
getHeaderFirstLine(string $name) : string
Parameters
- $name : string
-
Name of the header.
Return values
string —First line of the header.
getHeaderLine()
Gets the contents of a header as a string.
public
getHeaderLine(string $name) : string
Parameters
- $name : string
-
Name of the header.
Return values
string —Contents of the header.
getHeaderLines()
Gets lines of a header.
public
getHeaderLines(string $name) : array<string|int, string>
Parameters
- $name : string
-
Name of the header.
Return values
array<string|int, string> —Header lines.
getHeaders()
Retrieves the collection of headers for this HTTP message.
public
getHeaders() : array<string|int, HttpHeader>
Return values
array<string|int, HttpHeader> —HTTP headers.
getHttpVersion()
Retrieves the HTTP version of this message.
public
getHttpVersion() : string
Return values
string —HTTP version.
hasContent()
Checks whether this HTTP message has body contents.
public
hasContent() : bool
Return values
bool —true if it has body contents.
hasHeader()
Checks if a header is present.
public
hasHeader(string $name) : bool
Parameters
- $name : string
-
Name of the header.
Return values
bool —true if the header is present.
isBencodedContent()
Checks if the body content is BencodedContent.
public
isBencodedContent() : bool
Return values
bool —true if it is BencodedContent.
isFormContent()
Checks if the body content is FormContent.
public
isFormContent() : bool
Return values
bool —true if it is FormContent.
isJsonContent()
Checks if the body content is JsonContent.
public
isJsonContent() : bool
Return values
bool —true if it is JsonContent.
isStreamContent()
Checks if the body content is StreamContent.
public
isStreamContent() : bool
Return values
bool —true if it is StreamContent.
isStringContent()
Checks if the body content is StringContent.
public
isStringContent() : bool
Return values
bool —true if it is StringContent.