當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript request.cookie函數代碼示例

本文整理匯總了TypeScript中request.cookie函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript cookie函數的具體用法?TypeScript cookie怎麽用?TypeScript cookie使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了cookie函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

	fs.readFile("cookies.json", {encoding: "utf8"}, function(err, data: string) {
		var steamCookies: string[] = JSON.parse(data);
		var j = requester.jar();
		j.setCookie(requester.cookie(steamCookies[0]), "http://steamcommunity.com");
		j.setCookie(requester.cookie(steamCookies[1]), "http://steamcommunity.com");
		requester.post({url: "http://steamcommunity.com/actions/GroupInvite", jar: j, form: {
			"type": "groupInvite",
			"inviter": "76561198126817377", // Bot's SteamID
			"invitee": invitee,
			"group": DogeTipGroupID, // Dogecoin group
			"sessionID": (/sessionid=(.*)/).exec(steamCookies[0])[1]
		}});
	});
開發者ID:hilmysyarif,項目名稱:GamersSteamTipBot,代碼行數:13,代碼來源:tf2logparser.ts

示例2: it

      it('Should support implementing custom authentication logic', async () => {
        const router = new Router('');
        router.get({ path: '/', validate: false }, async (req, res) => res.ok({ content: 'ok' }));

        const authenticate: AuthenticationHandler<Storage> = async (req, sessionStorage, t) => {
          if (req.headers.authorization) {
            const user = { id: '42' };
            sessionStorage.set({ value: user, expires: Date.now() + sessionDurationMs });
            return t.authenticated({ credentials: user });
          } else {
            return t.rejected(Boom.unauthorized());
          }
        };

        const { http } = await root.setup();
        http.registerAuth(authenticate, cookieOptions);
        http.registerRouter(router);
        await root.start();

        const response = await kbnTestServer.request.get(root, '/').expect(200, { content: 'ok' });

        expect(response.header['set-cookie']).toBeDefined();
        const cookies = response.header['set-cookie'];
        expect(cookies).toHaveLength(1);

        const sessionCookie = request.cookie(cookies[0]);
        if (!sessionCookie) {
          throw new Error('session cookie expected to be defined');
        }
        expect(sessionCookie).toBeDefined();
        expect(sessionCookie.key).toBe('sid');
        expect(sessionCookie.value).toBeDefined();
        expect(sessionCookie.path).toBe('/');
        expect(sessionCookie.httpOnly).toBe(true);
      });
開發者ID:elastic,項目名稱:kibana,代碼行數:35,代碼來源:http_service.test.ts

示例3: retrieveSessionCookie

function retrieveSessionCookie(cookies: string) {
  const sessionCookie = request.cookie(cookies);
  if (!sessionCookie) {
    throw new Error('session cookie expected to be defined');
  }
  return sessionCookie;
}
開發者ID:elastic,項目名稱:kibana,代碼行數:7,代碼來源:cookie_sesson_storage.test.ts

示例4: botWebLogOn

	botWebLogOn(function(steamCookies: string[]): void {
		var j = requester.jar();
		j.setCookie(requester.cookie(steamCookies[0]), "http://steamcommunity.com");
		j.setCookie(requester.cookie(steamCookies[1]), "http://steamcommunity.com");
		requester.post({url: "http://steamcommunity.com/actions/GroupInvite", jar: j, form: {
			"type": "groupInvite",
			"inviter": bot.steamID,
			"invitee": invitee,
			"group": GamersTipGroupID, // Gamerscoin group
			"sessionID": (/sessionid=(.*)/).exec(steamCookies[0])[1]
		}}, function (err, httpResponse, body) {
			Collections.Errors.insert({
				"timestamp": Date.now(),
				"time": new Date().toString(),
				"type": "Invite Response",
				"info": {
					err: err,
					httpResponse: httpResponse,
					body: body
				}
			}, {w:0}, undefined);
		});
	});
開發者ID:hilmysyarif,項目名稱:GamersSteamTipBot,代碼行數:23,代碼來源:bot.ts

示例5: it

      it('Should support implementing custom authentication logic', async () => {
        const response = await kbnTestServer.request
          .get(root, authUrl.auth)
          .expect(200, { content: 'ok' });

        expect(response.header['set-cookie']).toBeDefined();
        const cookies = response.header['set-cookie'];
        expect(cookies).toHaveLength(1);

        const sessionCookie = request.cookie(cookies[0]);
        if (!sessionCookie) {
          throw new Error('session cookie expected to be defined');
        }
        expect(sessionCookie).toBeDefined();
        expect(sessionCookie.key).toBe('sid');
        expect(sessionCookie.value).toBeDefined();
        expect(sessionCookie.path).toBe('/');
        expect(sessionCookie.httpOnly).toBe(true);
      });
開發者ID:simianhacker,項目名稱:kibana,代碼行數:19,代碼來源:http_service.test.ts

示例6:

			Object.keys(options.cookies).forEach(function (cookieKey) {
				jar.setCookie(request.cookie(cookieKey+'='+options.cookies[cookieKey]), url);
			});
開發者ID:dsilva2401,項目名稱:server-seed,代碼行數:3,代碼來源:httpRequest.ts


注:本文中的request.cookie函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。