@@ -33,15 +33,17 @@ export class HttpClient {
3333 * @param data Data to send as query
3434 * @param bearer Bearer token to send
3535 * @param expect Array of status codes to expect
36+ * @param customOptions Additional request options
3637 * @return Returns a promise of HttpClientResponse
3738 */
3839 public post (
3940 path : string ,
4041 data : object ,
4142 bearer : boolean | string = false ,
42- expect : number [ ] = [ 200 , 201 , 202 , 204 ]
43+ expect : number [ ] = [ 200 , 201 , 202 , 204 ] ,
44+ customOptions ?: object
4345 ) : Promise < HttpClientResponse > {
44- const options = {
46+ let options = {
4547 method : 'POST' ,
4648 url : `${ this . url } :${ this . port } ${ path } ` ,
4749 body : data ,
@@ -56,6 +58,10 @@ export class HttpClient {
5658 options [ 'headers' ] = this . headers ;
5759 }
5860
61+ if ( customOptions ) {
62+ options = Object . assign ( options , options ) ;
63+ }
64+
5965 return new Promise < HttpClientResponse > ( ( accept , reject ) => {
6066 this . request ( options , ( error , response , body ) => {
6167 if ( error ) {
@@ -82,16 +88,18 @@ export class HttpClient {
8288 * @param data Data to send as query
8389 * @param bearer Bearer token to send
8490 * @param expect Array of status codes to expect
91+ * @param customOptions Additional request options
8592 * @return Returns a promise of HttpClientResponse
8693 */
8794 public get (
8895 path : string ,
8996 data : boolean | Object = false ,
9097 bearer : boolean | string = false ,
91- expect : number [ ] = [ 200 , 202 ]
98+ expect : number [ ] = [ 200 , 202 ] ,
99+ customOptions ?: object
92100 ) : Promise < HttpClientResponse > {
93101 return new Promise < HttpClientResponse > ( ( accept , reject ) => {
94- const options = {
102+ let options = {
95103 method : 'GET' ,
96104 url : `${ this . url } :${ this . port } ${ path } ` ,
97105 json : true ,
@@ -106,6 +114,10 @@ export class HttpClient {
106114 options [ 'headers' ] = this . headers ;
107115 }
108116
117+ if ( customOptions ) {
118+ options = Object . assign ( options , options ) ;
119+ }
120+
109121 this . request ( options , ( error , response , body ) => {
110122 if ( error ) {
111123 reject ( new HttpClientResponse ( response , error ) ) ;
@@ -131,15 +143,17 @@ export class HttpClient {
131143 * @param data Data to send as query
132144 * @param bearer Bearer token to send
133145 * @param expect Array of status codes to expect
146+ * @param customOptions Additional request options
134147 * @return Returns a promise of HttpClientResponse
135148 */
136149 public patch (
137150 path : string ,
138151 data : object ,
139152 bearer : boolean | string = false ,
140- expect : number [ ] = [ 200 , 201 , 202 , 204 ]
153+ expect : number [ ] = [ 200 , 201 , 202 , 204 ] ,
154+ customOptions ?: object
141155 ) : Promise < HttpClientResponse > {
142- const options = {
156+ let options = {
143157 method : 'PATCH' ,
144158 url : `${ this . url } :${ this . port } ${ path } ` ,
145159 body : data ,
@@ -154,6 +168,10 @@ export class HttpClient {
154168 options [ 'headers' ] = this . headers ;
155169 }
156170
171+ if ( customOptions ) {
172+ options = Object . assign ( options , options ) ;
173+ }
174+
157175 return new Promise < HttpClientResponse > ( ( accept , reject ) => {
158176 this . request ( options , ( error , response , body ) => {
159177 if ( error ) {
@@ -180,15 +198,17 @@ export class HttpClient {
180198 * @param data Data to send as query
181199 * @param bearer Bearer token to send
182200 * @param expect Array of status codes to expect
201+ * @param customOptions Additional request options
183202 * @return Returns a promise of HttpClientResponse
184203 */
185204 public delete (
186205 path : string ,
187206 bearer : boolean | string = false ,
188- expect : number [ ] = [ 200 , 202 , 204 ]
207+ expect : number [ ] = [ 200 , 202 , 204 ] ,
208+ customOptions ?: object
189209 ) : Promise < HttpClientResponse > {
190210 return new Promise < HttpClientResponse > ( ( accept , reject ) => {
191- const options = {
211+ let options = {
192212 method : 'DELETE' ,
193213 url : `${ this . url } :${ this . port } ${ path } `
194214 } ;
@@ -201,6 +221,10 @@ export class HttpClient {
201221 options [ 'headers' ] = this . headers ;
202222 }
203223
224+ if ( customOptions ) {
225+ options = Object . assign ( options , options ) ;
226+ }
227+
204228 this . request ( options , ( error , response , body ) => {
205229 if ( error ) {
206230 reject ( new HttpClientResponse ( response , error ) ) ;
0 commit comments