@gatling.io/http 0.1.0

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.
@@ -0,0 +1,521 @@
1
+ import { ActionBuilder, Body, CheckBuilder, Condition, Duration, Session } from "@gatling.io/core";
2
+ import { BodyPart } from "../bodyPart";
3
+ import { Proxy } from "../proxy";
4
+ import JvmHttpRequestActionBuilder = io.gatling.javaapi.http.HttpRequestActionBuilder;
5
+ export * from "./body";
6
+ export * from "./request";
7
+ export interface RequestWithParamsActionBuilder<T> {
8
+ /**
9
+ * Set some query parameter
10
+ *
11
+ * @param name - the name of the parameter, expressed as a Gatling Expression Language String
12
+ * @param value - the value of the parameter, expressed as a Gatling Expression Language String
13
+ * @returns a new DSL instance
14
+ */
15
+ queryParam(name: string, value: string): T;
16
+ /**
17
+ * Set some query parameter
18
+ *
19
+ * @param name - the name of the parameter, expressed as a Gatling Expression Language String
20
+ * @param value - the static value of the parameter
21
+ * @returns a new DSL instance
22
+ */
23
+ queryParam(name: string, value: any): T;
24
+ /**
25
+ * Set some query parameter
26
+ *
27
+ * @param name - the name of the parameter, expressed as a Gatling Expression Language String
28
+ * @param value - the value of the parameter, expressed as a function
29
+ * @returns a new DSL instance
30
+ */
31
+ queryParam(name: string, value: (session: Session) => any): T;
32
+ /**
33
+ * Set some query parameter
34
+ *
35
+ * @param name - the name of the parameter, expressed as a function
36
+ * @param value - the value of the parameter, expressed as a Gatling Expression Language String
37
+ * @returns a new DSL instance
38
+ */
39
+ queryParam(name: (session: Session) => string, value: string): T;
40
+ /**
41
+ * Set some query parameter
42
+ *
43
+ * @param name - the name of the parameter, expressed as a function
44
+ * @param value - the static value of the parameter
45
+ * @returns a new DSL instance
46
+ */
47
+ queryParam(name: (session: Session) => string, value: any): T;
48
+ /**
49
+ * Set some query parameter
50
+ *
51
+ * @param name - the name of the parameter, expressed as a function
52
+ * @param value - the value of the parameter, expressed as a function
53
+ * @returns a new DSL instance
54
+ */
55
+ queryParam(name: (session: Session) => string, value: (session: Session) => any): T;
56
+ /**
57
+ * Set a multivalued query parameter
58
+ *
59
+ * @param name - the name of the parameter, expressed as a Gatling Expression Language String
60
+ * @param values - the list of values of the parameter, expressed as a Gatling Expression Language
61
+ * String
62
+ * @returns a new DSL instance
63
+ */
64
+ multivaluedQueryParam(name: string, values: string): T;
65
+ /**
66
+ * Set a multivalued query parameter
67
+ *
68
+ * @param name - the name of the parameter, expressed as a Gatling Expression Language String
69
+ * @param values - the static list of values of the parameter
70
+ * @returns a new DSL instance
71
+ */
72
+ multivaluedQueryParam(name: string, values: any[]): T;
73
+ /**
74
+ * Set a multivalued query parameter
75
+ *
76
+ * @param name - the name of the parameter, expressed as a Gatling Expression Language String
77
+ * @param values - the list of values of the parameter, expressed as a function
78
+ * @returns a new DSL instance
79
+ */
80
+ multivaluedQueryParam(name: string, values: (session: Session) => any[]): T;
81
+ /**
82
+ * Set a multivalued query parameter
83
+ *
84
+ * @param name - the name of the parameter, expressed as a function
85
+ * @param values - the list of values of the parameter, expressed as a Gatling Expression Language
86
+ * String
87
+ * @returns a new DSL instance
88
+ */
89
+ multivaluedQueryParam(name: (session: Session) => string, values: string): T;
90
+ /**
91
+ * Set a multivalued query parameter
92
+ *
93
+ * @param name - the name of the parameter, expressed as a function
94
+ * @param values - the static list of values of the parameter
95
+ * @returns a new DSL instance
96
+ */
97
+ multivaluedQueryParam(name: (session: Session) => string, values: any[]): T;
98
+ /**
99
+ * Set a multivalued query parameter
100
+ *
101
+ * @param name - the name of the parameter, expressed as a function
102
+ * @param values - the list of values of the parameter, expressed as a function
103
+ * @returns a new DSL instance
104
+ */
105
+ multivaluedQueryParam(name: (session: Session) => string, values: (session: Session) => any[]): T;
106
+ /**
107
+ * Set multiple query params
108
+ *
109
+ * @param map - a static Map of query params
110
+ * @returns a new DSL instance
111
+ */
112
+ queryParamMap(map: string): T;
113
+ /**
114
+ * Set multiple query params
115
+ *
116
+ * @param map - a Map of query params, expressed as a Gatling Expression Language String
117
+ * @returns a new DSL instance
118
+ */
119
+ queryParamMap(map: Record<string, any>): T;
120
+ /**
121
+ * Set multiple query params
122
+ *
123
+ * @param map - a Map of query params, expressed as a function
124
+ * @returns a new DSL instance
125
+ */
126
+ queryParamMap(map: (session: Session) => Record<string, any>): T;
127
+ /**
128
+ * Set a header
129
+ *
130
+ * @param name - the static header name
131
+ * @param value - the header value, expressed as a Gatling Expression Language String
132
+ * @returns a new DSL instance
133
+ */
134
+ header(name: string, value: string): T;
135
+ /**
136
+ * Set a header
137
+ *
138
+ * @param name - the static header name
139
+ * @param value - the header value, expressed as a function
140
+ * @returns a new DSL instance
141
+ */
142
+ header(name: string, value: (session: Session) => string): T;
143
+ /**
144
+ * Set multiple headers
145
+ *
146
+ * @param headers - the headers, names are static but values are expressed as a Gatling Expression
147
+ * Language String
148
+ * @returns a new DSL instance
149
+ */
150
+ headers(headers: Record<string, string>): T;
151
+ /**
152
+ * Ignore common headers set in the Http protocol configuration
153
+ *
154
+ * @returns a new DSL instance
155
+ */
156
+ ignoreProtocolHeaders(): T;
157
+ /**
158
+ * Set the authorization header for Basic Auth
159
+ *
160
+ * @param username - the username, expressed as a Gatling Expression Language String
161
+ * @param password - the password, expressed as a Gatling Expression Language String
162
+ * @returns a new DSL instance
163
+ */
164
+ basicAuth(username: string, password: string): T;
165
+ /**
166
+ * Set the authorization header for Basic Auth
167
+ *
168
+ * @param username - the username, expressed as a Gatling Expression Language String
169
+ * @param password - the password, expressed as a function
170
+ * @returns a new DSL instance
171
+ */
172
+ basicAuth(username: string, password: (session: Session) => string): T;
173
+ /**
174
+ * Set the authorization header for Basic Auth
175
+ *
176
+ * @param username - the username, expressed as a function
177
+ * @param password - the password, expressed as a Gatling Expression Language String
178
+ * @returns a new DSL instance
179
+ */
180
+ basicAuth(username: (session: Session) => string, password: string): T;
181
+ /**
182
+ * Set the authorization header for Basic Auth
183
+ *
184
+ * @param username - the username, expressed as a function
185
+ * @param password - the password, expressed as a function
186
+ * @returns a new DSL instance
187
+ */
188
+ basicAuth(username: (session: Session) => string, password: (session: Session) => string): T;
189
+ /**
190
+ * Set the authorization header for Digest Auth
191
+ *
192
+ * @param username - the username, expressed as a Gatling Expression Language String
193
+ * @param password - the password, expressed as a Gatling Expression Language String
194
+ * @returns a new DSL instance
195
+ */
196
+ digestAuth(username: string, password: string): T;
197
+ /**
198
+ * Set the authorization header for Digest Auth
199
+ *
200
+ * @param username - the username, expressed as a Gatling Expression Language String
201
+ * @param password - the password, expressed as a function
202
+ * @returns a new DSL instance
203
+ */
204
+ digestAuth(username: string, password: (session: Session) => string): T;
205
+ /**
206
+ * Set the authorization header for Digest Auth
207
+ *
208
+ * @param username - the username, expressed as a function
209
+ * @param password - the password, expressed as a Gatling Expression Language String
210
+ * @returns a new DSL instance
211
+ */
212
+ digestAuth(username: (session: Session) => string, password: string): T;
213
+ /**
214
+ * Set the authorization header for Digest Auth
215
+ *
216
+ * @param username - the username, expressed as a function
217
+ * @param password - the password, expressed as a function
218
+ * @returns a new DSL instance
219
+ */
220
+ digestAuth(username: (session: Session) => string, password: (session: Session) => string): T;
221
+ /**
222
+ * Disable the automatic url encoding that tries to detect unescaped reserved chars
223
+ *
224
+ * @returns a new DSL instance
225
+ */
226
+ disableUrlEncoding(): T;
227
+ /**
228
+ * Define a Proxy to be used for this request
229
+ *
230
+ * @param proxy - the proxy
231
+ * @returns a new DSL instance
232
+ */
233
+ proxy(proxy: Proxy): T;
234
+ /**
235
+ * Instruct sign the request with OAuth1 before writing it on the wire
236
+ *
237
+ * @param consumerKey - the consumerKey, expressed as a Gatling Expression Language String
238
+ * @param clientSharedSecret - the clientSharedSecret, expressed as a Gatling Expression Language
239
+ * String
240
+ * @param token - the token, expressed as a Gatling Expression Language String
241
+ * @param tokenSecret - the tokenSecret, expressed as a Gatling Expression Language String
242
+ * @returns a new DSL instance
243
+ */
244
+ signWithOAuth1(consumerKey: string, clientSharedSecret: string, token: string, tokenSecret: string): T;
245
+ /**
246
+ * Instruct sign the request with OAuth1 before writing it on the wire
247
+ *
248
+ * @param consumerKey - the consumerKey, expressed as a function
249
+ * @param clientSharedSecret - the clientSharedSecret, expressed as a function
250
+ * @param token - the token, expressed as a function
251
+ * @param tokenSecret - the tokenSecret, expressed as a function
252
+ * @returns a new DSL instance
253
+ */
254
+ signWithOAuth1(consumerKey: (session: Session) => string, clientSharedSecret: (session: Session) => string, token: (session: Session) => string, tokenSecret: (session: Session) => string): T;
255
+ }
256
+ export interface RequestWithBodyActionBuilder<T> {
257
+ /**
258
+ * Define a request body
259
+ *
260
+ * @param body - the request body
261
+ * @returns a new HttpRequestActionBuilder instance
262
+ */
263
+ body(body: Body): T;
264
+ /**
265
+ * Set a multipart body part
266
+ *
267
+ * @param part - the part
268
+ * @returns a new HttpRequestActionBuilder instance
269
+ */
270
+ bodyPart(part: BodyPart): T;
271
+ /**
272
+ * Set multiple multipart body parts
273
+ *
274
+ * @param parts - the parts
275
+ * @returns a new HttpRequestActionBuilder instance
276
+ */
277
+ bodyParts(...parts: BodyPart[]): T;
278
+ /**
279
+ * Set the content-type header for multipart body.
280
+ *
281
+ * @returns a new HttpRequestActionBuilder instance
282
+ */
283
+ asMultipartForm(): T;
284
+ /**
285
+ * Set the content-type header for form-urlencoding body.
286
+ *
287
+ * @returns a new HttpRequestActionBuilder instance
288
+ */
289
+ asFormUrlEncoded(): T;
290
+ /**
291
+ * Set an HTML form parameter
292
+ *
293
+ * @param key - the parameter key, expressed as a Gatling Expression Language String
294
+ * @param value - the parameter value, expressed as a Gatling Expression Language String
295
+ * @returns a new HttpRequestActionBuilder instance
296
+ */
297
+ formParam(key: string, value: string): T;
298
+ /**
299
+ * Set an HTML form parameter
300
+ *
301
+ * @param key - the parameter key, expressed as a Gatling Expression Language String
302
+ * @param value - the parameter static value
303
+ * @returns a new HttpRequestActionBuilder instance
304
+ */
305
+ formParam(key: string, value: any): T;
306
+ /**
307
+ * Set an HTML form parameter
308
+ *
309
+ * @param key - the parameter key, expressed as a Gatling Expression Language String
310
+ * @param value - the parameter value, expressed as a function
311
+ * @returns a new HttpRequestActionBuilder instance
312
+ */
313
+ formParam(key: string, value: (session: Session) => any): T;
314
+ /**
315
+ * Set an HTML form parameter
316
+ *
317
+ * @param key - the parameter key, expressed as a function
318
+ * @param value - the parameter value, expressed as a Gatling Expression Language String
319
+ * @returns a new HttpRequestActionBuilder instance
320
+ */
321
+ formParam(key: (session: Session) => string, value: string): T;
322
+ /**
323
+ * Set an HTML form parameter
324
+ *
325
+ * @param key - the parameter key, expressed as a function
326
+ * @param value - the parameter static value
327
+ * @returns a new HttpRequestActionBuilder instance
328
+ */
329
+ formParam(key: (session: Session) => string, value: any): T;
330
+ /**
331
+ * Set an HTML form parameter
332
+ *
333
+ * @param key - the parameter key, expressed as a function
334
+ * @param value - the parameter value, expressed as a function
335
+ * @returns a new HttpRequestActionBuilder instance
336
+ */
337
+ formParam(key: (session: Session) => string, value: (session: Session) => any): T;
338
+ /**
339
+ * Set an HTML form multivalued parameter
340
+ *
341
+ * @param key - the parameter key, expressed as a Gatling Expression Language String
342
+ * @param values - the parameter values, as a Gatling EL string
343
+ * @returns a new HttpRequestActionBuilder instance
344
+ */
345
+ multivaluedFormParam(key: string, values: string): T;
346
+ /**
347
+ * Set an HTML form multivalued parameter
348
+ *
349
+ * @param key - the parameter key, expressed as a Gatling Expression Language String
350
+ * @param values - the static parameter values
351
+ * @returns a new HttpRequestActionBuilder instance
352
+ */
353
+ multivaluedFormParam(key: string, values: any[]): T;
354
+ /**
355
+ * Set an HTML form multivalued parameter
356
+ *
357
+ * @param key - the parameter key, expressed as a Gatling Expression Language String
358
+ * @param values - the parameter values, expressed as a function
359
+ * @returns a new HttpRequestActionBuilder instance
360
+ */
361
+ multivaluedFormParam(key: string, values: (session: Session) => any[]): T;
362
+ /**
363
+ * Set an HTML form multivalued parameter
364
+ *
365
+ * @param key - the parameter key, expressed as a function
366
+ * @param values - the static parameter values
367
+ * @returns a new HttpRequestActionBuilder instance
368
+ */
369
+ multivaluedFormParam(key: (session: Session) => string, values: any[]): T;
370
+ /**
371
+ * Set an HTML form multivalued parameter
372
+ *
373
+ * @param key - the parameter key, expressed as a function
374
+ * @param values - the parameter values, expressed as a function
375
+ * @returns a new HttpRequestActionBuilder instance
376
+ */
377
+ multivaluedFormParam(key: (session: Session) => string, values: (session: Session) => any[]): T;
378
+ /**
379
+ * Set multiple form parameters
380
+ *
381
+ * @param map - the static parameters
382
+ * @returns a new HttpRequestActionBuilder instance
383
+ */
384
+ formParamMap(map: Record<string, any>): T;
385
+ /**
386
+ * Set multiple form parameters
387
+ *
388
+ * @param map - the parameters, expressed as a function
389
+ * @returns a new HttpRequestActionBuilder instance
390
+ */
391
+ formParamMap(map: (session: Session) => Record<string, any>): T;
392
+ /**
393
+ * Set a form, typically captured from a form check
394
+ *
395
+ * @param form - the form inputs, expressed as a Gatling Expression Language String
396
+ * @returns a new HttpRequestActionBuilder instance
397
+ */
398
+ form(form: string): T;
399
+ /**
400
+ * Set a form, typically captured from a form check
401
+ *
402
+ * @param map - the form inputs, expressed as a function
403
+ * @returns a new HttpRequestActionBuilder instance
404
+ */
405
+ form(map: (session: Session) => Record<string, any>): T;
406
+ /**
407
+ * Set a form file upload
408
+ *
409
+ * @param name - the name of the file part, expressed as a Gatling Expression Language String
410
+ * @param filePath - the path of the file, either relative to the root of the classpath, or
411
+ * absolute, expressed as a Gatling Expression Language String
412
+ * @returns a new HttpRequestActionBuilder instance
413
+ */
414
+ formUpload(name: string, filePath: string): T;
415
+ /**
416
+ * Set a form file upload
417
+ *
418
+ * @param name - the name of the file part, expressed as a function
419
+ * @param filePath - the path of the file, either relative to the root of the classpath, or
420
+ * absolute, expressed as a Gatling Expression Language String
421
+ * @returns a new HttpRequestActionBuilder instance
422
+ */
423
+ formUpload(name: (session: Session) => string, filePath: string): T;
424
+ /**
425
+ * Set a form file upload
426
+ *
427
+ * @param name - the name of the file part, expressed as a Gatling Expression Language String
428
+ * @param filePath - the path of the file, either relative to the root of the classpath, or
429
+ * absolute, expressed as a function
430
+ * @returns a new HttpRequestActionBuilder instance
431
+ */
432
+ formUpload(name: string, filePath: (session: Session) => string): T;
433
+ /**
434
+ * Set a form file upload
435
+ *
436
+ * @param name - the name of the file part, expressed as a function
437
+ * @param filePath - the path of the file, either relative to the root of the classpath, or
438
+ * absolute, expressed as a function
439
+ * @returns a new HttpRequestActionBuilder instance
440
+ */
441
+ formUpload(name: (session: Session) => string, filePath: (session: Session) => string): T;
442
+ /**
443
+ * Set the content-type header for JSON
444
+ *
445
+ * @returns a new DSL instance
446
+ */
447
+ asJson(): T;
448
+ /**
449
+ * Set the content-type header for XML
450
+ *
451
+ * @returns a new DSL instance
452
+ */
453
+ asXml(): T;
454
+ }
455
+ export interface RequestActionBuilder<T> {
456
+ /**
457
+ * Apply some checks
458
+ *
459
+ * @param checks - the checks
460
+ * @returns a new HttpRequestActionBuilder instance
461
+ */
462
+ check(...checks: CheckBuilder[]): T;
463
+ /**
464
+ * Apply some checks if some condition holds true
465
+ *
466
+ * @param condition - the condition, expressed as a function
467
+ * @returns the next DSL step
468
+ */
469
+ checkIf(condition: string): Condition<T>;
470
+ /**
471
+ * Apply some checks if some condition holds true
472
+ *
473
+ * @param condition - the condition, expressed as a function
474
+ * @returns the next DSL step
475
+ */
476
+ checkIf(condition: (session: Session) => boolean): Condition<T>;
477
+ /**
478
+ * Have this request ignore the common checks defined on the HTTP protocol configuration
479
+ *
480
+ * @returns a new HttpRequestActionBuilder instance
481
+ */
482
+ ignoreProtocolChecks(): T;
483
+ /**
484
+ * Have this request ignore the common checks defined on the HTTP protocol configuration
485
+ *
486
+ * @returns a new HttpRequestActionBuilder instance
487
+ */
488
+ silent(): T;
489
+ /**
490
+ * Instruct the reporting engine to forcefully report stats about this request, ignoring HTTP
491
+ * protocol configuration
492
+ *
493
+ * @returns a new HttpRequestActionBuilder instance
494
+ */
495
+ notSilent(): T;
496
+ /**
497
+ * Disable automatic redirect following
498
+ *
499
+ * @returns a new HttpRequestActionBuilder instance
500
+ */
501
+ disableFollowRedirect(): T;
502
+ /**
503
+ * Set some resources to be fetched concurrently after the main request. Next action in the
504
+ * Scenario will be performed once all resources are fetched.
505
+ *
506
+ * @param res - the resources
507
+ * @returns a new HttpRequestActionBuilder instance
508
+ */
509
+ resources(...res: HttpRequestActionBuilder[]): T;
510
+ /**
511
+ * Override the default request timeout defined in gatling.conf
512
+ *
513
+ * @param timeout - timeout the timeout
514
+ * @returns a new HttpRequestActionBuilder instance
515
+ */
516
+ requestTimeout(timeout: Duration): T;
517
+ }
518
+ export interface HttpRequestActionBuilder extends RequestWithParamsActionBuilder<HttpRequestActionBuilder>, RequestWithBodyActionBuilder<HttpRequestActionBuilder>, RequestActionBuilder<HttpRequestActionBuilder>, ActionBuilder {
519
+ _underlying: JvmHttpRequestActionBuilder;
520
+ }
521
+ export declare const wrapHttpRequestActionBuilder: (_underlying: JvmHttpRequestActionBuilder) => HttpRequestActionBuilder;