internalRequest()
Makes a request to the CFML Engine internally. also available in 5.x as _internalRequest()
Great for CI / tests, internalRequest allows you to call another cfml page on the same server without needing to make an http call
The template argument
The template is a path to a CFML template on the same server.
- A path with a leading slash is resolved from the root, from the web root and the mappings, for example
/app/index.cfm. - A path without a leading slash is relative to the directory of the template that calls the function, like in
cfinclude../and../are supported, for exampleindex.cfm,sub/index.cfmor../index.cfm. The directory is taken from the virtual path of the caller, so it works for templates that are found through a mapping. - A relative path that goes above the root with
../throws an exception.
Breaking change in Lucee 9.0 (LDEV-4038): before Lucee 9.0 a path without a leading slash was resolved from the root. Add the leading slash to such calls, see Breaking Changes between Lucee 8.0 and 9.0.
Introduced: 6.0.0.161
internalRequest( template=string, method=string, urls=any, forms=any, cookies=struct, headers=struct, body=any, charset=string, addToken=boolean, throwonerror=boolean );
Returns: Struct
| Argument | Description | Default |
|---|---|---|
|
template
string,
required
|
edit
Template path (script name) for the request (example:/test/index.cfm). |
|
|
method
string,
optional
|
edit
method of the request (GET,POST,PUT,DELETE ...) |
get |
|
urls
any,
optional
|
edit
URL scope passed to the request (query string). This can be a struct or a string following this format [name1=value1&name2=value2]. Alias: url |
|
|
forms
any,
optional
|
edit
FORM scope passed to the request.This can be a struct or a string following this format [name1=value1&name2=value2]. Alias: form |
|
|
cookies
struct,
optional
|
edit
Cookie scope passed to the request Alias: cookie |
|
|
headers
struct,
optional
|
edit
Request header entries passed to the request Alias: header |
|
|
body
any,
optional
|
edit
body to send with the request |
|
|
charset
string,
optional
|
edit
charset used for the request, if not set the web charset is used. |
|
|
addToken
boolean,
optional
|
edit
if yes add urlToken as cookie |
false |
|
throwonerror
boolean,
optional
|
edit
if true (default) and the called page throws an exception, that exception is also thrown within the caller request. If false it is caught and only reported in the resulting struct. |
true |
Examples
There are currently no examples for this function 29,389ms WARN No examples for function InternalRequestSee also
- Internet Protocols
- Lucee Server related Tags, Functions and Guides
- <cfhttp>
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)