Script: Class dw.system.Request

Class Request

Represents a request in Commerce Cloud Digital. Each pipeline dictionary contains a CurrentRequest object, which is of type dw.system.Request. Most requests are HTTP requests, so you can use this object to get information about the HTTP request, such as the HTTP headers. You can also get a list of cookies, if any, associated with the request. If the request is issued from a job, the request is not an HTTP request, so HTTP-related methods return null.

Properties

clientId : String Read Only

The client id of the current SCAPI or OCAPI request. If the request is not a SCAPI request or not an OCAPI request 'null' is returned. For client ids owned by Commerce Cloud Digital an alias is returned.

custom : CustomAttributes Read Only

All of the custom attributes associated with the request. The attributes are stored for the life time of the request.

geolocation : Geolocation

The physical location for the current request, if available. The location is calculated based on the IP address of the request. Note, if the geolocation tracking feature is not enabled, this method always returns null.

httpCookies : Cookies Read Only

The Cookies object, which can be used to read cookies sent by the client. Use the method Response.addHttpCookie() to add a cookie to the outgoing response.

httpHeaders : Map Read Only

A Map containing all HTTP header values.

httpHost : String Read Only

The host name or null if there is no host name.

httpLocale : String Read Only

The locale or null if there is no associated locale.

httpMethod : String Read Only

The name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

httpParameterMap : HttpParameterMap Read Only

The parameter map that contains the HTTP parameters for the current request.

httpParameters : Map Read Only

A Map containing the raw HTTP parameters sent to the server. The Map contains name/value pairs. Each name is a String and each value is a String array.

httpPath : String Read Only

The path.

httpProtocol : String Read Only

The HTTP protocol used for this request. Possible values are "http" or "https". If the current activity is not related to an HTTP request, for example, when the request is part of a job, this method returns null.

httpQueryString : String Read Only

The query string or null if there is no query string.

httpReferer : String Read Only

The referer or null if there is no referer.

httpRemoteAddress : String Read Only

The remote address or null if no remote address is found.

httpRequest : boolean Read Only

Identifies if this request is an HTTP request. The method returns true, if the current processing is related to a HTTP request.

Deprecated:

Effectively always returns true.

httpSecure : boolean Read Only

Returns whether the HTTP communication is secure, which basically means that the communication happens via https. If the current activity is not related to an HTTP request the method returns false.

httpURL : URL Read Only

The complete URL of the request which was received at the server. This URL does not include SEO optimizations.

httpUserAgent : String Read Only

The HTTP user agent or null if there is no user agent.

includeRequest : boolean Read Only

Returns true if the request represents a request for a remote include, false if it is a top-level request.

locale : String

The locale of the current request. This locale is set by the system based on the information in the URL. It may be different from the locale returned by getHttpLocale(), which is the preferred locale sent by the user agent.

ocapiVersion : String Read Only

The OCAPI version of the current request. If this is not an OCAPI request, 'null' is returned.

pageMetaData : PageMetaData Read Only

The page meta data that are associated with the current request.

requestID : String Read Only

The unique identifier of the current request. The unique id is helpful for debugging purpose, e.g. relate debug messages to a particular request.

SCAPI : boolean Read Only

Returns whether the request originated in SCAPI.

session : Session Read Only

The session associated with this request.

triggeredForm : Form Read Only

The form that was submitted by the client if the request represents a form submission.

triggeredFormAction : FormAction Read Only

The form action that was triggered by the client if the request represents a form submission.

Constructor Summary

This class does not have a constructor, so you cannot create it directly.

Method Summary

addHttpCookie(cookie : Cookie) : void

Adds the specified cookie to the outgoing response.

getClientId() : String

Returns the client id of the current SCAPI or OCAPI request.

getCustom() : CustomAttributes

Returns all of the custom attributes associated with the request.

getGeolocation() : Geolocation

Returns the physical location for the current request, if available.

getHttpCookies() : Cookies

Returns the Cookies object, which can be used to read cookies sent by the client.

getHttpHeaders() : Map

Returns a Map containing all HTTP header values.

getHttpHost() : String

