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


TypeScript request.jar函數代碼示例

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


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

示例1: send

    send(httpRequest: HttpRequest): Promise<HttpResponse> {
        let options = {
            url: httpRequest.url,
            headers: httpRequest.headers,
            method: httpRequest.method,
            body: httpRequest.body,
            time: true,
            timeout: this._settings.timeoutInMilliseconds,
            proxy: this._settings.proxy,
            strictSSL: this._settings.proxy && this._settings.proxy.length > 0 ? this._settings.proxyStrictSSL : false,
            gzip: true,
            followRedirect: this._settings.followRedirect,
            jar: this._settings.rememberCookiesForSubsequentRequests ? request.jar(new fileCookieStore(PersistUtility.cookieFilePath)) : false
        };

        if (!options.headers) {
            options.headers = httpRequest.headers = {};
        }

        // add default user agent if not specified
        if (!options.headers['user-agent']) {
            options.headers['user-agent'] = this._settings.defaultUserAgent;
        }

        return new Promise<HttpResponse>((resolve, reject) => {
            request(options, function (error, response, body) {
                if (error) {
                    reject(error);
                    return;
                }

                resolve(new HttpResponse(response.statusCode, response.statusMessage, response.httpVersion, response.headers, body, response.elapsedTime));
            });
        });
    }
開發者ID:928PJY,項目名稱:vscode-restclient,代碼行數:35,代碼來源:httpClient.ts

示例2: constructor

 constructor() {
     this.cookieJar = request.jar();
     this.contactsService = new ContactsService(this.cookieJar);
     this.messageService = new MessageService(this.cookieJar);
     this.requestService = new RequestService(this.cookieJar);
     this.statusService = new StatusService(this.cookieJar);
 }
開發者ID:SwadicalRag,項目名稱:skyweb,代碼行數:7,代碼來源:skyweb.ts

示例3: 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

示例4: httpRequest

	export function httpRequest (
		method: string,
		url: string,
		options?: {
			data?: any,
			cookies?: any
		}
	) {

		// Init
		let deferred = Q.defer();

		// Setup cookies
		let jar = request.jar();
		if (options && options.cookies) {
			Object.keys(options.cookies).forEach(function (cookieKey) {
				jar.setCookie(request.cookie(cookieKey+'='+options.cookies[cookieKey]), url);
			});
		}

		// Setup request options
		let reqOptions: any = {};
		reqOptions.jar = jar;
		reqOptions.url = url;
		reqOptions.method = method;
		reqOptions.json = true;
		if (options && options.data) reqOptions.body = options.data;

		// Handler
		request(reqOptions, function (error, response, body) {
			if (error) {
				deferred.reject(error);
				return;
			}
			let cookies = {};
			(response.headers['set-cookie'] || []).forEach(function (cookieData) {
				cookieData = cookieData.substring(0, cookieData.indexOf(';'));
				cookieData = cookieData.split('=');
				cookies[cookieData[0]] = cookieData[1];
			});
			let httpResp: IHTTPResponse = {
				statusCode: response.statusCode,
				headers: response.headers,
				body: body,
				cookies: cookies
			}
			deferred.resolve(httpResp);
		});

		return deferred.promise;
	}
開發者ID:dsilva2401,項目名稱:server-seed,代碼行數:51,代碼來源:httpRequest.ts

示例5: 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

示例6: constructor

 public constructor(logger: ILogger) {
     super();
     this.logger = logger;
     this.cookieJar = Request.jar();
     this.request = Request.defaults({ jar: this.cookieJar });
 }
開發者ID:anurse,項目名稱:SignalR,代碼行數:6,代碼來源:NodeHttpClient.ts

示例7: constructor

 constructor(username: string, password: string) {
   this.username = username;
   this.password = password;
   this.cookie = request.jar();
   this.baseurl = 'https://www.opal.com.au';
 }
開發者ID:tbasse,項目名稱:opaler,代碼行數:6,代碼來源:opaler.ts


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