fixed request for newer docker
This commit is contained in:
parent
0c7cd35448
commit
144f963d8a
2
dist/dockersock.classes.dockersock.d.ts
vendored
2
dist/dockersock.classes.dockersock.d.ts
vendored
@ -22,5 +22,5 @@ export declare class Dockersock {
|
|||||||
callOnChange(cb: Function): void;
|
callOnChange(cb: Function): void;
|
||||||
getChangeObservable(): Observable<{}>;
|
getChangeObservable(): Observable<{}>;
|
||||||
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
request(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
||||||
requestStream(methodArg: any, routeArg: any, endArg?: boolean): plugins.q.Promise<{}>;
|
requestStream(methodArg: string, routeArg: string, queryArg?: string, dataArg?: {}): plugins.q.Promise<{}>;
|
||||||
}
|
}
|
||||||
|
38
dist/dockersock.classes.dockersock.js
vendored
38
dist/dockersock.classes.dockersock.js
vendored
File diff suppressed because one or more lines are too long
@ -144,7 +144,8 @@ export class Dockersock {
|
|||||||
method:methodArg,
|
method:methodArg,
|
||||||
url:this.sockPath + routeArg + suffix + queryArg,
|
url:this.sockPath + routeArg + suffix + queryArg,
|
||||||
headers:{
|
headers:{
|
||||||
"Content-Type":"application/json"
|
"Content-Type":"application/json",
|
||||||
|
"Host":"docker.sock"
|
||||||
},
|
},
|
||||||
body:jsonArg
|
body:jsonArg
|
||||||
};
|
};
|
||||||
@ -161,10 +162,28 @@ export class Dockersock {
|
|||||||
});
|
});
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
requestStream(methodArg,routeArg,endArg:boolean = true){
|
requestStream(methodArg:string,routeArg:string,queryArg:string = "", dataArg = {}){
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
if(methodArg == "POST"){
|
let jsonArg:string = JSON.stringify(dataArg);
|
||||||
let requestStream = plugins.request.post(this.sockPath + routeArg);
|
let suffix:string = "";
|
||||||
|
let options = {
|
||||||
|
method:methodArg,
|
||||||
|
url:this.sockPath + routeArg + suffix + queryArg,
|
||||||
|
headers:{
|
||||||
|
"Content-Type":"application/json",
|
||||||
|
"Host":"docker.sock"
|
||||||
|
},
|
||||||
|
body:jsonArg
|
||||||
|
};
|
||||||
|
let requestStream = plugins.request(options,(err, res, body) => {
|
||||||
|
if (!err && res.statusCode == 200) {
|
||||||
|
done.resolve();
|
||||||
|
} else {
|
||||||
|
console.log(err);
|
||||||
|
console.log(res);
|
||||||
|
done.reject(err);
|
||||||
|
};
|
||||||
|
});
|
||||||
requestStream.on("response",(response) => {
|
requestStream.on("response",(response) => {
|
||||||
if(response.statusCode == 200){
|
if(response.statusCode == 200){
|
||||||
plugins.beautylog.ok("request returned status 200, so we are good!");
|
plugins.beautylog.ok("request returned status 200, so we are good!");
|
||||||
@ -174,13 +193,10 @@ export class Dockersock {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
requestStream.on("data",(data:Buffer) => {
|
requestStream.on("data",(data:Buffer) => {
|
||||||
let status = JSON.parse(data.toString()).status;
|
let status;
|
||||||
|
status = JSON.parse(data.toString()).status;
|
||||||
plugins.beautylog.logReduced(status);
|
plugins.beautylog.logReduced(status);
|
||||||
});
|
});
|
||||||
requestStream.on("end",()=> {
|
|
||||||
done.resolve();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return done.promise;
|
return done.promise;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user