Files
playbook/skills/tsl-api-reference/references/codegen/builtin/external/cgi.md
T
csh 13be5ea0aa feat(tsl-api-reference): index class and unit APIs
Migrate reference pages to declaration-line storage and rebuild the
13-column index.

Add qualified member lookup plus regression and end-to-end coverage.
2026-07-29 15:47:46 +08:00

292 lines
5.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Builtin - 外部交互 / CGI
## `unsetEchoString()`
声明:function
取出被SetEchoString后的重定向输出流,取出后重置输出流为空。
返回:string
## `isEchoRedirect()`
声明:function
判断目前是否被SetEchoString重定向,如果被重定向了,返回为真,否则为假。
返回:bool
## `readLn()`
声明:function
从控制台读字符串并返回结果(输入以回车结束)。
返回:string
## `writeln(p1, pn)`
声明:function
带回车地输出字符串,如果在平台运行,会输出信息到客户端。
| 参数 | 类型 | 说明 |
| ---- | ------ | -------------- |
| `p1` | string | string 字符串1 |
| `pn` | string | string 字符串n |
返回:any
### 示例
```tsl
// 先输出111222,接着另起一行显示空白,再接着另起一行输出333
writeln("111", "222");
writeln("333");
{结果页面中,运行信息下打印:
111222
333
}
```
## `write(p1, pn)`
声明:function
输出字符串,如果在平台运行,会输出信息到客户端。
| 参数 | 类型 | 说明 |
| ---- | ------ | -------------- |
| `p1` | string | string 字符串1 |
| `pn` | string | string 字符串n |
返回:any
### 示例
```tsl
// 先输出123456,接着另起一行输出789
write("123", "456");
write("789");
return;
{在结果页面中打印:
123456
789}
```
## `httpGetContent()`
声明:function
返回前端发送的内容串,如果内容串长度和HttpGetContentLength不一致,则需要用TWebRequest类来读取剩余内容。
返回:string
## `httpGetContentLength()`
声明:function
返回前端发送的内容串的长度。
返回:integer
## `httpGetQueryString()`
声明:function
返回前端发送的查询串。
返回:string
### 示例
```tsl
// 前端执行的是http: // hostname/test.tsl?name=billgates&sex=male
// 则返回的值为name=billgates&sex=male
```
## `httpGetRequestMethod()`
声明:function
返回前端发送请求的类型。如get或者put。
返回:string
## `httpGetQueryValues()`
声明:function
分解前端发送的查询串为字符串下标的字符串数组。
返回:array[key:string] of string
## `httpGetQueryValueByName(name, additional_info)`
声明:function
得到指定参数的查询串的值。
| 参数 | 类型 | 说明 |
| ----------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------- |
| `name` | string | 字符串类型。查询串中的变量名。 |
| `additional_info` | string | 字符串类型,返回附加信息。最常见的是当查询的Name为文件上传的ID时,函数返回文件的内容,而AdditionalInfo返回包括文件名等内容的附加信息。 |
返回:string
## `httpGetQueryValueByNameEx(name)`
声明:function
得到查询串的值,网页多文件一次性上传可能会用多同名多个内容的情况,返回二维数组结构。
| 参数 | 类型 | 说明 |
| ------ | ------ | -------------------------- |
| `name` | string | 字符串,查询串中的变量名。 |
返回:array
## `httpGetScriptName()`
声明:function
返回所执行的CGI名。
返回:string
## `httpGetPathInfo()`
声明:function
返回所执行的CGI的虚拟路径名。
返回:string
## `httpGetPathTranslated()`
声明:function
返回所执行的CGI的实路径名。
返回:string
## `httpGetRemoteHost()`
声明:function
返回所执行的CGI的前端主机名。
返回:string
## `httpGetRemoteAddr()`
声明:function
返回所执行的CGI的前端IP地址。
返回:string
## `httpGetRemoteUser()`
声明:function
返回所执行的CGI的远端登录用户名。
返回:string
## `httpGetRemoteIdent()`
声明:function
返回所执行的CGI的远端识别串。
返回:string
## `httpGetHttpAccept()`
声明:function
返回接受的类型种类。
返回:string
## `httpGetHttpUserAgent()`
声明:function
返回用户代理串。
返回:string
## `httpGetServerName()`
声明:function
返回服务器名。
返回:string
## `httpGetServerPort()`
声明:function
返回服务器端口。
返回:string
## `httpGetServerProtocol()`
声明:function
返回服务器协议类别。
返回:string
## `httpGetServerSoftware()`
声明:function
返回服务器软件的名称。
返回:string
## `httpGetGatewayInterface()`
声明:function
返回网关接口。
返回:string
## `httpGetCookie()`
声明:function
返回Cookie串。
返回:string
## `httpGetEnvVar(env_name)`
声明:function
返回指定名称的环境串。
| 参数 | 类型 | 说明 |
| ---------- | ------ | ------------------------ |
| `env_name` | string | 字符串类型,环境变量名。 |
返回:string
## `httpSetHeadString(header)`
声明:function
设置返回的HTTP头。
| 参数 | 类型 | 说明 |
| -------- | ------ | ------------------------------------------------ |
| `header` | string | 字符串类型,Http头,以连续两个回车换行作为结尾。 |
返回:string