tencent cloud

Tencent Cloud Observability Platform

Configuration Options

PDF
Mode fokus
Ukuran font
Terakhir diperbarui: 2025-03-10 22:14:18

Configuration Options Supported by PTS

The request configuration for HTTP can be defined in the global variable option. The following table lists the configuration options supported by PTS.
HTTP Request Configuration Option
Description
maxRedirects
Number of redirects.
maxIdleConns
Maximum number of active connections per VU.
maxIdleConnsPerHost
Maximum number of active connections per VU per domain name.
disableKeepAlives
Whether to disable persistent connection.
headers
Common request header.
timeout
Request timeout interval, in milliseconds.
basicAuth
Basic authentication.
http2
Whether to enable HTTP/2.
discardResponseBody
Whether to discard response packets. When the performance testing task does not focus on responses, you can enable this feature to improve testing performance.
Note:
For the complete list of options, see HTTP Global Options.

Configuring the Timeout Interval for HTTP Requests

import http from "pts/http";

export const option = {
http: {
timeout: 3000,
}
}

export default function() {
http.get("http://httpbin.org/get"); // Error: Get "http://httpbin.org/get": net/http: request canceled while waiting for connection
}

Configuring Basic Authentication for HTTP Requests

// HTTP basic authentication
import http from 'pts/http';
import { check } from 'pts';

export const option = {
http: {
basicAuth: {
username: 'user',
password: 'passwd',
}
}
}

export default function () {
const resp = http.get(http://httpbin.org/basic-auth/user/passwd);
console.log(resp.json().authenticated); // true
check('body.authenticated equals true', () => resp.json().authenticated === true);
}


Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan