new HttpRequest( [host] [, port] [, path] [, ssl] [, method] [, body] [, responseType] [, query])
Creates an instance of HttpRequest
.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
host |
string |
<optional> |
localhost | Request hostname. |
port |
number |
<optional> |
80 | Request port. |
path |
string |
<optional> |
"/" | Request path. |
ssl |
boolean |
<optional> |
false | Whether the request is SSL enabled, if port is 443 the default is |
method |
olympe.net.Http.Method |
<optional> |
'GET' | Method to pass data along the request. GET or POST. |
body |
Blob | string |
<optional> |
Body (data) sent with a POST request. |
|
responseType |
olympe.net.Http.ResponseType |
<optional> |
'text' | Type of response. |
query |
string |
<optional> |
The query associated with the request. |
Extends
Members
-
<static> Method :string
-
Type:
- string
- Deprecated:
-
- Use #olympe.net.Http.Method instead
Properties:
Name Type Default Description POST
string POST GET
string GET HEAD
string HEAD PUT
string PUT DELETE
string DELETE OPTIONS
string OPTIONS
Methods
-
<static> fromUrl(url [, method] [, body] [, responseType])
-
Creates an
HttpRequest
from a URL.Parameters:
Name Type Argument Default Description url
string | olympe.df.OString The URL.
method
olympe.net.Http.Method <optional>
'GET' Method to pass data along the request. GET or POST.
body
Blob | string <optional>
Body (data) sent with a POST request.
responseType
olympe.net.Http.ResponseType <optional>
'text' Type of response.
Returns:
The created
HttpRequest
. -
addBasicAuthorizationHeaders(userinfo [, logger])
-
Add basic authentication headers to this request.
Parameters:
Name Type Argument Description userinfo
string logger
olympe.logging.Channel <optional>
-
addHeaders(headers)
-
Adds headers to this request.
Parameters:
Name Type Description headers
Object.<string, string> The headers.
-
getBody()
-
Get this request body.
Returns:
The body.
- Type
- Blob | string | undefined
-
getClientCertificate()
-
Returns:
cert
- Type
- string
-
getClientKey()
-
Returns:
key
- Type
- string
-
getHeaders()
-
Get this request headers.
Returns:
The headers.
- Type
- Object.<string, string>
-
getHost()
-
Gets the request host.
- Inherited From:
- Overrides:
Returns:
The host name.
- Type
- string
-
getMethod()
-
Gets this request method.
Returns:
The request method.
-
getPath()
-
Gets the request's path.
- Inherited From:
- Overrides:
Returns:
The path.
- Type
- string
-
getPort()
-
Gets the request port.
- Inherited From:
- Overrides:
Returns:
The port.
- Type
- number
-
getQuery()
-
Gets this request query. Encode every character expect
=
and&
.Returns:
The query appended to the URL.
- Type
- string
-
getRejectUnauthorized()
-
Returns:
rejectUnauthorized
- Type
- boolean
-
getResponseType()
-
Gets this request response type.
Returns:
The response type.
-
getServerCertificate()
-
Returns:
ca
- Type
- string
-
getUrl()
-
Gets the request's URL.
- Inherited From:
- Overrides:
Returns:
The URL.
- Type
- string
-
isSSL()
-
Checks whether the request is over SSL.
- Inherited From:
- Overrides:
Returns:
true
if the request is over SSL.- Type
- boolean
-
setBody(body)
-
Sets this request body.
Parameters:
Name Type Description body
Blob | string The body.
-
setClientCertificate(path)
-
Parameters:
Name Type Description path
string -
setClientKey(path)
-
Parameters:
Name Type Description path
string -
setHeader(name, value)
-
Sets a specific header for this request.
Parameters:
Name Type Description name
string The name of the header.
value
string The value of the header.
-
setHost(hostname)
-
Sets the request host.
Parameters:
Name Type Argument Description hostname
string <nullable>
The host name.
- Inherited From:
- Overrides:
-
setMethod(method)
-
Sets this request method.
Parameters:
Name Type Description method
olympe.net.Http.Method The request method.
-
setPath(path)
-
Sets the request path.
Parameters:
Name Type Description path
string The path.
- Inherited From:
- Overrides:
-
setPort(port)
-
Sets the request's port.
Parameters:
Name Type Description port
number Port number.
- Inherited From:
- Overrides:
-
setQuery(query)
-
Sets this request query.
Parameters:
Name Type Description query
string The query appended to the URL.
-
setRejectUnauthorized(reject)
-
Parameters:
Name Type Description reject
boolean -
setResponseType(responseType)
-
Sets this request response type.
Parameters:
Name Type Description responseType
olympe.net.Http.ResponseType The response type.
-
setServerCertificate(path)
-
Parameters:
Name Type Description path
string -
setSSL(ssl)
-
Set this request as SSL enabled.
Parameters:
Name Type Description ssl
boolean true
for SSL.- Inherited From:
- Overrides:
-
toString()
-
Gets a string representation
- Overrides:
Returns:
- Type
- string