• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript http.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中k6/http.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test3

function test3() {
    const res = http.get("http://httpbin.org");
    check(res, {
        "response code was 200": (res) => res.status === 200,
        "body size was 1234 bytes": (res) => res.body.length === 1234,
    });
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:7,代码来源:k6-tests.ts


示例2: group

 group("features page", () => {
   const res = http.get("https://loadimpact.com/features");
   check(res, {
     "status code is 200": (res) => res.status === 200,
     "h1 message is correct": (res) => res.html("h1").text().startsWith("Simple yet realistic load testing"),
   });
 });
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:7,代码来源:k6-tests.ts


示例3: httpTest10

function httpTest10() {
    // Request page with links
    let res = http.get("https://httpbin.org/links/10/0");

    // Now, click the 4th link on the page
    res = res.clickLink({ selector: 'a:nth-child(4)' });
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:7,代码来源:k6-tests.ts


示例4: httpTest11

function httpTest11() {
    // Request page containing a form
    let res = http.get("https://httpbin.org/forms/post");

    // Now, submit form setting/overriding some fields of the form
    res = res.submitForm({ fields: { custname: "test", extradata: "test2" }, submitSelector: "mySubmit" });
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:7,代码来源:k6-tests.ts


示例5: httpTest5

function httpTest5() {
    const options = { maxRedirects: 10 };

    const baseURL = "https://dev-li-david.pantheonsite.io";

    // Fetch the login page, with the login HTML form
    const res1 = http.get(baseURL + "/user/login");

    // Extract hidden value needed to POST form
    const formBuildID = (res1.body.match('name="form_build_id" value="(.*)"') || [])[1];
    // Create an Object containing the form data
    const formdata = {
        name: "testuser1",
        pass: "testuser1",
        form_build_id: formBuildID,
        form_id: "user_login",
        op: "Log in",
    };
    const headers = { "Content-Type": "application/x-www-form-urlencoded" };
    // Send login request
    const res2 = http.post(baseURL + "/user/login", formdata, { headers });
    // Verify that we ended up on the user page
    check(res2, {
        "login succeeded": (res2) => res2.url === `${baseURL}/users/testuser1`,
    }) || fail("login failed");
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:26,代码来源:k6-tests.ts


示例6: httpTest6

function httpTest6() {
	const params = {
        cookies: { my_cookie: "value" },
        headers: { "X-MyHeader": "k6test" },
        redirects: 5,
		tags: { k6test: "yes" }
	};
    http.get("https://loadimpact.com", params);
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:9,代码来源:k6-tests.ts


示例7: httpTest8

function httpTest8() {
    // Passing username and password as part of URL plus the auth option will authenticate using HTTP Digest authentication
    const res = http.get("http://user:[email protected]/digest-auth/auth/user/passwd", {auth: "digest"});

    // Verify response
    check(res, {
        "status is 200": (r) => r.status === 200,
        "is authenticated": (r) => r.json().authenticated === true,
        "is correct user": (r) => r.json().user === "user"
    });
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:11,代码来源:k6-tests.ts


示例8: httpTest9

function httpTest9() {
	const res = http.get("https://loadimpact.com");
	for (const p in res.headers) {
		if (res.headers.hasOwnProperty(p)) {
			console.log(`${p} : ${res.headers[p]}`);
		}
	}
  check(res, {
    "status is 200": (r) => r.status === 200,
    "caption is correct": (r) => r.html("h1").text() === "Example Domain",
  });
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:12,代码来源:k6-tests.ts


示例9: test6

function test6() {
    http.get("https://loadimpact.com");
    sleep(Math.random() * 30);
    http.get("https://loadimpact.com/features");
}
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:5,代码来源:k6-tests.ts



注:本文中的k6/http.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript kafka-node.Consumer类代码示例发布时间:2022-05-25
下一篇:
TypeScript k6.check函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap