@gatling.io/http 3.11.7 → 3.13.1

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,1011 @@
1
+ import {
2
+ AllowListFilter,
3
+ CheckBuilder,
4
+ Condition,
5
+ DenyListFilter,
6
+ Expression,
7
+ ProtocolBuilder,
8
+ Session,
9
+ SessionTo,
10
+ asJava,
11
+ underlyingSessionTo,
12
+ wrapCondition
13
+ } from "@gatling.io/core";
14
+
15
+ import { Proxy } from "./proxy";
16
+ import { Response } from "./response";
17
+
18
+ import JvmHttpProtocolBuilder = io.gatling.javaapi.http.HttpProtocolBuilder;
19
+
20
+ /**
21
+ * DSL for building HTTP protocol configurations
22
+ *
23
+ * <p>Immutable, so all methods returns a new occurrence and leave the original unmodified.
24
+ */
25
+ export interface HttpProtocolBuilder extends ProtocolBuilder {
26
+ /**
27
+ * Define the baseUrl that will be used as a prefix for all relative urls
28
+ *
29
+ * @param url - the base url
30
+ * @returns a new HttpProtocolBuilder instance
31
+ */
32
+ baseUrl(url: string): HttpProtocolBuilder;
33
+
34
+ /**
35
+ * Define multiple baseUrls that will be used as a prefix for all relative urls. Assigned once per
36
+ * virtual user based on a round-robin strategy.
37
+ *
38
+ * @param urls - the base urls
39
+ * @returns a new HttpProtocolBuilder instance
40
+ */
41
+ baseUrls(...urls: string[]): HttpProtocolBuilder;
42
+
43
+ /**
44
+ * Define the warmup url. Used to perform a blank HTTP request to load the classes in the
45
+ * ClassLoader so the first load test request won't have to pay for this penalty. Hit
46
+ * "https://gatling.io" by default.
47
+ *
48
+ * @param url - the warmup url
49
+ * @returns a new HttpProtocolBuilder instance
50
+ */
51
+ warmUp(url: string): HttpProtocolBuilder;
52
+
53
+ /**
54
+ * Disable the warmup
55
+ *
56
+ * @returns a new HttpProtocolBuilder instance
57
+ */
58
+ disableWarmUp(): HttpProtocolBuilder;
59
+
60
+ // Engine part
61
+
62
+ /**
63
+ * Share a global connection pool and a global {@link javax.net.ssl.SSLContext} amongst virtual
64
+ * users instead of each having its own. Makes sense if you don't want to generate mob browser
65
+ * traffic but server to server traffic.
66
+ *
67
+ * @returns a new HttpProtocolBuilder instance
68
+ */
69
+ shareConnections(): HttpProtocolBuilder;
70
+
71
+ /**
72
+ * Define the local address to bind from
73
+ *
74
+ * @param address - the local address
75
+ * @returns a new HttpProtocolBuilder instance
76
+ */
77
+ localAddress(address: string): HttpProtocolBuilder;
78
+
79
+ /**
80
+ * Define multiple local addresses to bind from. Assigned once per virtual user based on a
81
+ * round-robin strategy.
82
+ *
83
+ * @param addresses - the local addresses
84
+ * @returns a new HttpProtocolBuilder instance
85
+ */
86
+ localAddresses(...addresses: string[]): HttpProtocolBuilder;
87
+
88
+ /**
89
+ * Bind from all detected local addresses. Assigned once per virtual user based on a round-robin
90
+ * strategy.
91
+ *
92
+ * @returns a new HttpProtocolBuilder instance
93
+ */
94
+ useAllLocalAddresses(): HttpProtocolBuilder;
95
+
96
+ /**
97
+ * Bind from all detected local addresses matching at least one of the configured patterns.
98
+ * Assigned once per virtual user based on a round-robin strategy.
99
+ *
100
+ * @param patterns - some <a
101
+ * href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html">Java Regular
102
+ * Expression</a> patterns
103
+ * @returns a new HttpProtocolBuilder instance
104
+ */
105
+ useAllLocalAddressesMatching(...patterns: string[]): HttpProtocolBuilder;
106
+
107
+ /**
108
+ * Define an HTTP/1.1 connections per host limit for fetching concurrent resources
109
+ *
110
+ * @param max - the limit
111
+ * @returns a new HttpProtocolBuilder instance
112
+ */
113
+ maxConnectionsPerHost(max: number): HttpProtocolBuilder;
114
+
115
+ // TODO
116
+ //perUserKeyManagerFactory(arg0: Func<long | null, any /*javax.net.ssl.KeyManagerFactory*/>): HttpProtocolBuilder;
117
+
118
+ // Request part
119
+
120
+ /**
121
+ * Disable the automatic Referer header generation, based on previous requests.
122
+ *
123
+ * @returns a new HttpProtocolBuilder instance
124
+ */
125
+ disableAutoReferer(): HttpProtocolBuilder;
126
+
127
+ /**
128
+ * Disable the automatic Origin header generation, based the request url.
129
+ *
130
+ * @returns a new HttpProtocolBuilder instance
131
+ */
132
+ disableAutoOrigin(): HttpProtocolBuilder;
133
+
134
+ /**
135
+ * Disable HTTP caching.
136
+ *
137
+ * @returns a new HttpProtocolBuilder instance
138
+ */
139
+ disableCaching(): HttpProtocolBuilder;
140
+
141
+ /**
142
+ * Set a header that's common to all HTTP requests
143
+ *
144
+ * @param name - the static header name
145
+ * @param value - the header value, expressed as a Gatling Expression Language String
146
+ * @returns a new HttpProtocolBuilder instance
147
+ */
148
+ header(name: string, value: string): HttpProtocolBuilder;
149
+
150
+ /**
151
+ * Set a header that's common to all HTTP requests
152
+ *
153
+ * @param name - the static header name
154
+ * @param value - the header value, expressed as a function
155
+ * @returns a new HttpProtocolBuilder instance
156
+ */
157
+ header(name: string, value: (session: Session) => string): HttpProtocolBuilder;
158
+
159
+ /**
160
+ * Set multiple headers that's common to all HTTP requests
161
+ *
162
+ * @param headers - the headers, names are static but values are expressed as a Gatling Expression
163
+ * Language String
164
+ * @returns a new HttpProtocolBuilder instance
165
+ */
166
+ headers(headers: Record<string, string>): HttpProtocolBuilder;
167
+
168
+ /**
169
+ * Set the accept header
170
+ *
171
+ * @param value - the header value, expressed as a Gatling Expression Language String
172
+ * @returns a new HttpProtocolBuilder instance
173
+ */
174
+ acceptHeader(value: string): HttpProtocolBuilder;
175
+
176
+ /**
177
+ * Set the accept header
178
+ *
179
+ * @param value - the header value, expressed as a function
180
+ * @returns a new HttpProtocolBuilder instance
181
+ */
182
+ acceptHeader(value: (session: Session) => string): HttpProtocolBuilder;
183
+
184
+ /**
185
+ * Set the accept-charset header
186
+ *
187
+ * @param value - the header value, expressed as a Gatling Expression Language String
188
+ * @returns a new HttpProtocolBuilder instance
189
+ */
190
+ acceptCharsetHeader(value: string): HttpProtocolBuilder;
191
+
192
+ /**
193
+ * Set the accept-charset header
194
+ *
195
+ * @param value - the header value, expressed as a function
196
+ * @returns a new HttpProtocolBuilder instance
197
+ */
198
+ acceptCharsetHeader(value: (session: Session) => string): HttpProtocolBuilder;
199
+
200
+ /**
201
+ * Set the accept-encoding header
202
+ *
203
+ * @param value - the header value, expressed as a Gatling Expression Language String
204
+ * @returns a new HttpProtocolBuilder instance
205
+ */
206
+ acceptEncodingHeader(value: string): HttpProtocolBuilder;
207
+
208
+ /**
209
+ * Set the accept-encoding header
210
+ *
211
+ * @param value - the header value, expressed as a Gatling Expression Language String
212
+ * @returns a new HttpProtocolBuilder instance
213
+ */
214
+ acceptEncodingHeader(value: (session: Session) => string): HttpProtocolBuilder;
215
+
216
+ /**
217
+ * Set the accept-language header
218
+ *
219
+ * @param value - the header value, expressed as a Gatling Expression Language String
220
+ * @returns a new HttpProtocolBuilder instance
221
+ */
222
+ acceptLanguageHeader(value: string): HttpProtocolBuilder;
223
+
224
+ /**
225
+ * Set the accept-language header
226
+ *
227
+ * @param value - the header value, expressed as a function
228
+ * @returns a new HttpProtocolBuilder instance
229
+ */
230
+ acceptLanguageHeader(value: (session: Session) => string): HttpProtocolBuilder;
231
+
232
+ /**
233
+ * Set the authorization header
234
+ *
235
+ * @param value - the header value, expressed as a Gatling Expression Language String
236
+ * @returns a new HttpProtocolBuilder instance
237
+ */
238
+ authorizationHeader(value: string): HttpProtocolBuilder;
239
+
240
+ /**
241
+ * Set the authorization header
242
+ *
243
+ * @param value - the header value, expressed as a function
244
+ * @returns a new HttpProtocolBuilder instance
245
+ */
246
+ authorizationHeader(value: (session: Session) => string): HttpProtocolBuilder;
247
+
248
+ /**
249
+ * Set the connection header
250
+ *
251
+ * @param value - the header value, expressed as a Gatling Expression Language String
252
+ * @returns a new HttpProtocolBuilder instance
253
+ */
254
+ connectionHeader(value: string): HttpProtocolBuilder;
255
+
256
+ /**
257
+ * Set the connection header
258
+ *
259
+ * @param value - the header value, expressed as a function
260
+ * @returns a new HttpProtocolBuilder instance
261
+ */
262
+ connectionHeader(value: (session: Session) => string): HttpProtocolBuilder;
263
+
264
+ /**
265
+ * Set the content-type header
266
+ *
267
+ * @param value - the header value, expressed as a Gatling Expression Language String
268
+ * @returns a new HttpProtocolBuilder instance
269
+ */
270
+ contentTypeHeader(value: string): HttpProtocolBuilder;
271
+
272
+ /**
273
+ * Set the content-type header
274
+ *
275
+ * @param value - the header value, expressed as a function
276
+ * @returns a new HttpProtocolBuilder instance
277
+ */
278
+ contentTypeHeader(value: (session: Session) => string): HttpProtocolBuilder;
279
+
280
+ /**
281
+ * Set the do-not-track header
282
+ *
283
+ * @param value - the header value, expressed as a Gatling Expression Language String
284
+ * @returns a new HttpProtocolBuilder instance
285
+ */
286
+ doNotTrackHeader(value: string): HttpProtocolBuilder;
287
+
288
+ /**
289
+ * Set the do-not-track header
290
+ *
291
+ * @param value - the header value, expressed as a function
292
+ * @returns a new HttpProtocolBuilder instance
293
+ */
294
+ doNotTrackHeader(value: (session: Session) => string): HttpProtocolBuilder;
295
+
296
+ /**
297
+ * Set the origin header
298
+ *
299
+ * @param value - the header value, expressed as a Gatling Expression Language String
300
+ * @returns a new HttpProtocolBuilder instance
301
+ */
302
+ originHeader(value: string): HttpProtocolBuilder;
303
+
304
+ /**
305
+ * Set the origin header
306
+ *
307
+ * @param value - the header value, expressed as a function
308
+ * @returns a new HttpProtocolBuilder instance
309
+ */
310
+ originHeader(value: (session: Session) => string): HttpProtocolBuilder;
311
+
312
+ /**
313
+ * Set the user-agent header
314
+ *
315
+ * @param value - the header value, expressed as a Gatling Expression Language String
316
+ * @returns a new HttpProtocolBuilder instance
317
+ */
318
+ userAgentHeader(value: string): HttpProtocolBuilder;
319
+
320
+ /**
321
+ * Set the user-agent header
322
+ *
323
+ * @param value - the header value, expressed as a function
324
+ * @returns a new HttpProtocolBuilder instance
325
+ */
326
+ userAgentHeader(value: (session: Session) => string): HttpProtocolBuilder;
327
+
328
+ /**
329
+ * Set the upgrade-insecure-requests header
330
+ *
331
+ * @param value - the header value, expressed as a Gatling Expression Language String
332
+ * @returns a new HttpProtocolBuilder instance
333
+ */
334
+ upgradeInsecureRequestsHeader(value: string): HttpProtocolBuilder;
335
+
336
+ /**
337
+ * Set the upgrade-insecure-requests header
338
+ *
339
+ * @param value - the header value, expressed as a function
340
+ * @returns a new HttpProtocolBuilder instance
341
+ */
342
+ upgradeInsecureRequestsHeader(value: (session: Session) => string): HttpProtocolBuilder;
343
+
344
+ /**
345
+ * Set the authorization header for Basic Auth
346
+ *
347
+ * @param username - the username, expressed as a Gatling Expression Language String
348
+ * @param password - the password, expressed as a Gatling Expression Language String
349
+ * @returns a new HttpProtocolBuilder instance
350
+ */
351
+ basicAuth(username: string, password: string): HttpProtocolBuilder;
352
+
353
+ /**
354
+ * Set the authorization header for Basic Auth
355
+ *
356
+ * @param username - the username, expressed as a Gatling Expression Language String
357
+ * @param password - the password, expressed as a function
358
+ * @returns a new HttpProtocolBuilder instance
359
+ */
360
+ basicAuth(username: string, password: (session: Session) => string): HttpProtocolBuilder;
361
+
362
+ /**
363
+ * Set the authorization header for Basic Auth
364
+ *
365
+ * @param username - the username, expressed as a function
366
+ * @param password - the password, expressed as a Gatling Expression Language String
367
+ * @returns a new HttpProtocolBuilder instance
368
+ */
369
+ basicAuth(username: (session: Session) => string, password: string): HttpProtocolBuilder;
370
+
371
+ /**
372
+ * Set the authorization header for Basic Auth
373
+ *
374
+ * @param username - the username, expressed as a function
375
+ * @param password - the password, expressed as a function
376
+ * @returns a new HttpProtocolBuilder instance
377
+ */
378
+ basicAuth(username: (session: Session) => string, password: (session: Session) => string): HttpProtocolBuilder;
379
+
380
+ /**
381
+ * Set the authorization header for Digest Auth
382
+ *
383
+ * @param username - the username, expressed as a Gatling Expression Language String
384
+ * @param password - the password, expressed as a Gatling Expression Language String
385
+ * @returns a new HttpProtocolBuilder instance
386
+ */
387
+ digestAuth(username: string, password: string): HttpProtocolBuilder;
388
+
389
+ /**
390
+ * Set the authorization header for Digest Auth
391
+ *
392
+ * @param username - the username, expressed as a Gatling Expression Language String
393
+ * @param password - the password, expressed as a function
394
+ * @returns a new HttpProtocolBuilder instance
395
+ */
396
+ digestAuth(username: string, password: (session: Session) => string): HttpProtocolBuilder;
397
+
398
+ /**
399
+ * Set the authorization header for Digest Auth
400
+ *
401
+ * @param username - the username, expressed as a function
402
+ * @param password - the password, expressed as a Gatling Expression Language String
403
+ * @returns a new HttpProtocolBuilder instance
404
+ */
405
+ digestAuth(username: (session: Session) => string, password: string): HttpProtocolBuilder;
406
+
407
+ /**
408
+ * Set the authorization header for Digest Auth
409
+ *
410
+ * @param username - the username, expressed as a function
411
+ * @param password - the password, expressed as a function
412
+ * @returns a new HttpProtocolBuilder instance
413
+ */
414
+ digestAuth(username: (session: Session) => string, password: (session: Session) => string): HttpProtocolBuilder;
415
+
416
+ /**
417
+ * Instruct the reporting engine to not report resources
418
+ *
419
+ * @returns a new HttpProtocolBuilder instance
420
+ */
421
+ silentResources(): HttpProtocolBuilder;
422
+
423
+ /**
424
+ * Instruct the reporting engine to not report requests whose uri matches the configured <a
425
+ * href="https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html">Java Regular
426
+ * Expression</a> pattern
427
+ *
428
+ * @param pattern - the regex pattern
429
+ * @returns a new HttpProtocolBuilder instance
430
+ */
431
+ silentUri(pattern: string): HttpProtocolBuilder;
432
+
433
+ /**
434
+ * Disable the automatic url encoding that tries to detect unescaped reserved chars
435
+ *
436
+ * @returns a new HttpProtocolBuilder instance
437
+ */
438
+ disableUrlEncoding(): HttpProtocolBuilder;
439
+
440
+ /**
441
+ * Provide a function to sign the requests before writing them on the wire
442
+ *
443
+ * @param calculator - the signing function
444
+ * @returns a new HttpProtocolBuilder instance
445
+ */
446
+ //sign(calculator: (request: Request, session: Session) => Request): HttpProtocolBuilder;
447
+
448
+ /**
449
+ * Instruct sign the requests with an OAuth1 Authorization header before writing them on the wire
450
+ *
451
+ * @param consumerKey - the consumerKey, expressed as a Gatling Expression Language String
452
+ * @param clientSharedSecret - the clientSharedSecret, expressed as a Gatling Expression Language
453
+ * String
454
+ * @param token - the token, expressed as a Gatling Expression Language String
455
+ * @param tokenSecret - the tokenSecret, expressed as a Gatling Expression Language String
456
+ * @returns a new HttpProtocolBuilder instance
457
+ */
458
+ signWithOAuth1(
459
+ consumerKey: string,
460
+ clientSharedSecret: string,
461
+ token: string,
462
+ tokenSecret: string
463
+ ): HttpProtocolBuilder;
464
+
465
+ /**
466
+ * Instruct sign the requests with OAuth1 before writing them on the wire
467
+ *
468
+ * @param consumerKey - the consumerKey, expressed as a Gatling Expression Language String
469
+ * @param clientSharedSecret - the clientSharedSecret, expressed as a Gatling Expression Language
470
+ * String
471
+ * @param token - the token, expressed as a Gatling Expression Language String
472
+ * @param tokenSecret - the tokenSecret, expressed as a Gatling Expression Language String
473
+ * @param useAuthorizationHeader - if true, sign with an Authorization header, otherwise sign forms
474
+ * with extra parameters and other requests with extra query params
475
+ * @returns a new HttpProtocolBuilder instance
476
+ */
477
+ signWithOAuth1(
478
+ consumerKey: string,
479
+ clientSharedSecret: string,
480
+ token: string,
481
+ tokenSecret: string,
482
+ useAuthorizationHeader: boolean
483
+ ): HttpProtocolBuilder;
484
+
485
+ /**
486
+ * Instruct sign the requests with an OAuth1 Authorization before writing them on the wire
487
+ *
488
+ * @param consumerKey - the consumerKey, expressed as a function
489
+ * @param clientSharedSecret - the clientSharedSecret, expressed as a function
490
+ * @param token - the token, expressed as a function
491
+ * @param tokenSecret - the tokenSecret, expressed as a function
492
+ * @returns a new HttpProtocolBuilder instance
493
+ */
494
+ signWithOAuth1(
495
+ consumerKey: (session: Session) => string,
496
+ clientSharedSecret: (session: Session) => string,
497
+ token: (session: Session) => string,
498
+ tokenSecret: (session: Session) => string
499
+ ): HttpProtocolBuilder;
500
+
501
+ /**
502
+ * Instruct sign the requests with OAuth1 before writing them on the wire
503
+ *
504
+ * @param consumerKey - the consumerKey, expressed as a function
505
+ * @param clientSharedSecret - the clientSharedSecret, expressed as a function
506
+ * @param token - the token, expressed as a function
507
+ * @param tokenSecret - the tokenSecret, expressed as a function
508
+ * @param useAuthorizationHeader - if true, sign with an Authorization header, otherwise sign forms
509
+ * with extra parameters and other requests with extra query params
510
+ * @returns a new HttpProtocolBuilder instance
511
+ */
512
+ signWithOAuth1(
513
+ consumerKey: (session: Session) => string,
514
+ clientSharedSecret: (session: Session) => string,
515
+ token: (session: Session) => string,
516
+ tokenSecret: (session: Session) => string,
517
+ useAuthorizationHeader: boolean
518
+ ): HttpProtocolBuilder;
519
+
520
+ /**
521
+ * Enable HTTP/2
522
+ *
523
+ * @returns a new HttpProtocolBuilder instance
524
+ */
525
+ enableHttp2(): HttpProtocolBuilder;
526
+
527
+ /**
528
+ * Define the remote hosts that are known to support or not support HTTP/2
529
+ *
530
+ * @param remotes - the known remote hosts
531
+ * @returns a new HttpProtocolBuilder instance
532
+ */
533
+ http2PriorKnowledge(remotes: Record<string, boolean>): HttpProtocolBuilder;
534
+
535
+ // Response part
536
+
537
+ /**
538
+ * Disable automatically following redirects
539
+ *
540
+ * @returns a new HttpProtocolBuilder instance
541
+ */
542
+ disableFollowRedirect(): HttpProtocolBuilder;
543
+
544
+ /**
545
+ * Define the maximum number of redirects in a redirect chain
546
+ *
547
+ * @param max - the limit
548
+ * @returns a new HttpProtocolBuilder instance
549
+ */
550
+ maxRedirects(max: number): HttpProtocolBuilder;
551
+
552
+ /**
553
+ * Apply 302 strictly and not switch to GET and re-send the request body
554
+ *
555
+ * @returns a new HttpProtocolBuilder instance
556
+ */
557
+ strict302Handling(): HttpProtocolBuilder;
558
+
559
+ // TODO
560
+ //redirectNamingStrategy(
561
+ // arg0: any /*io.gatling.javaapi.http.HttpProtocolBuilder$RedirectNamingStrategy*/
562
+ //): HttpProtocolBuilder;
563
+
564
+ /**
565
+ * Define a transformation function to be applied on the {@link Response}s before checks are
566
+ * applied. Typically used for decoding responses, eg with <a
567
+ * href="https://developers.google.com/protocol-buffers">Protobuf</a>.
568
+ *
569
+ * @param f - the strategy
570
+ * @returns a new HttpProtocolBuilder instance
571
+ */
572
+ //transformResponse(f: (response: Response, session: Session) => Response): HttpProtocolBuilder;
573
+
574
+ /**
575
+ * Apply some checks
576
+ *
577
+ * @param checks - the checks
578
+ * @returns a new HttpRequestActionBuilder instance
579
+ */
580
+ check(...checks: CheckBuilder[]): HttpProtocolBuilder;
581
+
582
+ // TODO
583
+ //checkIf(
584
+ // arg0: BiFunction<any /*io.gatling.http.response.Response*/, io.gatling.javaapi.core.Session, boolean | null>
585
+ //): any /*io.gatling.javaapi.http.HttpProtocolBuilder$TypedCondition*/;
586
+
587
+ /**
588
+ * Define some common checks to be applied on all the requests when a condition holds true.
589
+ *
590
+ * @param condition - a condition, expressed as a Gatling Expression Language String
591
+ * @returns the next DSL step
592
+ */
593
+ checkIf(condition: string): Condition<HttpProtocolBuilder>;
594
+
595
+ /**
596
+ * Define some common checks to be applied on all the requests when a condition holds true.
597
+ *
598
+ * @param condition - a condition, expressed as a function
599
+ * @returns the next DSL step
600
+ */
601
+ checkIf(condition: (session: Session) => boolean): Condition<HttpProtocolBuilder>;
602
+
603
+ /**
604
+ * Automatically infer resources from HTML payloads
605
+ *
606
+ * @returns a new HttpProtocolBuilder instance
607
+ */
608
+ inferHtmlResources(): HttpProtocolBuilder;
609
+
610
+ /**
611
+ * Automatically infer resources from HTML payloads
612
+ *
613
+ * @param allow - the allow list to filter the resources
614
+ * @returns a new HttpProtocolBuilder instance
615
+ */
616
+ inferHtmlResources(allow: AllowListFilter): HttpProtocolBuilder;
617
+
618
+ /**
619
+ * Automatically infer resources from HTML payloads
620
+ *
621
+ * @param allow - the allow list to filter the resources
622
+ * @param deny - the deny list to filter out the resources
623
+ * @returns a new HttpProtocolBuilder instance
624
+ */
625
+ inferHtmlResources(allow: AllowListFilter, deny: DenyListFilter): HttpProtocolBuilder;
626
+
627
+ /**
628
+ * Automatically infer resources from HTML payloads
629
+ *
630
+ * @param deny - the deny list to filter out the resources
631
+ * @returns a new HttpProtocolBuilder instance
632
+ */
633
+ inferHtmlResources(deny: DenyListFilter): HttpProtocolBuilder;
634
+
635
+ /**
636
+ * Name the inferred resources' requests based on the tail of the url
637
+ *
638
+ * @returns a new HttpProtocolBuilder instance
639
+ */
640
+ nameInferredHtmlResourcesAfterUrlTail(): HttpProtocolBuilder;
641
+
642
+ /**
643
+ * Name the inferred resources' requests based on the absolute url
644
+ *
645
+ * @returns a new HttpProtocolBuilder instance
646
+ */
647
+ nameInferredHtmlResourcesAfterAbsoluteUrl(): HttpProtocolBuilder;
648
+
649
+ /**
650
+ * Name the inferred resources' requests based on the relative url
651
+ *
652
+ * @returns a new HttpProtocolBuilder instance
653
+ */
654
+ nameInferredHtmlResourcesAfterRelativeUrl(): HttpProtocolBuilder;
655
+
656
+ /**
657
+ * Name the inferred resources' requests based on the path
658
+ *
659
+ * @returns a new HttpProtocolBuilder instance
660
+ */
661
+ nameInferredHtmlResourcesAfterPath(): HttpProtocolBuilder;
662
+
663
+ /**
664
+ * Name the inferred resources' requests based on the last element of the path
665
+ *
666
+ * @returns a new HttpProtocolBuilder instance
667
+ */
668
+ nameInferredHtmlResourcesAfterLastPathElement(): HttpProtocolBuilder;
669
+
670
+ // TODO
671
+ //nameInferredHtmlResources(arg0: Func<any /*io.gatling.http.client.uri.Uri*/, string>): HttpProtocolBuilder;
672
+
673
+ // WebSockets part
674
+
675
+ // TODO
676
+ //wsBaseUrl(arg0: string): HttpProtocolBuilder;
677
+
678
+ // TODO
679
+ //wsBaseUrls(...arg0: string[]): HttpProtocolBuilder;
680
+
681
+ // TODO
682
+ //wsBaseUrls(arg0: java.util.List<string>): HttpProtocolBuilder;
683
+
684
+ // TODO
685
+ //wsReconnect(): HttpProtocolBuilder;
686
+
687
+ // TODO
688
+ //wsMaxReconnects(arg0: int): HttpProtocolBuilder;
689
+
690
+ // TODO
691
+ //wsAutoReplyTextFrame(arg0: Func<string, string>): HttpProtocolBuilder;
692
+
693
+ // TODO
694
+ //wsAutoReplySocketIo4(): HttpProtocolBuilder;
695
+
696
+ // FIXME missing wsUnmatchedInboundMessageBufferSize
697
+
698
+ // SSE part
699
+
700
+ // FIXME missing sseUnmatchedInboundMessageBufferSize
701
+
702
+ // Proxy part
703
+
704
+ /**
705
+ * Define a Proxy to be used for all requests
706
+ *
707
+ * @param proxy - the proxy
708
+ * @returns a new HttpProtocolBuilder instance
709
+ */
710
+ proxy(proxy: Proxy): HttpProtocolBuilder;
711
+
712
+ /**
713
+ * Ignore any configured proxy for some hosts
714
+ *
715
+ * @param hosts - the hosts that must be connected directly without the proxy
716
+ * @returns a new HttpProtocolBuilder instance
717
+ */
718
+ noProxyFor(...hosts: string[]): HttpProtocolBuilder;
719
+
720
+ /**
721
+ * Enable Proxy Protocol for IPv4
722
+ *
723
+ * @param address - a fake local address in IPv4 format
724
+ * @returns a new HttpProtocolBuilder instance
725
+ */
726
+ proxyProtocolSourceIpV4Address(address: string): HttpProtocolBuilder;
727
+
728
+ /**
729
+ * Enable Proxy Protocol for IPv4
730
+ *
731
+ * @param address - a fake local address in IPv4 format
732
+ * @returns a new HttpProtocolBuilder instance
733
+ */
734
+ proxyProtocolSourceIpV4Address(address: (session: Session) => string): HttpProtocolBuilder;
735
+
736
+ /**
737
+ * Enable Proxy Protocol for IPv6
738
+ *
739
+ * @param address - a fake local address in IPv6 format
740
+ * @returns a new HttpProtocolBuilder instance
741
+ */
742
+ proxyProtocolSourceIpV6Address(address: string): HttpProtocolBuilder;
743
+
744
+ /**
745
+ * Enable Proxy Protocol for IPv6
746
+ *
747
+ * @param address - a fake local address in IPv6 format
748
+ * @returns a new HttpProtocolBuilder instance
749
+ */
750
+ proxyProtocolSourceIpV6Address(address: (session: Session) => string): HttpProtocolBuilder;
751
+
752
+ // DNS part
753
+
754
+ /**
755
+ * Enable Gatling non-blocking DNS resolution instead of using Java's blocking implementation
756
+ *
757
+ * @param dnsServers - the DNS servers
758
+ * @returns a new HttpProtocolBuilder instance
759
+ */
760
+ asyncNameResolution(...dnsServers: string[]): HttpProtocolBuilder;
761
+
762
+ /**
763
+ * Define some aliases to bypass DNS name resolution
764
+ *
765
+ * @param aliases the aliases
766
+ * @return a new HttpProtocolBuilder instance
767
+ */
768
+ hostNameAliases(aliases: Record<string, string[]>): HttpProtocolBuilder;
769
+
770
+ /**
771
+ * Force each virtual user to have its own DNS cache and perform its own DNS resolutions instead
772
+ * of using a global shared resolver
773
+ *
774
+ * @returns a new HttpProtocolBuilder instance
775
+ */
776
+ perUserNameResolution(): HttpProtocolBuilder;
777
+ }
778
+
779
+ export const wrapHttpProtocolBuilder = (_underlying: JvmHttpProtocolBuilder): HttpProtocolBuilder => ({
780
+ _underlying,
781
+
782
+ baseUrl: (url: string): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.baseUrl(url)),
783
+ baseUrls: (...urls: string[]): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.baseUrls(...urls)),
784
+ warmUp: (url: string): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.warmUp(url)),
785
+ disableWarmUp: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.disableWarmUp()),
786
+
787
+ // Engine part
788
+
789
+ shareConnections: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.shareConnections()),
790
+ localAddress: (address: string): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.localAddress(address)),
791
+ localAddresses: (...addresses: string[]): HttpProtocolBuilder =>
792
+ wrapHttpProtocolBuilder(_underlying.localAddresses(...addresses)),
793
+ useAllLocalAddresses: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.useAllLocalAddresses()),
794
+ useAllLocalAddressesMatching: (...patterns: string[]): HttpProtocolBuilder =>
795
+ wrapHttpProtocolBuilder(_underlying.useAllLocalAddressesMatching(...patterns)),
796
+ maxConnectionsPerHost: (max: int): HttpProtocolBuilder =>
797
+ wrapHttpProtocolBuilder(_underlying.maxConnectionsPerHost(max)),
798
+ // TODO perUserKeyManagerFactory
799
+
800
+ // Request part
801
+
802
+ disableAutoOrigin: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.disableAutoOrigin()),
803
+ disableAutoReferer: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.disableAutoReferer()),
804
+ disableCaching: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.disableCaching()),
805
+ header: (name: string, value: Expression<string>): HttpProtocolBuilder =>
806
+ wrapHttpProtocolBuilder(
807
+ typeof value === "function"
808
+ ? _underlying.header(name, underlyingSessionTo(value))
809
+ : _underlying.header(name, value)
810
+ ),
811
+ headers: (headers: Record<string, string>): HttpProtocolBuilder =>
812
+ wrapHttpProtocolBuilder(_underlying.headers(asJava(headers) as any)),
813
+ acceptHeader: (value: Expression<string>): HttpProtocolBuilder =>
814
+ wrapHttpProtocolBuilder(
815
+ typeof value === "function"
816
+ ? _underlying.acceptHeader(underlyingSessionTo(value))
817
+ : _underlying.acceptHeader(value)
818
+ ),
819
+ acceptCharsetHeader: (value: Expression<string>): HttpProtocolBuilder =>
820
+ wrapHttpProtocolBuilder(
821
+ typeof value === "function"
822
+ ? _underlying.acceptCharsetHeader(underlyingSessionTo(value))
823
+ : _underlying.acceptCharsetHeader(value)
824
+ ),
825
+ acceptEncodingHeader: (value: Expression<string>): HttpProtocolBuilder =>
826
+ wrapHttpProtocolBuilder(
827
+ typeof value === "function"
828
+ ? _underlying.acceptEncodingHeader(underlyingSessionTo(value))
829
+ : _underlying.acceptEncodingHeader(value)
830
+ ),
831
+ acceptLanguageHeader: (value: Expression<string>): HttpProtocolBuilder =>
832
+ wrapHttpProtocolBuilder(
833
+ typeof value === "function"
834
+ ? _underlying.acceptLanguageHeader(underlyingSessionTo(value))
835
+ : _underlying.acceptLanguageHeader(value)
836
+ ),
837
+ authorizationHeader: (value: Expression<string>): HttpProtocolBuilder =>
838
+ wrapHttpProtocolBuilder(
839
+ typeof value === "function"
840
+ ? _underlying.authorizationHeader(underlyingSessionTo(value))
841
+ : _underlying.authorizationHeader(value)
842
+ ),
843
+ connectionHeader: (value: Expression<string>): HttpProtocolBuilder =>
844
+ wrapHttpProtocolBuilder(
845
+ typeof value === "function"
846
+ ? _underlying.connectionHeader(underlyingSessionTo(value))
847
+ : _underlying.connectionHeader(value)
848
+ ),
849
+ contentTypeHeader: (value: Expression<string>): HttpProtocolBuilder =>
850
+ wrapHttpProtocolBuilder(
851
+ typeof value === "function"
852
+ ? _underlying.contentTypeHeader(underlyingSessionTo(value))
853
+ : _underlying.contentTypeHeader(value)
854
+ ),
855
+ doNotTrackHeader: (value: Expression<string>): HttpProtocolBuilder =>
856
+ wrapHttpProtocolBuilder(
857
+ typeof value === "function"
858
+ ? _underlying.doNotTrackHeader(underlyingSessionTo(value))
859
+ : _underlying.doNotTrackHeader(value)
860
+ ),
861
+ originHeader: (value: Expression<string>): HttpProtocolBuilder =>
862
+ wrapHttpProtocolBuilder(
863
+ typeof value === "function"
864
+ ? _underlying.originHeader(underlyingSessionTo(value))
865
+ : _underlying.originHeader(value)
866
+ ),
867
+ userAgentHeader: (value: Expression<string>): HttpProtocolBuilder =>
868
+ wrapHttpProtocolBuilder(
869
+ typeof value === "function"
870
+ ? _underlying.userAgentHeader(underlyingSessionTo(value))
871
+ : _underlying.userAgentHeader(value)
872
+ ),
873
+ upgradeInsecureRequestsHeader: (value: Expression<string>): HttpProtocolBuilder =>
874
+ wrapHttpProtocolBuilder(
875
+ typeof value === "function"
876
+ ? _underlying.upgradeInsecureRequestsHeader(underlyingSessionTo(value))
877
+ : _underlying.upgradeInsecureRequestsHeader(value)
878
+ ),
879
+ basicAuth: (username: Expression<string>, password: Expression<string>): HttpProtocolBuilder =>
880
+ wrapHttpProtocolBuilder(
881
+ typeof username === "function"
882
+ ? typeof password === "function"
883
+ ? _underlying.basicAuth(underlyingSessionTo(username), underlyingSessionTo(password))
884
+ : _underlying.basicAuth(underlyingSessionTo(username), password)
885
+ : typeof password === "function"
886
+ ? _underlying.basicAuth(username, underlyingSessionTo(password))
887
+ : _underlying.basicAuth(username, password)
888
+ ),
889
+ digestAuth: (username: Expression<string>, password: Expression<string>): HttpProtocolBuilder =>
890
+ wrapHttpProtocolBuilder(
891
+ typeof username === "function"
892
+ ? typeof password === "function"
893
+ ? _underlying.digestAuth(underlyingSessionTo(username), underlyingSessionTo(password))
894
+ : _underlying.digestAuth(underlyingSessionTo(username), password)
895
+ : typeof password === "function"
896
+ ? _underlying.digestAuth(username, underlyingSessionTo(password))
897
+ : _underlying.digestAuth(username, password)
898
+ ),
899
+ silentResources: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.silentResources()),
900
+ silentUri: (pattern: string): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.silentUri(pattern)),
901
+ disableUrlEncoding: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.disableUrlEncoding()),
902
+ //sign: (calculator: (request: Request, session: Session) => Request): HttpProtocolBuilder =>
903
+ // wrapHttpProtocolBuilder(_underlying.sign(wrapBiCallback(underlyingRequestTransform(calculator)))),
904
+ signWithOAuth1: (
905
+ consumerKey: Expression<string>,
906
+ clientSharedSecret: Expression<string>,
907
+ token: Expression<string>,
908
+ tokenSecret: Expression<string>,
909
+ useAuthorizationHeader?: boolean
910
+ ): HttpProtocolBuilder =>
911
+ wrapHttpProtocolBuilder(
912
+ typeof consumerKey === "function" &&
913
+ typeof clientSharedSecret === "function" &&
914
+ typeof token === "function" &&
915
+ typeof tokenSecret === "function"
916
+ ? typeof useAuthorizationHeader !== "undefined"
917
+ ? _underlying.signWithOAuth1(
918
+ underlyingSessionTo(consumerKey),
919
+ underlyingSessionTo(clientSharedSecret),
920
+ underlyingSessionTo(token),
921
+ underlyingSessionTo(tokenSecret),
922
+ useAuthorizationHeader
923
+ )
924
+ : _underlying.signWithOAuth1(
925
+ underlyingSessionTo(consumerKey),
926
+ underlyingSessionTo(clientSharedSecret),
927
+ underlyingSessionTo(token),
928
+ underlyingSessionTo(tokenSecret)
929
+ )
930
+ : typeof useAuthorizationHeader !== "undefined"
931
+ ? _underlying.signWithOAuth1(
932
+ consumerKey as string,
933
+ clientSharedSecret as string,
934
+ token as string,
935
+ tokenSecret as string,
936
+ useAuthorizationHeader
937
+ )
938
+ : _underlying.signWithOAuth1(
939
+ consumerKey as string,
940
+ clientSharedSecret as string,
941
+ token as string,
942
+ tokenSecret as string
943
+ )
944
+ ),
945
+ enableHttp2: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.enableHttp2()),
946
+ http2PriorKnowledge: (remotes: Record<string, boolean>): HttpProtocolBuilder =>
947
+ wrapHttpProtocolBuilder(_underlying.http2PriorKnowledge(remotes)),
948
+
949
+ // Response part
950
+
951
+ disableFollowRedirect: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.disableFollowRedirect()),
952
+ maxRedirects: (max: number): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.maxRedirects(max)),
953
+ strict302Handling: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.strict302Handling()),
954
+
955
+ //transformResponse: (f: (response: Response, session: Session) => Response): HttpProtocolBuilder =>
956
+ // wrapHttpProtocolBuilder(_underlying.transformResponse(wrapBiCallback(underlyingResponseTransform(f)))),
957
+
958
+ check: (...checks: CheckBuilder[]): HttpProtocolBuilder =>
959
+ wrapHttpProtocolBuilder(_underlying.check(checks.map((c: CheckBuilder) => c._underlying))),
960
+ checkIf: (condition: string | SessionTo<boolean>): Condition<HttpProtocolBuilder> =>
961
+ wrapCondition(
962
+ typeof condition === "string"
963
+ ? _underlying.checkIf(condition)
964
+ : _underlying.checkIf(underlyingSessionTo(condition)),
965
+ wrapHttpProtocolBuilder
966
+ ),
967
+
968
+ inferHtmlResources: (arg0?: AllowListFilter | DenyListFilter, arg1?: DenyListFilter): HttpProtocolBuilder =>
969
+ wrapHttpProtocolBuilder(
970
+ arg0 !== undefined
971
+ ? arg1 !== undefined
972
+ ? _underlying.inferHtmlResources(arg0._underlying, arg1._underlying)
973
+ : _underlying.inferHtmlResources(arg0._underlying)
974
+ : _underlying.inferHtmlResources()
975
+ ),
976
+
977
+ nameInferredHtmlResourcesAfterUrlTail: (): HttpProtocolBuilder =>
978
+ wrapHttpProtocolBuilder(_underlying.nameInferredHtmlResourcesAfterUrlTail()),
979
+ nameInferredHtmlResourcesAfterAbsoluteUrl: (): HttpProtocolBuilder =>
980
+ wrapHttpProtocolBuilder(_underlying.nameInferredHtmlResourcesAfterAbsoluteUrl()),
981
+ nameInferredHtmlResourcesAfterRelativeUrl: (): HttpProtocolBuilder =>
982
+ wrapHttpProtocolBuilder(_underlying.nameInferredHtmlResourcesAfterRelativeUrl()),
983
+ nameInferredHtmlResourcesAfterPath: (): HttpProtocolBuilder =>
984
+ wrapHttpProtocolBuilder(_underlying.nameInferredHtmlResourcesAfterPath()),
985
+ nameInferredHtmlResourcesAfterLastPathElement: (): HttpProtocolBuilder =>
986
+ wrapHttpProtocolBuilder(_underlying.nameInferredHtmlResourcesAfterLastPathElement()),
987
+
988
+ // Proxy part
989
+
990
+ proxy: (proxy: Proxy): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.proxy(proxy._underlying)),
991
+ noProxyFor: (...hosts: string[]): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.noProxyFor(...hosts)),
992
+ proxyProtocolSourceIpV4Address: (address: Expression<string>) =>
993
+ wrapHttpProtocolBuilder(
994
+ typeof address === "string"
995
+ ? _underlying.proxyProtocolSourceIpV4Address(address)
996
+ : _underlying.proxyProtocolSourceIpV4Address(underlyingSessionTo(address))
997
+ ),
998
+ proxyProtocolSourceIpV6Address: (address: Expression<string>) =>
999
+ wrapHttpProtocolBuilder(
1000
+ typeof address === "string"
1001
+ ? _underlying.proxyProtocolSourceIpV6Address(address)
1002
+ : _underlying.proxyProtocolSourceIpV6Address(underlyingSessionTo(address))
1003
+ ),
1004
+
1005
+ // DNS part
1006
+
1007
+ asyncNameResolution: (...dnsServers: string[]): HttpProtocolBuilder =>
1008
+ wrapHttpProtocolBuilder(_underlying.asyncNameResolution(...dnsServers)),
1009
+ hostNameAliases: (aliases) => wrapHttpProtocolBuilder(_underlying.hostNameAliases(aliases)),
1010
+ perUserNameResolution: (): HttpProtocolBuilder => wrapHttpProtocolBuilder(_underlying.perUserNameResolution())
1011
+ });