Returns the host name or null if there is no host name.

getHttpLocale() : String

Returns the locale or null if there is no associated locale.

getHttpMethod() : String

Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

getHttpParameterMap() : HttpParameterMap

Returns the parameter map that contains the HTTP parameters for the current request.

getHttpParameters() : Map

Returns a Map containing the raw HTTP parameters sent to the server.

getHttpPath() : String

Returns the path.

getHttpProtocol() : String

Returns the HTTP protocol used for this request.

getHttpQueryString() : String

Returns the query string or null if there is no query string.

getHttpReferer() : String

Returns the referer or null if there is no referer.

getHttpRemoteAddress() : String

Returns the remote address or null if no remote address is found.

getHttpURL() : URL

Returns the complete URL of the request which was received at the server.

getHttpUserAgent() : String

Returns the HTTP user agent or null if there is no user agent.

getLocale() : String

Returns the locale of the current request.

getOcapiVersion() : String

Returns the OCAPI version of the current request.

getPageMetaData() : PageMetaData

Returns the page meta data that are associated with the current request.

getRequestID() : String

Returns the unique identifier of the current request.

getSession() : Session

Returns the session associated with this request.

getTriggeredForm() : Form

Returns the form that was submitted by the client if the request represents a form submission.

getTriggeredFormAction() : FormAction

Returns the form action that was triggered by the client if the request represents a form submission.

isHttpRequest() : boolean

Identifies if this request is an HTTP request.

isHttpSecure() : boolean

Returns whether the HTTP communication is secure, which basically means that the communication happens via https.

isIncludeRequest() : boolean

Returns true if the request represents a request for a remote include, false if it is a top-level request.

isSCAPI() : boolean

Returns whether the request originated in SCAPI.

setGeolocation(geoLocation : Geolocation) : void

Sets the physical location for the current request and remembers the new value for the duration of the user session.

setLocale(localeID : String) : boolean

Sets the given locale for the request.

Methods inherited from class Object

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Method Detail

addHttpCookie(cookie : Cookie) : void

Adds the specified cookie to the outgoing response. This method can be called multiple times to set more than one cookie. If a cookie with the same cookie name, domain and path is set multiple times for the same response, only the last set cookie with this name is send to the client. This method can be used to set, update or delete cookies at the client. If the cookie doesn't exist at the client, it is set initially. If a cookie with the same name, domain and path already exists at the client, it is updated. A cookie can be deleted at the client by submitting a cookie with the maxAge attribute set to 0 (see Cookie.setMaxAge() for more information).

Example, how a cookie can be deleted at the client:
var cookie : Cookie = new Cookie("SomeName", "Simple Value");
cookie.setMaxAge(0);
request.addHttpCookie(cookie);

Deprecated:

Use Response.addHttpCookie(Cookie) instead.

Parameters:

cookie - a Cookie object

getClientId

getClientId() : String

Returns the client id of the current SCAPI or OCAPI request. If the request is not a SCAPI request or not an OCAPI request 'null' is returned. For client ids owned by Commerce Cloud Digital an alias is returned.

Returns:

a client id or alias in case of an OCAPI request, otherwise null.


getCustom

getCustom() : CustomAttributes

Returns all of the custom attributes associated with the request. The attributes are stored for the life time of the request.

Returns:

all of the custom attributes associated with the request.


getGeolocation

getGeolocation() : Geolocation

Returns the physical location for the current request, if available. The location is calculated based on the IP address of the request. Note, if the geolocation tracking feature is not enabled, this method always returns null.

Returns:

The geolocation of the current request, or null if this is not available.


getHttpCookies

getHttpCookies() : Cookies

Returns the Cookies object, which can be used to read cookies sent by the client. Use the method Response.addHttpCookie() to add a cookie to the outgoing response.

Returns:

Cookies object or null if this is not an HTTP request


getHttpHeaders

getHttpHeaders() : Map

Returns a Map containing all HTTP header values.

Returns:

a Map containing all HTTP header values.


getHttpHost

getHttpHost() : String

Returns the host name or null if there is no host name.

Returns:

the host name or null if there is no host name.


getHttpLocale

