本文整理匯總了TypeScript中urllib.request函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript request函數的具體用法?TypeScript request怎麽用?TypeScript request使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了request函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Error
}).then(() => {
// ask mgmNode to watch the file and upload when complete
let url = 'http://' + host.address + ':' + host.port + '/saveOar/' + region.uuid + '/' + job.id;
return urllib.request(url).then((body) => {
let result = JSON.parse(body.data);
if (!result.Success) {
throw new Error(result.Message);
}
});
});
示例2: KillRegion
export function KillRegion(r: IRegion, h: IHost): Promise<void> {
console.log('killing ' + r.uuid);
let url = 'http://' + h.address + ':' + h.port + '/kill/' + r.uuid;
return urllib.request(url).then((body) => {
let result = JSON.parse(body.data);
if (!result.Success) {
throw new Error(result.Message);
}
});
}
示例3: StartRegion
export function StartRegion(r: IRegion, h: IHost, conf: Config): Promise<void> {
console.log('starting ' + r.uuid);
let form = formstream();
form.field('xml', RegionXML(r, h));
form.field('ini', RegionINI(r, h, conf));
let url = 'http://' + h.address + ':' + h.port + '/start/' + r.uuid;
return urllib.request(url, {
method: 'POST',
headers: form.headers(),
stream: form
}).then((body) => {
let result = JSON.parse(body.data);
if (!result.Success) {
throw new Error(result.Message);
}
});
}
示例4: LoadOar
export function LoadOar(r: IRegion, h: IHost, j: IJob, u: IUser, oarPath?: string): Promise<void> {
console.log('triggering oar load for ' + r.uuid);
let admin: RemoteAdmin
let form = formstream();
switch (j.type) {
case 'nuke':
form.file('oarFile', oarPath, r.name + '.oar');
break;
default:
let datum = JSON.parse(j.data);
form.file('oarFile', datum.File, r.name + '.oar');
break;
}
form.field('jobID', j.id);
let url = 'http://' + h.address + ':' + h.port + '/loadOar/' + r.uuid + '/';
return urllib.request(url, {
method: 'POST',
headers: form.headers(),
stream: form
}).then((body) => {
let result = JSON.parse(body.data);
if (!result.Success) {
throw new Error(result.Message);
}
}).then(() => {
return HalcyonJWT.instance().GetAdminToken(u);
}).then((token: string) => {
admin = new RemoteAdmin(r);
return admin.login(token);
}).then(() => {
return admin.loadOar(r);
}).then(() => {
return admin.logout();
})
}
示例5: PutRegionOnHost
export function PutRegionOnHost(store: Store, r: IRegion, h: IHost): Promise<void> {
return urllib.request('http://' + h.address + ':' + h.port + '/add/' + r.uuid + '/' + r.name, { timeout: 10000 });
}
示例6: RemoveRegionFromHost
export function RemoveRegionFromHost(r: IRegion, h: IHost): Promise<void> {
return urllib.request('http://' + h.address + ':' + h.port + '/remove/' + r.uuid);
}