@actions/http-client 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,51 +0,0 @@
1
- name: http-tests
2
- on:
3
- push:
4
- branches:
5
- - main
6
- paths-ignore:
7
- - '**.md'
8
- pull_request:
9
- paths-ignore:
10
- - '**.md'
11
-
12
- jobs:
13
-
14
- build:
15
- name: Build
16
-
17
- strategy:
18
- matrix:
19
- runs-on: [ubuntu-latest, macOS-latest, windows-latest]
20
- node-version: [12.x]
21
- fail-fast: false
22
-
23
- runs-on: ${{ matrix.runs-on }}
24
-
25
- steps:
26
- - name: Checkout
27
- uses: actions/checkout@v2
28
-
29
- - name: Setup node
30
- uses: actions/setup-node@v1
31
- with:
32
- node-version: ${{ matrix.node-version }}
33
-
34
- - name: npm install
35
- run: npm install
36
-
37
- - name: Compile
38
- run: npm run build
39
-
40
- - name: npm test
41
- run: npm test
42
-
43
- - name: Format
44
- shell: bash
45
- run: npm run format-check
46
- if: matrix.runs-on == 'ubuntu-latest'
47
-
48
- - name: audit security
49
- continue-on-error: true
50
- run: npm audit --audit-level=moderate
51
- if: matrix.runs-on == 'ubuntu-latest'
package/.prettierignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules/
2
- _out
package/.prettierrc.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "printWidth": 80,
3
- "tabWidth": 2,
4
- "useTabs": false,
5
- "semi": false,
6
- "singleQuote": true,
7
- "trailingComma": "none",
8
- "bracketSpacing": false,
9
- "arrowParens": "avoid",
10
- "parser": "typescript"
11
- }
@@ -1,61 +0,0 @@
1
- import * as httpm from '../_out'
2
- import * as am from '../_out/auth'
3
-
4
- describe('auth', () => {
5
- beforeEach(() => {})
6
-
7
- afterEach(() => {})
8
-
9
- it('does basic http get request with basic auth', async () => {
10
- let bh: am.BasicCredentialHandler = new am.BasicCredentialHandler(
11
- 'johndoe',
12
- 'password'
13
- )
14
- let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [bh])
15
- let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
16
- expect(res.message.statusCode).toBe(200)
17
- let body: string = await res.readBody()
18
- let obj: any = JSON.parse(body)
19
- let auth: string = obj.headers.Authorization
20
- let creds: string = Buffer.from(
21
- auth.substring('Basic '.length),
22
- 'base64'
23
- ).toString()
24
- expect(creds).toBe('johndoe:password')
25
- expect(obj.url).toBe('http://httpbin.org/get')
26
- })
27
-
28
- it('does basic http get request with pat token auth', async () => {
29
- let token: string = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
30
- let ph: am.PersonalAccessTokenCredentialHandler = new am.PersonalAccessTokenCredentialHandler(
31
- token
32
- )
33
-
34
- let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [ph])
35
- let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
36
- expect(res.message.statusCode).toBe(200)
37
- let body: string = await res.readBody()
38
- let obj: any = JSON.parse(body)
39
- let auth: string = obj.headers.Authorization
40
- let creds: string = Buffer.from(
41
- auth.substring('Basic '.length),
42
- 'base64'
43
- ).toString()
44
- expect(creds).toBe('PAT:' + token)
45
- expect(obj.url).toBe('http://httpbin.org/get')
46
- })
47
-
48
- it('does basic http get request with pat token auth', async () => {
49
- let token: string = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
50
- let ph: am.BearerCredentialHandler = new am.BearerCredentialHandler(token)
51
-
52
- let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [ph])
53
- let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
54
- expect(res.message.statusCode).toBe(200)
55
- let body: string = await res.readBody()
56
- let obj: any = JSON.parse(body)
57
- let auth: string = obj.headers.Authorization
58
- expect(auth).toBe('Bearer ' + token)
59
- expect(obj.url).toBe('http://httpbin.org/get')
60
- })
61
- })
@@ -1,375 +0,0 @@
1
- import * as httpm from '../_out'
2
- import * as ifm from '../_out/interfaces'
3
- import * as path from 'path'
4
- import * as fs from 'fs'
5
-
6
- let sampleFilePath: string = path.join(__dirname, 'testoutput.txt')
7
-
8
- interface HttpBinData {
9
- url: string
10
- data: any
11
- json: any
12
- headers: any
13
- args?: any
14
- }
15
-
16
- describe('basics', () => {
17
- let _http: httpm.HttpClient
18
-
19
- beforeEach(() => {
20
- _http = new httpm.HttpClient('http-client-tests')
21
- })
22
-
23
- afterEach(() => {})
24
-
25
- it('constructs', () => {
26
- let http: httpm.HttpClient = new httpm.HttpClient('thttp-client-tests')
27
- expect(http).toBeDefined()
28
- })
29
-
30
- // responses from httpbin return something like:
31
- // {
32
- // "args": {},
33
- // "headers": {
34
- // "Connection": "close",
35
- // "Host": "httpbin.org",
36
- // "User-Agent": "typed-test-client-tests"
37
- // },
38
- // "origin": "173.95.152.44",
39
- // "url": "https://httpbin.org/get"
40
- // }
41
-
42
- it('does basic http get request', async done => {
43
- let res: httpm.HttpClientResponse = await _http.get(
44
- 'http://httpbin.org/get'
45
- )
46
- expect(res.message.statusCode).toBe(200)
47
- let body: string = await res.readBody()
48
- let obj: any = JSON.parse(body)
49
- expect(obj.url).toBe('http://httpbin.org/get')
50
- expect(obj.headers['User-Agent']).toBeTruthy()
51
- done()
52
- })
53
-
54
- it('does basic http get request with no user agent', async done => {
55
- let http: httpm.HttpClient = new httpm.HttpClient()
56
- let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
57
- expect(res.message.statusCode).toBe(200)
58
- let body: string = await res.readBody()
59
- let obj: any = JSON.parse(body)
60
- expect(obj.url).toBe('http://httpbin.org/get')
61
- expect(obj.headers['User-Agent']).toBeFalsy()
62
- done()
63
- })
64
-
65
- it('does basic https get request', async done => {
66
- let res: httpm.HttpClientResponse = await _http.get(
67
- 'https://httpbin.org/get'
68
- )
69
- expect(res.message.statusCode).toBe(200)
70
- let body: string = await res.readBody()
71
- let obj: any = JSON.parse(body)
72
- expect(obj.url).toBe('https://httpbin.org/get')
73
- done()
74
- })
75
-
76
- it('does basic http get request with default headers', async done => {
77
- let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [], {
78
- headers: {
79
- Accept: 'application/json',
80
- 'Content-Type': 'application/json'
81
- }
82
- })
83
- let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
84
- expect(res.message.statusCode).toBe(200)
85
- let body: string = await res.readBody()
86
- let obj: any = JSON.parse(body)
87
- expect(obj.headers.Accept).toBe('application/json')
88
- expect(obj.headers['Content-Type']).toBe('application/json')
89
- expect(obj.url).toBe('http://httpbin.org/get')
90
- done()
91
- })
92
-
93
- it('does basic http get request with merged headers', async done => {
94
- let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [], {
95
- headers: {
96
- Accept: 'application/json',
97
- 'Content-Type': 'application/json'
98
- }
99
- })
100
- let res: httpm.HttpClientResponse = await http.get(
101
- 'http://httpbin.org/get',
102
- {
103
- 'content-type': 'application/x-www-form-urlencoded'
104
- }
105
- )
106
- expect(res.message.statusCode).toBe(200)
107
- let body: string = await res.readBody()
108
- let obj: any = JSON.parse(body)
109
- expect(obj.headers.Accept).toBe('application/json')
110
- expect(obj.headers['Content-Type']).toBe(
111
- 'application/x-www-form-urlencoded'
112
- )
113
- expect(obj.url).toBe('http://httpbin.org/get')
114
- done()
115
- })
116
-
117
- it('pipes a get request', () => {
118
- return new Promise<string>(async (resolve, reject) => {
119
- let file: NodeJS.WritableStream = fs.createWriteStream(sampleFilePath)
120
- ;(await _http.get('https://httpbin.org/get')).message
121
- .pipe(file)
122
- .on('close', () => {
123
- let body: string = fs.readFileSync(sampleFilePath).toString()
124
- let obj: any = JSON.parse(body)
125
- expect(obj.url).toBe('https://httpbin.org/get')
126
- resolve()
127
- })
128
- })
129
- })
130
-
131
- it.skip('does basic get request with redirects', async done => {
132
- let res: httpm.HttpClientResponse = await _http.get(
133
- 'https://httpbin.org/redirect-to?url=' +
134
- encodeURIComponent('https://httpbin.org/get')
135
- )
136
- expect(res.message.statusCode).toBe(200)
137
- let body: string = await res.readBody()
138
- let obj: any = JSON.parse(body)
139
- expect(obj.url).toBe('https://httpbin.org/get')
140
- done()
141
- })
142
-
143
- it.skip('does basic get request with redirects (303)', async done => {
144
- let res: httpm.HttpClientResponse = await _http.get(
145
- 'https://httpbin.org/redirect-to?url=' +
146
- encodeURIComponent('https://httpbin.org/get') +
147
- '&status_code=303'
148
- )
149
- expect(res.message.statusCode).toBe(200)
150
- let body: string = await res.readBody()
151
- let obj: any = JSON.parse(body)
152
- expect(obj.url).toBe('https://httpbin.org/get')
153
- done()
154
- })
155
-
156
- it('returns 404 for not found get request on redirect', async done => {
157
- let res: httpm.HttpClientResponse = await _http.get(
158
- 'https://httpbin.org/redirect-to?url=' +
159
- encodeURIComponent('https://httpbin.org/status/404') +
160
- '&status_code=303'
161
- )
162
- expect(res.message.statusCode).toBe(404)
163
- let body: string = await res.readBody()
164
- done()
165
- })
166
-
167
- it.skip('does not follow redirects if disabled', async done => {
168
- let http: httpm.HttpClient = new httpm.HttpClient(
169
- 'typed-test-client-tests',
170
- null,
171
- {allowRedirects: false}
172
- )
173
- let res: httpm.HttpClientResponse = await http.get(
174
- 'https://httpbin.org/redirect-to?url=' +
175
- encodeURIComponent('https://httpbin.org/get')
176
- )
177
- expect(res.message.statusCode).toBe(302)
178
- let body: string = await res.readBody()
179
- done()
180
- })
181
-
182
- it.skip('does not pass auth with diff hostname redirects', async done => {
183
- let headers = {
184
- accept: 'application/json',
185
- authorization: 'shhh'
186
- }
187
- let res: httpm.HttpClientResponse = await _http.get(
188
- 'https://httpbin.org/redirect-to?url=' +
189
- encodeURIComponent('https://www.httpbin.org/get'),
190
- headers
191
- )
192
-
193
- expect(res.message.statusCode).toBe(200)
194
- let body: string = await res.readBody()
195
- let obj: any = JSON.parse(body)
196
- // httpbin "fixes" the casing
197
- expect(obj.headers['Accept']).toBe('application/json')
198
- expect(obj.headers['Authorization']).toBeUndefined()
199
- expect(obj.headers['authorization']).toBeUndefined()
200
- expect(obj.url).toBe('https://www.httpbin.org/get')
201
-
202
- done()
203
- })
204
-
205
- it.skip('does not pass Auth with diff hostname redirects', async done => {
206
- let headers = {
207
- Accept: 'application/json',
208
- Authorization: 'shhh'
209
- }
210
- let res: httpm.HttpClientResponse = await _http.get(
211
- 'https://httpbin.org/redirect-to?url=' +
212
- encodeURIComponent('https://www.httpbin.org/get'),
213
- headers
214
- )
215
-
216
- expect(res.message.statusCode).toBe(200)
217
- let body: string = await res.readBody()
218
- let obj: any = JSON.parse(body)
219
- // httpbin "fixes" the casing
220
- expect(obj.headers['Accept']).toBe('application/json')
221
- expect(obj.headers['Authorization']).toBeUndefined()
222
- expect(obj.headers['authorization']).toBeUndefined()
223
- expect(obj.url).toBe('https://www.httpbin.org/get')
224
-
225
- done()
226
- })
227
-
228
- it('does basic head request', async done => {
229
- let res: httpm.HttpClientResponse = await _http.head(
230
- 'http://httpbin.org/get'
231
- )
232
- expect(res.message.statusCode).toBe(200)
233
- done()
234
- })
235
-
236
- it('does basic http delete request', async done => {
237
- let res: httpm.HttpClientResponse = await _http.del(
238
- 'http://httpbin.org/delete'
239
- )
240
- expect(res.message.statusCode).toBe(200)
241
- let body: string = await res.readBody()
242
- let obj: any = JSON.parse(body)
243
- done()
244
- })
245
-
246
- it('does basic http post request', async done => {
247
- let b: string = 'Hello World!'
248
- let res: httpm.HttpClientResponse = await _http.post(
249
- 'http://httpbin.org/post',
250
- b
251
- )
252
- expect(res.message.statusCode).toBe(200)
253
- let body: string = await res.readBody()
254
- let obj: any = JSON.parse(body)
255
- expect(obj.data).toBe(b)
256
- expect(obj.url).toBe('http://httpbin.org/post')
257
- done()
258
- })
259
-
260
- it('does basic http patch request', async done => {
261
- let b: string = 'Hello World!'
262
- let res: httpm.HttpClientResponse = await _http.patch(
263
- 'http://httpbin.org/patch',
264
- b
265
- )
266
- expect(res.message.statusCode).toBe(200)
267
- let body: string = await res.readBody()
268
- let obj: any = JSON.parse(body)
269
- expect(obj.data).toBe(b)
270
- expect(obj.url).toBe('http://httpbin.org/patch')
271
- done()
272
- })
273
-
274
- it('does basic http options request', async done => {
275
- let res: httpm.HttpClientResponse = await _http.options(
276
- 'http://httpbin.org'
277
- )
278
- expect(res.message.statusCode).toBe(200)
279
- let body: string = await res.readBody()
280
- done()
281
- })
282
-
283
- it('returns 404 for not found get request', async done => {
284
- let res: httpm.HttpClientResponse = await _http.get(
285
- 'http://httpbin.org/status/404'
286
- )
287
- expect(res.message.statusCode).toBe(404)
288
- let body: string = await res.readBody()
289
- done()
290
- })
291
-
292
- it('gets a json object', async () => {
293
- let jsonObj: ifm.ITypedResponse<HttpBinData> = await _http.getJson<
294
- HttpBinData
295
- >('https://httpbin.org/get')
296
- expect(jsonObj.statusCode).toBe(200)
297
- expect(jsonObj.result).toBeDefined()
298
- expect(jsonObj.result.url).toBe('https://httpbin.org/get')
299
- expect(jsonObj.result.headers['Accept']).toBe(
300
- httpm.MediaTypes.ApplicationJson
301
- )
302
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
303
- httpm.MediaTypes.ApplicationJson
304
- )
305
- })
306
-
307
- it('getting a non existent json object returns null', async () => {
308
- let jsonObj: ifm.ITypedResponse<HttpBinData> = await _http.getJson<
309
- HttpBinData
310
- >('https://httpbin.org/status/404')
311
- expect(jsonObj.statusCode).toBe(404)
312
- expect(jsonObj.result).toBeNull()
313
- })
314
-
315
- it('posts a json object', async () => {
316
- let res: any = {name: 'foo'}
317
- let restRes: ifm.ITypedResponse<HttpBinData> = await _http.postJson<
318
- HttpBinData
319
- >('https://httpbin.org/post', res)
320
- expect(restRes.statusCode).toBe(200)
321
- expect(restRes.result).toBeDefined()
322
- expect(restRes.result.url).toBe('https://httpbin.org/post')
323
- expect(restRes.result.json.name).toBe('foo')
324
- expect(restRes.result.headers['Accept']).toBe(
325
- httpm.MediaTypes.ApplicationJson
326
- )
327
- expect(restRes.result.headers['Content-Type']).toBe(
328
- httpm.MediaTypes.ApplicationJson
329
- )
330
- expect(restRes.headers[httpm.Headers.ContentType]).toBe(
331
- httpm.MediaTypes.ApplicationJson
332
- )
333
- })
334
-
335
- it('puts a json object', async () => {
336
- let res: any = {name: 'foo'}
337
- let restRes: ifm.ITypedResponse<HttpBinData> = await _http.putJson<
338
- HttpBinData
339
- >('https://httpbin.org/put', res)
340
- expect(restRes.statusCode).toBe(200)
341
- expect(restRes.result).toBeDefined()
342
- expect(restRes.result.url).toBe('https://httpbin.org/put')
343
- expect(restRes.result.json.name).toBe('foo')
344
-
345
- expect(restRes.result.headers['Accept']).toBe(
346
- httpm.MediaTypes.ApplicationJson
347
- )
348
- expect(restRes.result.headers['Content-Type']).toBe(
349
- httpm.MediaTypes.ApplicationJson
350
- )
351
- expect(restRes.headers[httpm.Headers.ContentType]).toBe(
352
- httpm.MediaTypes.ApplicationJson
353
- )
354
- })
355
-
356
- it('patch a json object', async () => {
357
- let res: any = {name: 'foo'}
358
- let restRes: ifm.ITypedResponse<HttpBinData> = await _http.patchJson<
359
- HttpBinData
360
- >('https://httpbin.org/patch', res)
361
- expect(restRes.statusCode).toBe(200)
362
- expect(restRes.result).toBeDefined()
363
- expect(restRes.result.url).toBe('https://httpbin.org/patch')
364
- expect(restRes.result.json.name).toBe('foo')
365
- expect(restRes.result.headers['Accept']).toBe(
366
- httpm.MediaTypes.ApplicationJson
367
- )
368
- expect(restRes.result.headers['Content-Type']).toBe(
369
- httpm.MediaTypes.ApplicationJson
370
- )
371
- expect(restRes.headers[httpm.Headers.ContentType]).toBe(
372
- httpm.MediaTypes.ApplicationJson
373
- )
374
- })
375
- })
@@ -1,115 +0,0 @@
1
- import * as httpm from '../_out'
2
- import * as ifm from '../_out/interfaces'
3
-
4
- describe('headers', () => {
5
- let _http: httpm.HttpClient
6
-
7
- beforeEach(() => {
8
- _http = new httpm.HttpClient('http-client-tests')
9
- })
10
-
11
- it('preserves existing headers on getJson', async () => {
12
- let additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
13
- let jsonObj: ifm.ITypedResponse<any> = await _http.getJson<any>(
14
- 'https://httpbin.org/get',
15
- additionalHeaders
16
- )
17
- expect(jsonObj.result.headers['Accept']).toBe('foo')
18
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
19
- httpm.MediaTypes.ApplicationJson
20
- )
21
-
22
- let httpWithHeaders = new httpm.HttpClient()
23
- httpWithHeaders.requestOptions = {
24
- headers: {
25
- [httpm.Headers.Accept]: 'baz'
26
- }
27
- }
28
- jsonObj = await httpWithHeaders.getJson<any>('https://httpbin.org/get')
29
- expect(jsonObj.result.headers['Accept']).toBe('baz')
30
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
31
- httpm.MediaTypes.ApplicationJson
32
- )
33
- })
34
-
35
- it('preserves existing headers on postJson', async () => {
36
- let additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
37
- let jsonObj: ifm.ITypedResponse<any> = await _http.postJson<any>(
38
- 'https://httpbin.org/post',
39
- {},
40
- additionalHeaders
41
- )
42
- expect(jsonObj.result.headers['Accept']).toBe('foo')
43
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
44
- httpm.MediaTypes.ApplicationJson
45
- )
46
-
47
- let httpWithHeaders = new httpm.HttpClient()
48
- httpWithHeaders.requestOptions = {
49
- headers: {
50
- [httpm.Headers.Accept]: 'baz'
51
- }
52
- }
53
- jsonObj = await httpWithHeaders.postJson<any>(
54
- 'https://httpbin.org/post',
55
- {}
56
- )
57
- expect(jsonObj.result.headers['Accept']).toBe('baz')
58
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
59
- httpm.MediaTypes.ApplicationJson
60
- )
61
- })
62
-
63
- it('preserves existing headers on putJson', async () => {
64
- let additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
65
- let jsonObj: ifm.ITypedResponse<any> = await _http.putJson<any>(
66
- 'https://httpbin.org/put',
67
- {},
68
- additionalHeaders
69
- )
70
- expect(jsonObj.result.headers['Accept']).toBe('foo')
71
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
72
- httpm.MediaTypes.ApplicationJson
73
- )
74
-
75
- let httpWithHeaders = new httpm.HttpClient()
76
- httpWithHeaders.requestOptions = {
77
- headers: {
78
- [httpm.Headers.Accept]: 'baz'
79
- }
80
- }
81
- jsonObj = await httpWithHeaders.putJson<any>('https://httpbin.org/put', {})
82
- expect(jsonObj.result.headers['Accept']).toBe('baz')
83
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
84
- httpm.MediaTypes.ApplicationJson
85
- )
86
- })
87
-
88
- it('preserves existing headers on patchJson', async () => {
89
- let additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
90
- let jsonObj: ifm.ITypedResponse<any> = await _http.patchJson<any>(
91
- 'https://httpbin.org/patch',
92
- {},
93
- additionalHeaders
94
- )
95
- expect(jsonObj.result.headers['Accept']).toBe('foo')
96
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
97
- httpm.MediaTypes.ApplicationJson
98
- )
99
-
100
- let httpWithHeaders = new httpm.HttpClient()
101
- httpWithHeaders.requestOptions = {
102
- headers: {
103
- [httpm.Headers.Accept]: 'baz'
104
- }
105
- }
106
- jsonObj = await httpWithHeaders.patchJson<any>(
107
- 'https://httpbin.org/patch',
108
- {}
109
- )
110
- expect(jsonObj.result.headers['Accept']).toBe('baz')
111
- expect(jsonObj.headers[httpm.Headers.ContentType]).toBe(
112
- httpm.MediaTypes.ApplicationJson
113
- )
114
- })
115
- })
@@ -1,79 +0,0 @@
1
- import * as httpm from '../_out'
2
-
3
- describe('basics', () => {
4
- let _http: httpm.HttpClient
5
-
6
- beforeEach(() => {
7
- _http = new httpm.HttpClient('http-client-tests', [], {keepAlive: true})
8
- })
9
-
10
- afterEach(() => {
11
- _http.dispose()
12
- })
13
-
14
- it('does basic http get request with keepAlive true', async done => {
15
- let res: httpm.HttpClientResponse = await _http.get(
16
- 'http://httpbin.org/get'
17
- )
18
- expect(res.message.statusCode).toBe(200)
19
- let body: string = await res.readBody()
20
- let obj: any = JSON.parse(body)
21
- expect(obj.url).toBe('http://httpbin.org/get')
22
- done()
23
- })
24
-
25
- it('does basic head request with keepAlive true', async done => {
26
- let res: httpm.HttpClientResponse = await _http.head(
27
- 'http://httpbin.org/get'
28
- )
29
- expect(res.message.statusCode).toBe(200)
30
- done()
31
- })
32
-
33
- it('does basic http delete request with keepAlive true', async done => {
34
- let res: httpm.HttpClientResponse = await _http.del(
35
- 'http://httpbin.org/delete'
36
- )
37
- expect(res.message.statusCode).toBe(200)
38
- let body: string = await res.readBody()
39
- let obj: any = JSON.parse(body)
40
- done()
41
- })
42
-
43
- it('does basic http post request with keepAlive true', async done => {
44
- let b: string = 'Hello World!'
45
- let res: httpm.HttpClientResponse = await _http.post(
46
- 'http://httpbin.org/post',
47
- b
48
- )
49
- expect(res.message.statusCode).toBe(200)
50
- let body: string = await res.readBody()
51
- let obj: any = JSON.parse(body)
52
- expect(obj.data).toBe(b)
53
- expect(obj.url).toBe('http://httpbin.org/post')
54
- done()
55
- })
56
-
57
- it('does basic http patch request with keepAlive true', async done => {
58
- let b: string = 'Hello World!'
59
- let res: httpm.HttpClientResponse = await _http.patch(
60
- 'http://httpbin.org/patch',
61
- b
62
- )
63
- expect(res.message.statusCode).toBe(200)
64
- let body: string = await res.readBody()
65
- let obj: any = JSON.parse(body)
66
- expect(obj.data).toBe(b)
67
- expect(obj.url).toBe('http://httpbin.org/patch')
68
- done()
69
- })
70
-
71
- it('does basic http options request with keepAlive true', async done => {
72
- let res: httpm.HttpClientResponse = await _http.options(
73
- 'http://httpbin.org'
74
- )
75
- expect(res.message.statusCode).toBe(200)
76
- let body: string = await res.readBody()
77
- done()
78
- })
79
- })