HttpMessageBuilder
in package
Represents a base HTTP message builder.
Table of Contents
Methods
- __construct() : mixed
- addHeader() : void
- Adds a header to the HTTP message.
- getHeadersBuilder() : HttpHeadersBuilder
- Retrieves instance of the underlying HTTP header builder.
- hasContent() : bool
- Checks whether this HTTP message has body contents.
- hasHeader() : bool
- Checks if a header is already present.
- removeHeader() : void
- Removes a header from the HTTP message.
- setContent() : void
- Sets HTTP message body contents.
- setHeader() : void
- Sets a header to the HTTP message.
- setHttpVersion() : void
- Sets HTTP version for the message.
Methods
__construct()
public
__construct() : mixed
addHeader()
Adds a header to the HTTP message.
public
addHeader(string $name, string $value) : void
If a header with the same name is already present, it will be appended with a new line.
Parameters
- $name : string
-
Name of the header to add.
- $value : string
-
Value to apply for this header.
getHeadersBuilder()
Retrieves instance of the underlying HTTP header builder.
public
getHeadersBuilder() : HttpHeadersBuilder
Return values
HttpHeadersBuilder —HTTP header builder.
hasContent()
Checks whether this HTTP message has body contents.
public
hasContent() : bool
Tags
Return values
bool —true if it has body contents.
hasHeader()
Checks if a header is already present.
public
hasHeader(string $name) : bool
Parameters
- $name : string
-
Name of the header.
Return values
bool —true if it is present.
removeHeader()
Removes a header from the HTTP message.
public
removeHeader(string $name) : void
Parameters
- $name : string
-
Name of the header to remove.
setContent()
Sets HTTP message body contents.
public
setContent(IHttpContent|Stream|string|null $content) : void
Parameters
- $content : IHttpContent|Stream|string|null
-
Body contents
setHeader()
Sets a header to the HTTP message.
public
setHeader(string $name, string $value) : void
If a header with the same name is already present, it will be overwritten.
Parameters
- $name : string
-
Name of the header to set.
- $value : string
-
Value to apply for this header.
setHttpVersion()
Sets HTTP version for the message.
public
setHttpVersion(string $version) : void
Parameters
- $version : string
-
HTTP version.