getHttpLocale() : String

Returns the locale or null if there is no associated locale.

Returns:

the locale or null.


getHttpMethod

getHttpMethod() : String

Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.

Returns:

the HTTP method


getHttpParameterMap

getHttpParameterMap() : HttpParameterMap

Returns the parameter map that contains the HTTP parameters for the current request.

Returns:

the HTTP parameter map


getHttpParameters

getHttpParameters() : Map

Returns a Map containing the raw HTTP parameters sent to the server. The Map contains name/value pairs. Each name is a String and each value is a String array.

Returns:

a Map containing all the raw HTTP parameters send to the server.


getHttpPath

getHttpPath() : String

Returns the path.

Returns:

the path or null.


getHttpProtocol

getHttpProtocol() : String

Returns the HTTP protocol used for this request. Possible values are "http" or "https". If the current activity is not related to an HTTP request, for example, when the request is part of a job, this method returns null.

Returns:

"http", "https" or null


getHttpQueryString

getHttpQueryString() : String

Returns the query string or null if there is no query string.

Returns:

the query string or null.


getHttpReferer

getHttpReferer() : String

Returns the referer or null if there is no referer.

Returns:

the referer or null if there is no referer.


getHttpRemoteAddress

getHttpRemoteAddress() : String

Returns the remote address or null if no remote address is found.

Returns:

the remote address or null if no remote address is found.


getHttpURL

getHttpURL() : URL

Returns the complete URL of the request which was received at the server. This URL does not include SEO optimizations.

Returns:

the URL as URL object


getHttpUserAgent

getHttpUserAgent() : String

Returns the HTTP user agent or null if there is no user agent.

Returns:

the HTTP user agent or null if there is no user agent.


getLocale

getLocale() : String

Returns the locale of the current request. This locale is set by the system based on the information in the URL. It may be different from the locale returned by getHttpLocale(), which is the preferred locale sent by the user agent.

Returns:

the locale of the current request, like 'en_US'


getOcapiVersion

getOcapiVersion() : String

Returns the OCAPI version of the current request. If this is not an OCAPI request, 'null' is returned.

Returns:

OCAPI version of the current request


getPageMetaData

getPageMetaData() : PageMetaData

Returns the page meta data that are associated with the current request.

Returns:

the page meta data object


getRequestID

getRequestID() : String

Returns the unique identifier of the current request. The unique id is helpful for debugging purpose, e.g. relate debug messages to a particular request.

Returns:

the unique identifier of the current request.


getSession

getSession() : Session

Returns the session associated with this request.

Returns:

the session associated with this request.


getTriggeredForm

getTriggeredForm() : Form

Returns the form that was submitted by the client if the request represents a form submission.

Returns:

the form which was triggered


getTriggeredFormAction

getTriggeredFormAction() : FormAction

Returns the form action that was triggered by the client if the request represents a form submission.

Returns:

the action of the form that was triggered


isHttpRequest

isHttpRequest() : boolean

Identifies if this request is an HTTP request. The method returns true, if the current processing is related to a HTTP request.

Deprecated:

Effectively always returns true.

Returns:

true if the current processing is related to a HTTP request, false otherwise.


isHttpSecure

isHttpSecure() : boolean

Returns whether the HTTP communication is secure, which basically means that the communication happens via https. If the current activity is not related to an HTTP request the method returns false.


isIncludeRequest

isIncludeRequest() : boolean

Returns true if the request represents a request for a remote include, false if it is a top-level request.


isSCAPI

isSCAPI() : boolean

Returns whether the request originated in SCAPI.

Returns:

true or false.


setGeolocation

setGeolocation(geoLocation : Geolocation) : void

Sets the physical location for the current request and remembers the new value for the duration of the user session. So any subsequent calls to getGeolocation() will return this value

Parameters:

geoLocation - the geolocation object to use


setLocale

setLocale(localeID : String) : boolean

Sets the given locale for the request. The locale is only set if it is valid, if it is active and if it is allowed for the current site.

Parameters:

localeID - the locale ID to be set, like 'en_US'

Returns:

true, if the locale was successfully set, false otherwise