HttpRequestBuilder
extends HttpMessageBuilder
in package
Represents a HTTP request 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.
- removeCookie() : void
- Removes a HTTP request cookie.
- removeHeader() : void
- Removes a header from the HTTP message.
- removeParam() : void
- Removes a HTTP request query param.
- setContent() : void
- Sets HTTP message body contents.
- setCookie() : void
- Sets a HTTP request cookie.
- setCookies() : void
- Sets HTTP request cookies.
- setCountryCode() : void
- Sets the the ISO 3166 country code for this request.
- setHeader() : void
- Sets a header to the HTTP message.
- setHttpVersion() : void
- Sets HTTP version for the message.
- setMethod() : void
- Sets HTTP request method.
- setParam() : void
- Sets a HTTP request query param.
- setParams() : void
- Sets HTTP request query params.
- setPath() : void
- Sets HTTP request path.
- setRemoteAddress() : void
- Sets the remote address from request originated.
- setSecure() : void
- Sets whether the request was made over HTTPS.
- toRequest() : HttpRequest
- Creates a HttpRequest instance from this builder.
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.
removeCookie()
Removes a HTTP request cookie.
public
removeCookie(string $name) : void
Parameters
- $name : string
-
Name of the cookie.
removeHeader()
Removes a header from the HTTP message.
public
removeHeader(string $name) : void
Parameters
- $name : string
-
Name of the header to remove.
removeParam()
Removes a HTTP request query param.
public
removeParam(string $name) : void
Parameters
- $name : string
-
Name of the query field.
setContent()
Sets HTTP message body contents.
public
setContent(HttpContent|Stringable|string|int|float|resource|null $content) : void
Parameters
- $content : HttpContent|Stringable|string|int|float|resource|null
-
Body contents
setCookie()
Sets a HTTP request cookie.
public
setCookie(string $name, string $value) : void
Parameters
- $name : string
-
Name of the cookie.
- $value : string
-
Value of the cookie.
setCookies()
Sets HTTP request cookies.
public
setCookies(array<string, string> $cookies) : void
Parameters
- $cookies : array<string, string>
-
HTTP request cookies.
setCountryCode()
Sets the the ISO 3166 country code for this request.
public
setCountryCode(string $countryCode) : void
Parameters
- $countryCode : string
-
Two letter country code.
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.
setMethod()
Sets HTTP request method.
public
setMethod(string $method) : void
Parameters
- $method : string
-
HTTP request method.
setParam()
Sets a HTTP request query param.
public
setParam(string $name, mixed $value) : void
Parameters
- $name : string
-
Name of the query field.
- $value : mixed
-
Value of the query field.
setParams()
Sets HTTP request query params.
public
setParams(array<string, mixed> $params) : void
Parameters
- $params : array<string, mixed>
-
HTTP request query params.
setPath()
Sets HTTP request path.
public
setPath(string $path) : void
Parameters
- $path : string
-
HTTP request path.
setRemoteAddress()
Sets the remote address from request originated.
public
setRemoteAddress(string $remoteAddr) : void
Parameters
- $remoteAddr : string
-
Remote address.
setSecure()
Sets whether the request was made over HTTPS.
public
setSecure(bool $secure) : void
Parameters
- $secure : bool
-
true if HTTPS.
toRequest()
Creates a HttpRequest instance from this builder.
public
toRequest() : HttpRequest
Return values
HttpRequest —An instance representing this builder.