options( url, [body], [params] )
参数 | 类型 | 描述 |
---|---|---|
url | string / HTTP URL | 请求 URL (例如 http://example.com )。 |
body (可选) | string / object / ArrayBuffer | 请求体;对象将使用 x-www-form-urlencoded 进行编码。 |
params (可选) | object | 包含额外请求参数的 Params 对象。 |
返回值
类型 | 描述 |
---|---|
Response | HTTP Response 对象。 |
示例
import http from 'k6/http';
const url = 'https://quickpizza.grafana.com/';
export default function () {
const params = { headers: { 'X-MyHeader': 'k6test' } };
const res = http.options(url, null, params);
console.log(res.headers['Allow']);
}