@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.
package/src/proxy.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { Wrapper } from "@gatling.io/core";
2
+ import { HttpDsl as JvmHttpDsl } from "@gatling.io/jvm-types";
3
+
4
+ import JvmProxy = io.gatling.javaapi.http.Proxy;
5
+
6
+ export interface Proxy extends Wrapper<JvmProxy> {
7
+ /**
8
+ * Define this proxy is an HTTP one (default)
9
+ *
10
+ * @returns a new Proxy instance
11
+ */
12
+ http(): Proxy;
13
+
14
+ /**
15
+ * Define this proxy is an HTTPS one
16
+ *
17
+ * @returns a new Proxy instance
18
+ */
19
+ https(): Proxy;
20
+
21
+ /**
22
+ * Define this proxy is an SOCKS4 once
23
+ *
24
+ * @returns a new Proxy instance
25
+ */
26
+ socks4(): Proxy;
27
+
28
+ /**
29
+ * Define this proxy is an SOCKS5 once
30
+ *
31
+ * @returns a new Proxy instance
32
+ */
33
+ socks5(): Proxy;
34
+
35
+ /**
36
+ * Define some Basic Auth credentials for this proxy
37
+ *
38
+ * @param username - the username
39
+ * @param password - the password
40
+ * @returns a new Proxy instance
41
+ */
42
+ credentials(username: string, password: string): Proxy;
43
+ }
44
+
45
+ const wrapProxy = (_underlying: JvmProxy): Proxy => ({
46
+ _underlying,
47
+ http: (): Proxy => wrapProxy(_underlying.http()),
48
+ https: (): Proxy => wrapProxy(_underlying.https()),
49
+ socks4: (): Proxy => wrapProxy(_underlying.socks4()),
50
+ socks5: (): Proxy => wrapProxy(_underlying.socks5()),
51
+ credentials: (username: string, password: string): Proxy => wrapProxy(_underlying.credentials(username, password))
52
+ });
53
+
54
+ /**
55
+ * Bootstrap the DSL for defining a Proxy
56
+ *
57
+ * @param host - the proxy host
58
+ * @param port - the proxy prot
59
+ * @returns the next DSL step
60
+ */
61
+ export const Proxy = (host: string, port: number) => wrapProxy(JvmHttpDsl.Proxy(host, port));
@@ -0,0 +1,12 @@
1
+ import { Wrapper } from "@gatling.io/core";
2
+
3
+ import JvmRequestBody = io.gatling.http.client.body.RequestBody;
4
+
5
+ export interface RequestBody extends Wrapper<JvmRequestBody> {
6
+ bytes(): number[];
7
+ }
8
+
9
+ export const wrapRequestBody = (_underlying: JvmRequestBody): RequestBody => ({
10
+ _underlying,
11
+ bytes: (): number[] => _underlying.getBytes()
12
+ });