@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,425 @@
1
+ import {
2
+ AllowList,
3
+ DenyList,
4
+ RawFileBody,
5
+ Session,
6
+ Simulation,
7
+ StringBody,
8
+ atOnceUsers,
9
+ bodyBytes,
10
+ bodyLength,
11
+ bodyString,
12
+ css,
13
+ form,
14
+ jmesPath,
15
+ jsonPath,
16
+ jsonpJmesPath,
17
+ jsonpJsonPath,
18
+ md5,
19
+ regex,
20
+ responseTimeInMillis,
21
+ scenario,
22
+ sha1,
23
+ substring,
24
+ xpath
25
+ } from "@gatling.io/core";
26
+
27
+ import {
28
+ Cookie,
29
+ CookieKey,
30
+ ElFileBodyPart,
31
+ Proxy,
32
+ RawFileBodyPart,
33
+ addCookie,
34
+ currentLocation,
35
+ currentLocationRegex,
36
+ flushCookieJar,
37
+ flushHttpCache,
38
+ flushSessionCookies,
39
+ getCookieValue,
40
+ header,
41
+ headerRegex,
42
+ http,
43
+ poll,
44
+ status,
45
+ sitemap
46
+ } from "./index";
47
+
48
+ const runSimulationMock = (_: Simulation): void => {};
49
+
50
+ const httpProtocol = http
51
+ .baseUrl("url")
52
+ .baseUrls("url1", "urls2")
53
+ .warmUp("url")
54
+ .disableWarmUp()
55
+ .shareConnections()
56
+ .localAddress("127.0.0.1")
57
+ .localAddresses("127.0.0.1", "127.0.0.2")
58
+ .useAllLocalAddresses()
59
+ .useAllLocalAddressesMatching("pattern")
60
+ .maxConnectionsPerHost(1)
61
+ //.perUserKeyManagerFactory(
62
+ // session -> {
63
+ // try {
64
+ // return KeyManagerFactory.getInstance("TLS");
65
+ // } catch (NoSuchAlgorithmException e) {
66
+ // throw new RuntimeException(e);
67
+ // }
68
+ // })
69
+ .disableAutoReferer()
70
+ .disableAutoOrigin()
71
+ .disableCaching()
72
+ .header("name", "value")
73
+ .header("name", (_: Session) => "value")
74
+ .headers({ key: "value" })
75
+ .acceptHeader("value")
76
+ .acceptHeader((_: Session) => "value")
77
+ .acceptCharsetHeader("value")
78
+ .acceptCharsetHeader((_: Session) => "value")
79
+ .acceptEncodingHeader("value")
80
+ .acceptEncodingHeader((_: Session) => "value")
81
+ .acceptLanguageHeader("value")
82
+ .acceptLanguageHeader((_: Session) => "value")
83
+ .acceptLanguageHeader("value")
84
+ .acceptLanguageHeader((_: Session) => "value")
85
+ .authorizationHeader("value")
86
+ .authorizationHeader((_: Session) => "value")
87
+ .connectionHeader("value")
88
+ .connectionHeader((_: Session) => "value")
89
+ .contentTypeHeader("value")
90
+ .contentTypeHeader((_: Session) => "value")
91
+ .doNotTrackHeader("value")
92
+ .doNotTrackHeader((_: Session) => "value")
93
+ .originHeader("value")
94
+ .originHeader((_: Session) => "value")
95
+ .userAgentHeader("value")
96
+ .userAgentHeader((_: Session) => "value")
97
+ .upgradeInsecureRequestsHeader("value")
98
+ .upgradeInsecureRequestsHeader((_: Session) => "value")
99
+ .basicAuth("username", "password")
100
+ .basicAuth("username", (_: Session) => "password")
101
+ .basicAuth((_: Session) => "username", "password")
102
+ .basicAuth(
103
+ (_: Session) => "username",
104
+ (_: Session) => "password"
105
+ )
106
+ .digestAuth((_: Session) => "username", "password")
107
+ .digestAuth(
108
+ (_: Session) => "username",
109
+ (_: Session) => "password"
110
+ )
111
+ .silentResources()
112
+ .silentUri("regex")
113
+ .disableUrlEncoding()
114
+ //.sign((request) => request)
115
+ //.sign((request, _: Session) => request)
116
+ .signWithOAuth1("consumerKey", "clientSharedSecret", "token", "tokenSecret")
117
+ .signWithOAuth1("consumerKey", "clientSharedSecret", "token", "tokenSecret", true)
118
+ .signWithOAuth1(
119
+ (_: Session) => "consumerKey",
120
+ (_: Session) => "clientSharedSecret",
121
+ (_: Session) => "token",
122
+ (_: Session) => "tokenSecret"
123
+ )
124
+ .signWithOAuth1(
125
+ (_: Session) => "consumerKey",
126
+ (_: Session) => "clientSharedSecret",
127
+ (_: Session) => "token",
128
+ (_: Session) => "tokenSecret",
129
+ true
130
+ )
131
+ .enableHttp2()
132
+ .http2PriorKnowledge({ host: true })
133
+ .disableFollowRedirect()
134
+ .maxRedirects(1)
135
+ .strict302Handling()
136
+ //.redirectNamingStrategy(
137
+ // (uri, originalRequestName, redirectCount) ->
138
+ // originalRequestName + " Redirect " + redirectCount)
139
+ //.transformResponse((response, session) -> response)
140
+ .inferHtmlResources()
141
+ .inferHtmlResources(AllowList("allow"))
142
+ .inferHtmlResources(DenyList("deny"))
143
+ .inferHtmlResources(AllowList("allow"), DenyList("deny"))
144
+ .nameInferredHtmlResourcesAfterUrlTail()
145
+ .nameInferredHtmlResourcesAfterAbsoluteUrl()
146
+ .nameInferredHtmlResourcesAfterRelativeUrl()
147
+ .nameInferredHtmlResourcesAfterPath()
148
+ .nameInferredHtmlResourcesAfterLastPathElement()
149
+ //.nameInferredHtmlResources(uri -> "foo")
150
+ .noProxyFor("host1", "host2")
151
+ .proxy(Proxy("172.31.76.106", 8080))
152
+ .proxy(Proxy("172.31.76.106", 8080).credentials("username", "password"))
153
+ .proxy(Proxy("172.31.76.106", 8080).http())
154
+ .proxy(Proxy("172.31.76.106", 8080).socks4())
155
+ .proxy(Proxy("172.31.76.106", 8080).socks5())
156
+ .asyncNameResolution("dnsServer1", "dnsServer2")
157
+ .hostNameAliases({ "gatling.io": ["192.168.0.1", "192.168.0.2"] })
158
+ .perUserNameResolution()
159
+ .check(
160
+ bodyBytes(),
161
+ bodyBytes().is([102, 111, 111]),
162
+ bodyBytes().is(RawFileBody("foo")),
163
+ bodyBytes().saveAs("key"),
164
+ bodyBytes().find().is([102, 111, 111]),
165
+ bodyLength().gt(1),
166
+ bodyString()
167
+ .transform((str: string) => str.length)
168
+ .lt(100000),
169
+ bodyString().is(StringBody("foo")),
170
+ regex("pattern").findAll(),
171
+ regex("pattern").captureGroups(2).is(["foo", "bar"]),
172
+ regex("pattern").findRandom(),
173
+ regex("pattern").findRandom(2),
174
+ regex("pattern").findRandom(2, true),
175
+ regex("pattern").saveAs("key"),
176
+ regex((_: Session) => "pattern").saveAs("key"),
177
+ substring("foo").is(1),
178
+ substring((_: Session) => "foo").is(1),
179
+ xpath("//foo"),
180
+ xpath("//foo", {}),
181
+ xpath((_: Session) => "//foo"),
182
+ xpath((_: Session) => "//foo", {}),
183
+ css("selector"),
184
+ css("selector", "attribute"),
185
+ css((_: Session) => "selector"),
186
+ css((_: Session) => "selector", "attribute"),
187
+ form("#form"),
188
+ form((_: Session) => "#form"),
189
+ jsonPath("$..foo"),
190
+ jsonPath("$..foo").ofBoolean(),
191
+ jsonPath("$..foo").ofInt(),
192
+ jsonPath("$..foo").ofLong(),
193
+ jsonPath("$..foo").ofDouble(),
194
+ jsonPath("$..foo").ofList(),
195
+ jsonPath("$..foo").ofMap(),
196
+ jsonPath("$..foo").ofObject(),
197
+ jsonPath((_: Session) => "$..foo").withDefault((_: Session) => "foo"),
198
+ jsonPath("$..foo"),
199
+ jsonpJsonPath("$..foo"),
200
+ jsonpJsonPath("$..foo").ofBoolean(),
201
+ jsonpJsonPath("$..foo").ofInt(),
202
+ jsonpJsonPath("$..foo").ofLong(),
203
+ jsonpJsonPath("$..foo").ofDouble(),
204
+ jsonpJsonPath("$..foo").ofList(),
205
+ jsonpJsonPath("$..foo").ofMap(),
206
+ jsonpJsonPath("$..foo").ofObject(),
207
+ jsonpJsonPath((_: Session) => "$..foo"),
208
+ jmesPath("foo"),
209
+ jmesPath("foo").ofBoolean(),
210
+ jmesPath("foo").ofInt(),
211
+ jmesPath("foo").ofLong(),
212
+ jmesPath("foo").ofDouble(),
213
+ jmesPath("foo").ofList(),
214
+ jmesPath("foo").ofMap(),
215
+ jmesPath("foo").ofObject(),
216
+ jmesPath((_: Session) => "foo"),
217
+ jsonpJmesPath("foo"),
218
+ jsonpJmesPath("foo").ofBoolean(),
219
+ jsonpJmesPath("foo").ofInt(),
220
+ jsonpJmesPath("foo").ofLong(),
221
+ jsonpJmesPath("foo").ofDouble(),
222
+ jsonpJmesPath("foo").ofList(),
223
+ jsonpJmesPath("foo").ofMap(),
224
+ jsonpJmesPath("foo").ofObject(),
225
+ jsonpJmesPath((_: Session) => "$..foo"),
226
+ md5().find().isEL("XXXXX"),
227
+ sha1().find().isEL("XXXXX"),
228
+ responseTimeInMillis().find().is(100),
229
+ md5().find().is("XXXXX"),
230
+ sha1().find().is("XXXXX"),
231
+ responseTimeInMillis().find().is(100),
232
+ status().is(200),
233
+ currentLocation().is("url"),
234
+ currentLocationRegex("pattern"),
235
+ currentLocationRegex((_: Session) => "pattern"),
236
+ header("name"),
237
+ header((_: Session) => "name"),
238
+ headerRegex("name", "pattern"),
239
+ headerRegex((_: Session) => "name", "pattern"),
240
+ headerRegex("name", (_: Session) => "pattern"),
241
+ headerRegex(
242
+ (_: Session) => "name",
243
+ (_: Session) => "pattern"
244
+ )
245
+ )
246
+ .checkIf("#{bool}")
247
+ .then(jsonPath("$..foo"))
248
+ .checkIf("#{bool}")
249
+ .then(jsonPath("$..foo"), jsonPath("$..foo"));
250
+ //.checkIf((response, session) -> true).then(jsonPath("$..foo"));
251
+
252
+ const scn = scenario("scenario")
253
+ .exec(
254
+ http("name")
255
+ .get("url")
256
+ .queryParam("key", "value")
257
+ .queryParam((_: Session) => "key", "value")
258
+ .queryParam("key", (_: Session) => "value")
259
+ .queryParam(
260
+ (_: Session) => "key",
261
+ (_: Session) => "value"
262
+ )
263
+ .queryParam("key", 1)
264
+ .queryParam((_: Session) => "key", 1)
265
+ .queryParam("key", (_: Session) => 1)
266
+ .queryParam(
267
+ (_: Session) => "key",
268
+ (_: Session) => 1
269
+ )
270
+ .multivaluedQueryParam("key", [1])
271
+ .multivaluedQueryParam((_: Session) => "key", [1])
272
+ .multivaluedQueryParam("key", (_: Session) => [1])
273
+ .multivaluedQueryParam(
274
+ (_: Session) => "key",
275
+ (_: Session) => [1]
276
+ )
277
+ .queryParamMap({ key: "value" })
278
+ .queryParamMap((_: Session) => ({ key: "value" }))
279
+ .header("key", "value")
280
+ .header("key", (_: Session) => "value")
281
+ .headers({ key: "value" })
282
+ .ignoreProtocolHeaders()
283
+ .asJson()
284
+ .asXml()
285
+ .basicAuth("username", "password")
286
+ .basicAuth("username", (_: Session) => "password")
287
+ .basicAuth((_: Session) => "username", "password")
288
+ .basicAuth(
289
+ (_: Session) => "username",
290
+ (_: Session) => "password"
291
+ )
292
+ .digestAuth("username", "password")
293
+ .digestAuth("username", (_: Session) => "password")
294
+ .digestAuth((_: Session) => "username", "password")
295
+ .digestAuth(
296
+ (_: Session) => "username",
297
+ (_: Session) => "password"
298
+ )
299
+ .disableUrlEncoding()
300
+ //.sign(request -> request)
301
+ //.sign((request, session) -> request)
302
+ .signWithOAuth1("consumerKey", "clientSharedSecret", "token", "tokenSecret")
303
+ .signWithOAuth1(
304
+ (_: Session) => "consumerKey",
305
+ (_: Session) => "clientSharedSecret",
306
+ (_: Session) => "token",
307
+ (_: Session) => "tokenSecret"
308
+ )
309
+ .ignoreProtocolChecks()
310
+ .silent()
311
+ .notSilent()
312
+ .disableFollowRedirect()
313
+ //.transformResponse((response, session) -> response)
314
+ .body(StringBody("static #{dynamic} static"))
315
+ .resources(http("name").get("url"), http("name").get("url"))
316
+ .asMultipartForm()
317
+ .asFormUrlEncoded()
318
+ .formParam("key", "value")
319
+ .formParam((_: Session) => "key", "value")
320
+ .formParam("key", (_: Session) => "value")
321
+ .formParam(
322
+ (_: Session) => "key",
323
+ (_: Session) => "value"
324
+ )
325
+ .formParam("key", 1)
326
+ .formParam((_: Session) => "key", 1)
327
+ .formParam("key", (_: Session) => 1)
328
+ .formParam(
329
+ (_: Session) => "key",
330
+ (_: Session) => 1
331
+ )
332
+ .multivaluedFormParam("key", [1])
333
+ .multivaluedFormParam((_: Session) => "key", [1])
334
+ .multivaluedFormParam("key", (_: Session) => [1])
335
+ .multivaluedFormParam(
336
+ (_: Session) => "key",
337
+ (_: Session) => [1]
338
+ )
339
+ .formParamMap({ key: "value" })
340
+ .formParamMap((_: Session) => ({ key: "value" }))
341
+ .form("#{key}")
342
+ .form((_: Session) => ({ key: "value" }))
343
+ .formUpload("name", "filePath")
344
+ .formUpload((_: Session) => "name", "filePath")
345
+ .formUpload("name", (_: Session) => "filePath")
346
+ .formUpload(
347
+ (_: Session) => "name",
348
+ (_: Session) => "filePath"
349
+ )
350
+ .bodyPart(RawFileBodyPart("name", "path"))
351
+ .bodyPart(ElFileBodyPart("name", "path"))
352
+ .bodyPart(ElFileBodyPart("name", "path").contentType("foo"))
353
+ //.bodyPart(PebbleFileBodyPart("name", "path"))
354
+ //.bodyPart(PebbleStringBodyPart("name", "somePebbleString"))
355
+ .bodyParts(RawFileBodyPart("name1", "path1"), RawFileBodyPart("name2", "path2"))
356
+ .requestTimeout(1)
357
+ .requestTimeout({ amount: 1, unit: "seconds" })
358
+ )
359
+ .exec(http("name").get((_: Session) => "url"))
360
+ .exec(http("name").put("url"))
361
+ .exec(http("name").put((_: Session) => "url"))
362
+ .exec(http("name").post("url"))
363
+ .exec(http("name").post((_: Session) => "url"))
364
+ .exec(http("name").patch("url"))
365
+ .exec(http("name").patch((_: Session) => "url"))
366
+ .exec(http("name").head("url"))
367
+ .exec(http("name").head((_: Session) => "url"))
368
+ .exec(http("name").delete("url"))
369
+ .exec(http("name").delete((_: Session) => "url"))
370
+ .exec(http("name").options("url"))
371
+ .exec(http("name").options((_: Session) => "url"))
372
+ .exec(http("name").httpRequest("JSON", "url"))
373
+ .exec(http("name").httpRequest("JSON", (_: Session) => "url"))
374
+ // check
375
+ .exec(
376
+ http("name")
377
+ .get("url")
378
+ .check(status().is(200))
379
+ .checkIf("#{bool}")
380
+ .then(jsonPath("$..foo"))
381
+ .checkIf("#{bool}")
382
+ .then(jsonPath("$..foo"), jsonPath("$..foo"))
383
+ //.checkIf((response, session) -> true).then(jsonPath("$..foo"))
384
+ )
385
+ // processRequestBody
386
+ //.exec(
387
+ // http("Request")
388
+ // .post("/things")
389
+ // .body(StringBody("FOO#{BAR}BAZ"))
390
+ // .processRequestBody(Function.identity())
391
+ //)
392
+ //.exec(
393
+ // http("Request")
394
+ // .post("/things")
395
+ // .body(ByteArrayBody("#{bytes}"))
396
+ // .processRequestBody(gzipBody)
397
+ //)
398
+ // proxy
399
+ .exec(http("Request").head("/").proxy(Proxy("172.31.76.106", 8080).https()))
400
+ .exec(http("Request").head("/").proxy(Proxy("172.31.76.106", 8080).socks4()))
401
+ .exec(http("Request").head("/").proxy(Proxy("172.31.76.106", 8080).socks5()))
402
+ // polling
403
+ .exec(poll().every(10).exec(http("poll").get("/foo")))
404
+ .exec(poll().pollerName("poll").every(10).exec(http("poll").get("/foo")))
405
+ .exec(poll().pollerName("poll").stop())
406
+ .exec(poll().stop())
407
+ // addCookie
408
+ .exec(addCookie(Cookie("foo", "bar").withDomain("foo.com")))
409
+ // getCookieValue
410
+ .exec(getCookieValue(CookieKey("foo").withDomain("foo.com").saveAs("newName")))
411
+ // flushSessionCookies
412
+ .exec(flushSessionCookies())
413
+ // flushCookieJar
414
+ .exec(flushCookieJar())
415
+ // flushHttpCache
416
+ .exec(flushHttpCache())
417
+ // feeder
418
+ .feed(sitemap("file"));
419
+
420
+ runSimulationMock((setUp) => {
421
+ setUp(
422
+ scn.injectOpen(atOnceUsers(1))
423
+ //.protocols(httpProtocol)
424
+ ).protocols(httpProtocol);
425
+ });
package/src/index.ts ADDED
@@ -0,0 +1,242 @@
1
+ import { Expression, Session, wrapSession } from "@gatling.io/core";
2
+ import { underlyingSessionTo } from "@gatling.io/core";
3
+ import { HttpDsl as JvmHttpDsl } from "@gatling.io/jvm-types";
4
+
5
+ import { HttpProtocolBuilder, wrapHttpProtocolBuilder } from "./protocol";
6
+ import { HttpRequestActionBuilder, Request, wrapHttpRequestActionBuilder, wrapRequest } from "./request";
7
+ import { Response, wrapResponse } from "./response";
8
+
9
+ export * from "./bodyPart";
10
+ export * from "./checks";
11
+ export * from "./cookies";
12
+ export * from "./feeders";
13
+ export * from "./headers";
14
+ export * from "./method";
15
+ export * from "./polling";
16
+ export * from "./protocol";
17
+ export * from "./proxy";
18
+ export * from "./request";
19
+ export * from "./response";
20
+
21
+ import JvmHttp = io.gatling.javaapi.http.Http;
22
+ import JvmRequest = io.gatling.http.client.Request;
23
+ import JvmResponse = io.gatling.http.response.Response;
24
+ import JvmSession = io.gatling.javaapi.core.Session;
25
+
26
+ export type RequestTransform = (request: Request, session: Session) => Request;
27
+
28
+ export const underlyingRequestTransform =
29
+ (f: RequestTransform): ((jvmRequest: JvmRequest, jvmSession: JvmSession) => JvmRequest) =>
30
+ (jvmRequest: JvmRequest, jvmSession: JvmSession) =>
31
+ f(wrapRequest(jvmRequest), wrapSession(jvmSession))._underlying;
32
+
33
+ export type ResponseTransform = (response: Response, session: Session) => Response;
34
+
35
+ export const underlyingResponseTransform =
36
+ (f: ResponseTransform): ((jvmResponse: JvmResponse, jvmSession: JvmSession) => JvmResponse) =>
37
+ (jvmResponse: JvmResponse, jvmSession: JvmSession) =>
38
+ f(wrapResponse(jvmResponse), wrapSession(jvmSession))._underlying;
39
+
40
+ const httpProtocolBuilder: HttpProtocolBuilder = wrapHttpProtocolBuilder(
41
+ // HttpDsl.http doesn't get properly generated by java2ts because of conflicts with methods of the same name
42
+ Java.type<any>("io.gatling.javaapi.http.HttpDsl").http
43
+ );
44
+
45
+ /**
46
+ * DSL for bootstrapping HTTP requests.
47
+ *
48
+ * <p>Immutable, so all methods return a new occurrence and leave the original unmodified.
49
+ */
50
+ export interface Http {
51
+ /**
52
+ * Define a GET request
53
+ *
54
+ * @param url - the url, expressed as a Gatling Expression Language String
55
+ * @returns a new instance of HttpRequestActionBuilder
56
+ */
57
+ get(url: string): HttpRequestActionBuilder;
58
+
59
+ /**
60
+ * Define a GET request
61
+ *
62
+ * @param url - the url, expressed as a function
63
+ * @returns a new instance of HttpRequestActionBuilder
64
+ */
65
+ get(url: (session: Session) => string): HttpRequestActionBuilder;
66
+
67
+ /**
68
+ * Define a PUT request
69
+ *
70
+ * @param url - the url, expressed as a Gatling Expression Language String
71
+ * @returns a new instance of HttpRequestActionBuilder
72
+ */
73
+ put(url: string): HttpRequestActionBuilder;
74
+
75
+ /**
76
+ * Define a PUT request
77
+ *
78
+ * @param url - the url, expressed as a function
79
+ * @returns a new instance of HttpRequestActionBuilder
80
+ */
81
+ put(url: (session: Session) => string): HttpRequestActionBuilder;
82
+
83
+ /**
84
+ * Define a POST request
85
+ *
86
+ * @param url - the url, expressed as a Gatling Expression Language String
87
+ * @returns a new instance of HttpRequestActionBuilder
88
+ */
89
+ post(url: string): HttpRequestActionBuilder;
90
+
91
+ /**
92
+ * Define a POST request
93
+ *
94
+ * @param url - the url, expressed as a function
95
+ * @returns a new instance of HttpRequestActionBuilder
96
+ */
97
+ post(url: (session: Session) => string): HttpRequestActionBuilder;
98
+
99
+ /**
100
+ * Define a PATCH request
101
+ *
102
+ * @param url - the url, expressed as a Gatling Expression Language String
103
+ * @returns a new instance of HttpRequestActionBuilder
104
+ */
105
+ patch(url: string): HttpRequestActionBuilder;
106
+
107
+ /**
108
+ * Define a PATCH request
109
+ *
110
+ * @param url - the url, expressed as a function
111
+ * @returns a new instance of HttpRequestActionBuilder
112
+ */
113
+ patch(url: (session: Session) => string): HttpRequestActionBuilder;
114
+
115
+ /**
116
+ * Define a HEAD request
117
+ *
118
+ * @param url - the url, expressed as a Gatling Expression Language String
119
+ * @returns a new instance of HttpRequestActionBuilder
120
+ */
121
+ head(url: string): HttpRequestActionBuilder;
122
+
123
+ /**
124
+ * Define a HEAD request
125
+ *
126
+ * @param url - the url, expressed as a function
127
+ * @returns a new instance of HttpRequestActionBuilder
128
+ */
129
+ head(url: (session: Session) => string): HttpRequestActionBuilder;
130
+
131
+ /**
132
+ * Define a DELETE request
133
+ *
134
+ * @param url - the url, expressed as a Gatling Expression Language String
135
+ * @returns a new instance of HttpRequestActionBuilder
136
+ */
137
+ delete(url: string): HttpRequestActionBuilder;
138
+
139
+ /**
140
+ * Define a DELETE request
141
+ *
142
+ * @param url - the url, expressed as a function
143
+ * @returns a new instance of HttpRequestActionBuilder
144
+ */
145
+ delete(url: (session: Session) => string): HttpRequestActionBuilder;
146
+
147
+ /**
148
+ * Define a OPTIONS request
149
+ *
150
+ * @param url - the url, expressed as a Gatling Expression Language String
151
+ * @returns a new instance of HttpRequestActionBuilder
152
+ */
153
+ options(url: string): HttpRequestActionBuilder;
154
+
155
+ /**
156
+ * Define a OPTIONS request
157
+ *
158
+ * @param url - the url, expressed as a function
159
+ * @returns a new instance of HttpRequestActionBuilder
160
+ */
161
+ options(url: (session: Session) => string): HttpRequestActionBuilder;
162
+
163
+ /**
164
+ * Define a HTTP request
165
+ *
166
+ * @param method - the HTTP method
167
+ * @param url - the url, expressed as a Gatling Expression Language String
168
+ * @returns a new instance of HttpRequestActionBuilder
169
+ */
170
+ httpRequest(method: string, url: string): HttpRequestActionBuilder;
171
+
172
+ /**
173
+ * Define a HTTP request
174
+ *
175
+ * @param method - the HTTP method
176
+ * @param url - the url, expressed as a function
177
+ * @returns a new instance of HttpRequestActionBuilder
178
+ */
179
+ httpRequest(method: string, url: (session: Session) => string): HttpRequestActionBuilder;
180
+ }
181
+
182
+ const wrapHttp = (jvmHttp: JvmHttp): Http => ({
183
+ get: (url: Expression<string>): HttpRequestActionBuilder =>
184
+ wrapHttpRequestActionBuilder(typeof url === "function" ? jvmHttp.get(underlyingSessionTo(url)) : jvmHttp.get(url)),
185
+ put: (url: Expression<string>): HttpRequestActionBuilder =>
186
+ wrapHttpRequestActionBuilder(typeof url === "function" ? jvmHttp.put(underlyingSessionTo(url)) : jvmHttp.put(url)),
187
+ post: (url: Expression<string>): HttpRequestActionBuilder =>
188
+ wrapHttpRequestActionBuilder(
189
+ typeof url === "function" ? jvmHttp.post(underlyingSessionTo(url)) : jvmHttp.post(url)
190
+ ),
191
+ patch: (url: Expression<string>): HttpRequestActionBuilder =>
192
+ wrapHttpRequestActionBuilder(
193
+ typeof url === "function" ? jvmHttp.patch(underlyingSessionTo(url)) : jvmHttp.patch(url)
194
+ ),
195
+ head: (url: Expression<string>): HttpRequestActionBuilder =>
196
+ wrapHttpRequestActionBuilder(
197
+ typeof url === "function" ? jvmHttp.head(underlyingSessionTo(url)) : jvmHttp.head(url)
198
+ ),
199
+ delete: (url: Expression<string>): HttpRequestActionBuilder =>
200
+ wrapHttpRequestActionBuilder(
201
+ typeof url === "function" ? jvmHttp.delete(underlyingSessionTo(url)) : jvmHttp.delete(url)
202
+ ),
203
+ options: (url: Expression<string>): HttpRequestActionBuilder =>
204
+ wrapHttpRequestActionBuilder(
205
+ typeof url === "function" ? jvmHttp.options(underlyingSessionTo(url)) : jvmHttp.options(url)
206
+ ),
207
+ httpRequest: (method: string, url: Expression<string>): HttpRequestActionBuilder =>
208
+ wrapHttpRequestActionBuilder(
209
+ typeof url === "function"
210
+ ? jvmHttp.httpRequest(method, underlyingSessionTo(url))
211
+ : jvmHttp.httpRequest(method, url)
212
+ )
213
+ });
214
+
215
+ /**
216
+ * The entrypoint of the Gatling HTTP DSL
217
+ */
218
+ export interface HttpApply {
219
+ /**
220
+ * Bootstrap a HTTP request configuration
221
+ *
222
+ * @param name - the HTTP request name, expressed as a Gatling Expression Language String
223
+ * @returns the next DSL step
224
+ */
225
+ (name: string): Http;
226
+
227
+ /**
228
+ * Bootstrap a HTTP request configuration
229
+ *
230
+ * @param name - the HTTP request name, expressed as a function
231
+ * @returns the next DSL step
232
+ */
233
+ (name: (session: Session) => string): Http;
234
+ }
235
+
236
+ const httpApply = (name: Expression<string>): Http => {
237
+ // Handle overloading
238
+ const jvmHttp = typeof name === "string" ? JvmHttpDsl.http(name) : JvmHttpDsl.http(underlyingSessionTo(name));
239
+ return wrapHttp(jvmHttp);
240
+ };
241
+
242
+ export const http: HttpApply & HttpProtocolBuilder = Object.assign(httpApply, httpProtocolBuilder);