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