@readme/httpsnippet 3.1.1 → 4.0.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/README.md +63 -62
- package/package.json +26 -21
- package/src/fixtures/customTarget.ts +14 -0
- package/src/fixtures/files/hello.txt +1 -0
- package/src/fixtures/mimetypes.ts +84 -0
- package/src/fixtures/requests/application-form-encoded.js +68 -0
- package/src/fixtures/requests/application-json.js +71 -0
- package/src/fixtures/requests/cookies.js +50 -0
- package/src/fixtures/requests/custom-method.js +40 -0
- package/src/fixtures/requests/full.js +98 -0
- package/src/fixtures/requests/headers.js +55 -0
- package/src/fixtures/requests/http-insecure.js +44 -0
- package/src/fixtures/requests/jsonObj-multiline.js +58 -0
- package/src/fixtures/requests/jsonObj-null-value.js +65 -0
- package/src/fixtures/requests/multipart-data.js +71 -0
- package/src/fixtures/requests/multipart-file.js +64 -0
- package/src/fixtures/requests/multipart-form-data-no-params.js +55 -0
- package/src/fixtures/requests/multipart-form-data.js +63 -0
- package/src/fixtures/requests/nested.js +63 -0
- package/src/fixtures/requests/query-encoded.js +58 -0
- package/src/fixtures/requests/query.js +63 -0
- package/src/fixtures/requests/short.js +44 -0
- package/src/fixtures/requests/text-plain.js +56 -0
- package/src/fixtures/runCustomFixtures.ts +47 -0
- package/src/helpers/__snapshots__/utils.test.ts.snap +364 -0
- package/src/helpers/code-builder.test.ts +42 -0
- package/src/helpers/code-builder.ts +85 -0
- package/src/helpers/{form-data.js → form-data.ts} +13 -44
- package/src/helpers/har-validator.ts +35 -0
- package/src/helpers/headers.test.ts +35 -0
- package/src/helpers/headers.ts +31 -0
- package/src/helpers/reducer.test.ts +27 -0
- package/src/helpers/reducer.ts +19 -0
- package/src/helpers/shell.ts +18 -0
- package/src/helpers/utils.test.ts +19 -0
- package/src/helpers/utils.ts +16 -0
- package/src/index.test.ts +221 -0
- package/src/index.ts +361 -0
- package/src/integration.test.ts +270 -0
- package/src/targets/c/libcurl/client.ts +50 -0
- package/src/targets/c/libcurl/fixtures/application-form-encoded.c +12 -0
- package/src/targets/c/libcurl/fixtures/application-json.c +12 -0
- package/src/targets/c/libcurl/fixtures/cookies.c +8 -0
- package/src/targets/c/libcurl/fixtures/custom-method.c +6 -0
- package/src/targets/c/libcurl/fixtures/full.c +15 -0
- package/src/targets/c/libcurl/fixtures/headers.c +12 -0
- package/src/targets/c/libcurl/fixtures/http-insecure.c +6 -0
- package/src/targets/c/libcurl/fixtures/jsonObj-multiline.c +12 -0
- package/src/targets/c/libcurl/fixtures/jsonObj-null-value.c +12 -0
- package/src/targets/c/libcurl/fixtures/multipart-data.c +12 -0
- package/src/targets/c/libcurl/fixtures/multipart-file.c +12 -0
- package/src/targets/c/libcurl/fixtures/multipart-form-data-no-params.c +10 -0
- package/src/targets/c/libcurl/fixtures/multipart-form-data.c +12 -0
- package/src/targets/c/libcurl/fixtures/nested.c +6 -0
- package/src/targets/c/libcurl/fixtures/query-encoded.c +6 -0
- package/src/targets/c/libcurl/fixtures/query.c +6 -0
- package/src/targets/c/libcurl/fixtures/short.c +6 -0
- package/src/targets/c/libcurl/fixtures/text-plain.c +12 -0
- package/src/targets/c/target.ts +14 -0
- package/src/targets/clojure/clj_http/client.ts +210 -0
- package/src/targets/clojure/clj_http/fixtures/application-form-encoded.clj +4 -0
- package/src/targets/clojure/clj_http/fixtures/application-json.clj +9 -0
- package/src/targets/clojure/clj_http/fixtures/cookies.clj +3 -0
- package/src/targets/clojure/clj_http/fixtures/custom-method.clj +1 -0
- package/src/targets/clojure/clj_http/fixtures/full.clj +8 -0
- package/src/targets/clojure/clj_http/fixtures/headers.clj +5 -0
- package/src/targets/clojure/clj_http/fixtures/http-insecure.clj +3 -0
- package/src/targets/clojure/clj_http/fixtures/jsonObj-multiline.clj +4 -0
- package/src/targets/clojure/clj_http/fixtures/jsonObj-null-value.clj +4 -0
- package/src/targets/clojure/clj_http/fixtures/multipart-data.clj +5 -0
- package/src/targets/clojure/clj_http/fixtures/multipart-file.clj +4 -0
- package/src/targets/clojure/clj_http/fixtures/multipart-form-data-no-params.clj +3 -0
- package/src/targets/clojure/clj_http/fixtures/multipart-form-data.clj +4 -0
- package/src/targets/clojure/clj_http/fixtures/nested.clj +5 -0
- package/src/targets/clojure/clj_http/fixtures/query-encoded.clj +4 -0
- package/src/targets/clojure/clj_http/fixtures/query.clj +5 -0
- package/src/targets/clojure/clj_http/fixtures/short.clj +3 -0
- package/src/targets/clojure/clj_http/fixtures/text-plain.clj +3 -0
- package/src/targets/clojure/target.ts +14 -0
- package/src/targets/csharp/httpclient/client.ts +170 -0
- package/src/targets/csharp/httpclient/fixtures/application-form-encoded.cs +18 -0
- package/src/targets/csharp/httpclient/fixtures/application-json.cs +20 -0
- package/src/targets/csharp/httpclient/fixtures/cookies.cs +21 -0
- package/src/targets/csharp/httpclient/fixtures/custom-method.cs +13 -0
- package/src/targets/csharp/httpclient/fixtures/full.cs +26 -0
- package/src/targets/csharp/httpclient/fixtures/headers.cs +19 -0
- package/src/targets/csharp/httpclient/fixtures/http-insecure.cs +13 -0
- package/src/targets/csharp/httpclient/fixtures/jsonObj-multiline.cs +20 -0
- package/src/targets/csharp/httpclient/fixtures/jsonObj-null-value.cs +20 -0
- package/src/targets/csharp/httpclient/fixtures/multipart-data.cs +38 -0
- package/src/targets/csharp/httpclient/fixtures/multipart-file.cs +28 -0
- package/src/targets/csharp/httpclient/fixtures/multipart-form-data-no-params.cs +13 -0
- package/src/targets/csharp/httpclient/fixtures/multipart-form-data.cs +26 -0
- package/src/targets/csharp/httpclient/fixtures/nested.cs +13 -0
- package/src/targets/csharp/httpclient/fixtures/query-encoded.cs +13 -0
- package/src/targets/csharp/httpclient/fixtures/query.cs +13 -0
- package/src/targets/csharp/httpclient/fixtures/short.cs +13 -0
- package/src/targets/csharp/httpclient/fixtures/text-plain.cs +20 -0
- package/src/targets/csharp/restsharp/client.ts +44 -0
- package/src/targets/csharp/restsharp/fixtures/application-form-encoded.cs +5 -0
- package/src/targets/csharp/restsharp/fixtures/application-json.cs +5 -0
- package/src/targets/csharp/restsharp/fixtures/cookies.cs +5 -0
- package/src/targets/csharp/restsharp/fixtures/custom-method.cs +1 -0
- package/src/targets/csharp/restsharp/fixtures/full.cs +8 -0
- package/src/targets/csharp/restsharp/fixtures/headers.cs +6 -0
- package/src/targets/csharp/restsharp/fixtures/http-insecure.cs +3 -0
- package/src/targets/csharp/restsharp/fixtures/jsonObj-multiline.cs +5 -0
- package/src/targets/csharp/restsharp/fixtures/jsonObj-null-value.cs +5 -0
- package/src/targets/csharp/restsharp/fixtures/multipart-data.cs +5 -0
- package/src/targets/csharp/restsharp/fixtures/multipart-file.cs +5 -0
- package/src/targets/csharp/restsharp/fixtures/multipart-form-data-no-params.cs +4 -0
- package/src/targets/csharp/restsharp/fixtures/multipart-form-data.cs +5 -0
- package/src/targets/csharp/restsharp/fixtures/nested.cs +3 -0
- package/src/targets/csharp/restsharp/fixtures/query-encoded.cs +3 -0
- package/src/targets/csharp/restsharp/fixtures/query.cs +3 -0
- package/src/targets/csharp/restsharp/fixtures/short.cs +3 -0
- package/src/targets/csharp/restsharp/fixtures/text-plain.cs +5 -0
- package/src/targets/csharp/target.ts +17 -0
- package/src/targets/go/native/client.test.ts +42 -0
- package/src/targets/go/native/client.ts +143 -0
- package/src/targets/go/native/fixtures/application-form-encoded.go +28 -0
- package/src/targets/go/native/fixtures/application-json.go +28 -0
- package/src/targets/go/native/fixtures/boilerplate-option.go +17 -0
- package/src/targets/go/native/fixtures/check-errors-option.go +39 -0
- package/src/targets/go/native/fixtures/cookies.go +25 -0
- package/src/targets/go/native/fixtures/custom-method.go +23 -0
- package/src/targets/go/native/fixtures/full.go +30 -0
- package/src/targets/go/native/fixtures/headers.go +27 -0
- package/src/targets/go/native/fixtures/http-insecure.go +23 -0
- package/src/targets/go/native/fixtures/jsonObj-multiline.go +28 -0
- package/src/targets/go/native/fixtures/jsonObj-null-value.go +28 -0
- package/src/targets/go/native/fixtures/multipart-data.go +28 -0
- package/src/targets/go/native/fixtures/multipart-file.go +28 -0
- package/src/targets/go/native/fixtures/multipart-form-data-no-params.go +25 -0
- package/src/targets/go/native/fixtures/multipart-form-data.go +28 -0
- package/src/targets/go/native/fixtures/nested.go +23 -0
- package/src/targets/go/native/fixtures/print-body-option.go +25 -0
- package/src/targets/go/native/fixtures/query-encoded.go +23 -0
- package/src/targets/go/native/fixtures/query.go +23 -0
- package/src/targets/go/native/fixtures/short.go +23 -0
- package/src/targets/go/native/fixtures/text-plain.go +28 -0
- package/src/targets/go/native/fixtures/timeout-option.go +35 -0
- package/src/targets/go/target.ts +14 -0
- package/src/targets/har-schema.d.ts +4 -0
- package/src/targets/http/http1.1/client.ts +89 -0
- package/src/targets/http/http1.1/fixtures/application-form-encoded +6 -0
- package/src/targets/http/http1.1/fixtures/application-json +6 -0
- package/src/targets/http/http1.1/fixtures/cookies +4 -0
- package/src/targets/http/http1.1/fixtures/custom-method +3 -0
- package/src/targets/http/http1.1/fixtures/full +8 -0
- package/src/targets/http/http1.1/fixtures/headers +6 -0
- package/src/targets/http/http1.1/fixtures/http-insecure +3 -0
- package/src/targets/http/http1.1/fixtures/jsonObj-multiline +8 -0
- package/src/targets/http/http1.1/fixtures/jsonObj-null-value +6 -0
- package/src/targets/http/http1.1/fixtures/multipart-data +15 -0
- package/src/targets/http/http1.1/fixtures/multipart-file +11 -0
- package/src/targets/http/http1.1/fixtures/multipart-form-data +10 -0
- package/src/targets/http/http1.1/fixtures/multipart-form-data-no-params +4 -0
- package/src/targets/http/http1.1/fixtures/nested +3 -0
- package/src/targets/http/http1.1/fixtures/query +3 -0
- package/src/targets/http/http1.1/fixtures/query-encoded +3 -0
- package/src/targets/http/http1.1/fixtures/short +3 -0
- package/src/targets/http/http1.1/fixtures/text-plain +6 -0
- package/src/targets/http/target.ts +14 -0
- package/src/targets/java/asynchttp/client.ts +50 -0
- package/src/targets/java/asynchttp/fixtures/application-form-encoded.java +10 -0
- package/src/targets/java/asynchttp/fixtures/application-json.java +10 -0
- package/src/targets/java/asynchttp/fixtures/cookies.java +9 -0
- package/src/targets/java/asynchttp/fixtures/custom-method.java +8 -0
- package/src/targets/java/asynchttp/fixtures/full.java +12 -0
- package/src/targets/java/asynchttp/fixtures/headers.java +11 -0
- package/src/targets/java/asynchttp/fixtures/http-insecure.java +8 -0
- package/src/targets/java/asynchttp/fixtures/jsonObj-multiline.java +10 -0
- package/src/targets/java/asynchttp/fixtures/jsonObj-null-value.java +10 -0
- package/src/targets/java/asynchttp/fixtures/multipart-data.java +10 -0
- package/src/targets/java/asynchttp/fixtures/multipart-file.java +10 -0
- package/src/targets/java/asynchttp/fixtures/multipart-form-data-no-params.java +9 -0
- package/src/targets/java/asynchttp/fixtures/multipart-form-data.java +10 -0
- package/src/targets/java/asynchttp/fixtures/nested.java +8 -0
- package/src/targets/java/asynchttp/fixtures/query-encoded.java +8 -0
- package/src/targets/java/asynchttp/fixtures/query.java +8 -0
- package/src/targets/java/asynchttp/fixtures/short.java +8 -0
- package/src/targets/java/asynchttp/fixtures/text-plain.java +10 -0
- package/src/targets/java/nethttp/client.ts +58 -0
- package/src/targets/java/nethttp/fixtures/application-form-encoded.java +7 -0
- package/src/targets/java/nethttp/fixtures/application-json.java +7 -0
- package/src/targets/java/nethttp/fixtures/cookies.java +7 -0
- package/src/targets/java/nethttp/fixtures/custom-method.java +6 -0
- package/src/targets/java/nethttp/fixtures/full.java +9 -0
- package/src/targets/java/nethttp/fixtures/headers.java +9 -0
- package/src/targets/java/nethttp/fixtures/http-insecure.java +6 -0
- package/src/targets/java/nethttp/fixtures/jsonObj-multiline.java +7 -0
- package/src/targets/java/nethttp/fixtures/jsonObj-null-value.java +7 -0
- package/src/targets/java/nethttp/fixtures/multipart-data.java +7 -0
- package/src/targets/java/nethttp/fixtures/multipart-file.java +7 -0
- package/src/targets/java/nethttp/fixtures/multipart-form-data-no-params.java +7 -0
- package/src/targets/java/nethttp/fixtures/multipart-form-data.java +7 -0
- package/src/targets/java/nethttp/fixtures/nested.java +6 -0
- package/src/targets/java/nethttp/fixtures/query-encoded.java +6 -0
- package/src/targets/java/nethttp/fixtures/query.java +6 -0
- package/src/targets/java/nethttp/fixtures/short.java +6 -0
- package/src/targets/java/nethttp/fixtures/text-plain.java +7 -0
- package/src/targets/java/okhttp/client.ts +72 -0
- package/src/targets/java/okhttp/fixtures/application-form-encoded.java +11 -0
- package/src/targets/java/okhttp/fixtures/application-json.java +11 -0
- package/src/targets/java/okhttp/fixtures/cookies.java +9 -0
- package/src/targets/java/okhttp/fixtures/custom-method.java +8 -0
- package/src/targets/java/okhttp/fixtures/full.java +13 -0
- package/src/targets/java/okhttp/fixtures/headers.java +11 -0
- package/src/targets/java/okhttp/fixtures/http-insecure.java +8 -0
- package/src/targets/java/okhttp/fixtures/jsonObj-multiline.java +11 -0
- package/src/targets/java/okhttp/fixtures/jsonObj-null-value.java +11 -0
- package/src/targets/java/okhttp/fixtures/multipart-data.java +11 -0
- package/src/targets/java/okhttp/fixtures/multipart-file.java +11 -0
- package/src/targets/java/okhttp/fixtures/multipart-form-data-no-params.java +9 -0
- package/src/targets/java/okhttp/fixtures/multipart-form-data.java +11 -0
- package/src/targets/java/okhttp/fixtures/nested.java +8 -0
- package/src/targets/java/okhttp/fixtures/query-encoded.java +8 -0
- package/src/targets/java/okhttp/fixtures/query.java +8 -0
- package/src/targets/java/okhttp/fixtures/short.java +8 -0
- package/src/targets/java/okhttp/fixtures/text-plain.java +11 -0
- package/src/targets/java/target.ts +21 -0
- package/src/targets/java/unirest/client.ts +50 -0
- package/src/targets/java/unirest/fixtures/application-form-encoded.java +4 -0
- package/src/targets/java/unirest/fixtures/application-json.java +4 -0
- package/src/targets/java/unirest/fixtures/cookies.java +3 -0
- package/src/targets/java/unirest/fixtures/custom-method.java +2 -0
- package/src/targets/java/unirest/fixtures/full.java +6 -0
- package/src/targets/java/unirest/fixtures/headers.java +5 -0
- package/src/targets/java/unirest/fixtures/http-insecure.java +2 -0
- package/src/targets/java/unirest/fixtures/jsonObj-multiline.java +4 -0
- package/src/targets/java/unirest/fixtures/jsonObj-null-value.java +4 -0
- package/src/targets/java/unirest/fixtures/multipart-data.java +4 -0
- package/src/targets/java/unirest/fixtures/multipart-file.java +4 -0
- package/src/targets/java/unirest/fixtures/multipart-form-data-no-params.java +3 -0
- package/src/targets/java/unirest/fixtures/multipart-form-data.java +4 -0
- package/src/targets/java/unirest/fixtures/nested.java +2 -0
- package/src/targets/java/unirest/fixtures/query-encoded.java +2 -0
- package/src/targets/java/unirest/fixtures/query.java +2 -0
- package/src/targets/java/unirest/fixtures/short.java +2 -0
- package/src/targets/java/unirest/fixtures/text-plain.java +4 -0
- package/src/targets/javascript/axios/client.ts +109 -0
- package/src/targets/javascript/axios/fixtures/application-form-encoded.js +21 -0
- package/src/targets/javascript/axios/fixtures/application-json.js +24 -0
- package/src/targets/javascript/axios/fixtures/cookies.js +16 -0
- package/src/targets/javascript/axios/fixtures/custom-method.js +12 -0
- package/src/targets/javascript/axios/fixtures/full.js +25 -0
- package/src/targets/javascript/axios/fixtures/headers.js +16 -0
- package/src/targets/javascript/axios/fixtures/http-insecure.js +12 -0
- package/src/targets/javascript/axios/fixtures/jsonObj-multiline.js +17 -0
- package/src/targets/javascript/axios/fixtures/jsonObj-null-value.js +17 -0
- package/src/targets/javascript/axios/fixtures/multipart-data.js +21 -0
- package/src/targets/javascript/axios/fixtures/multipart-file.js +20 -0
- package/src/targets/javascript/axios/fixtures/multipart-form-data-no-params.js +16 -0
- package/src/targets/javascript/axios/fixtures/multipart-form-data.js +20 -0
- package/src/targets/javascript/axios/fixtures/nested.js +16 -0
- package/src/targets/javascript/axios/fixtures/query-encoded.js +19 -0
- package/src/targets/javascript/axios/fixtures/query.js +16 -0
- package/src/targets/javascript/axios/fixtures/short.js +12 -0
- package/src/targets/javascript/axios/fixtures/text-plain.js +17 -0
- package/src/targets/javascript/fetch/client.ts +129 -0
- package/src/targets/javascript/fetch/fixtures/application-form-encoded.js +10 -0
- package/src/targets/javascript/fetch/fixtures/application-json.js +17 -0
- package/src/targets/javascript/fetch/fixtures/cookies.js +6 -0
- package/src/targets/javascript/fetch/fixtures/custom-method.js +6 -0
- package/src/targets/javascript/fetch/fixtures/full.js +14 -0
- package/src/targets/javascript/fetch/fixtures/headers.js +9 -0
- package/src/targets/javascript/fetch/fixtures/http-insecure.js +6 -0
- package/src/targets/javascript/fetch/fixtures/jsonObj-multiline.js +10 -0
- package/src/targets/javascript/fetch/fixtures/jsonObj-null-value.js +10 -0
- package/src/targets/javascript/fetch/fixtures/multipart-data.js +12 -0
- package/src/targets/javascript/fetch/fixtures/multipart-file.js +11 -0
- package/src/targets/javascript/fetch/fixtures/multipart-form-data-no-params.js +6 -0
- package/src/targets/javascript/fetch/fixtures/multipart-form-data.js +11 -0
- package/src/targets/javascript/fetch/fixtures/nested.js +6 -0
- package/src/targets/javascript/fetch/fixtures/query-encoded.js +6 -0
- package/src/targets/javascript/fetch/fixtures/query.js +6 -0
- package/src/targets/javascript/fetch/fixtures/short.js +6 -0
- package/src/targets/javascript/fetch/fixtures/text-plain.js +6 -0
- package/src/targets/javascript/jquery/client.ts +95 -0
- package/src/targets/javascript/jquery/fixtures/application-form-encoded.js +17 -0
- package/src/targets/javascript/jquery/fixtures/application-json.js +15 -0
- package/src/targets/javascript/jquery/fixtures/cookies.js +13 -0
- package/src/targets/javascript/jquery/fixtures/custom-method.js +11 -0
- package/src/targets/javascript/jquery/fixtures/full.js +18 -0
- package/src/targets/javascript/jquery/fixtures/headers.js +15 -0
- package/src/targets/javascript/jquery/fixtures/http-insecure.js +11 -0
- package/src/targets/javascript/jquery/fixtures/jsonObj-multiline.js +15 -0
- package/src/targets/javascript/jquery/fixtures/jsonObj-null-value.js +15 -0
- package/src/targets/javascript/jquery/fixtures/multipart-data.js +19 -0
- package/src/targets/javascript/jquery/fixtures/multipart-file.js +18 -0
- package/src/targets/javascript/jquery/fixtures/multipart-form-data-no-params.js +13 -0
- package/src/targets/javascript/jquery/fixtures/multipart-form-data.js +18 -0
- package/src/targets/javascript/jquery/fixtures/nested.js +11 -0
- package/src/targets/javascript/jquery/fixtures/query-encoded.js +11 -0
- package/src/targets/javascript/jquery/fixtures/query.js +11 -0
- package/src/targets/javascript/jquery/fixtures/short.js +11 -0
- package/src/targets/javascript/jquery/fixtures/text-plain.js +14 -0
- package/src/targets/javascript/target.ts +21 -0
- package/src/targets/javascript/xhr/client.test.ts +18 -0
- package/src/targets/javascript/xhr/client.ts +100 -0
- package/src/targets/javascript/xhr/fixtures/application-form-encoded.js +15 -0
- package/src/targets/javascript/xhr/fixtures/application-json.js +34 -0
- package/src/targets/javascript/xhr/fixtures/cookies.js +15 -0
- package/src/targets/javascript/xhr/fixtures/cors.js +13 -0
- package/src/targets/javascript/xhr/fixtures/custom-method.js +14 -0
- package/src/targets/javascript/xhr/fixtures/full.js +17 -0
- package/src/targets/javascript/xhr/fixtures/headers.js +17 -0
- package/src/targets/javascript/xhr/fixtures/http-insecure.js +14 -0
- package/src/targets/javascript/xhr/fixtures/jsonObj-multiline.js +17 -0
- package/src/targets/javascript/xhr/fixtures/jsonObj-null-value.js +17 -0
- package/src/targets/javascript/xhr/fixtures/multipart-data.js +16 -0
- package/src/targets/javascript/xhr/fixtures/multipart-file.js +15 -0
- package/src/targets/javascript/xhr/fixtures/multipart-form-data-no-params.js +13 -0
- package/src/targets/javascript/xhr/fixtures/multipart-form-data.js +15 -0
- package/src/targets/javascript/xhr/fixtures/nested.js +14 -0
- package/src/targets/javascript/xhr/fixtures/query-encoded.js +14 -0
- package/src/targets/javascript/xhr/fixtures/query.js +14 -0
- package/src/targets/javascript/xhr/fixtures/short.js +14 -0
- package/src/targets/javascript/xhr/fixtures/text-plain.js +15 -0
- package/src/targets/kotlin/okhttp/client.ts +73 -0
- package/src/targets/kotlin/okhttp/fixtures/application-form-encoded.kt +11 -0
- package/src/targets/kotlin/okhttp/fixtures/application-json.kt +11 -0
- package/src/targets/kotlin/okhttp/fixtures/cookies.kt +9 -0
- package/src/targets/kotlin/okhttp/fixtures/custom-method.kt +8 -0
- package/src/targets/kotlin/okhttp/fixtures/full.kt +13 -0
- package/src/targets/kotlin/okhttp/fixtures/headers.kt +11 -0
- package/src/targets/kotlin/okhttp/fixtures/http-insecure.kt +8 -0
- package/src/targets/kotlin/okhttp/fixtures/jsonObj-multiline.kt +11 -0
- package/src/targets/kotlin/okhttp/fixtures/jsonObj-null-value.kt +11 -0
- package/src/targets/kotlin/okhttp/fixtures/multipart-data.kt +11 -0
- package/src/targets/kotlin/okhttp/fixtures/multipart-file.kt +11 -0
- package/src/targets/kotlin/okhttp/fixtures/multipart-form-data-no-params.kt +9 -0
- package/src/targets/kotlin/okhttp/fixtures/multipart-form-data.kt +11 -0
- package/src/targets/kotlin/okhttp/fixtures/nested.kt +8 -0
- package/src/targets/kotlin/okhttp/fixtures/query-encoded.kt +8 -0
- package/src/targets/kotlin/okhttp/fixtures/query.kt +8 -0
- package/src/targets/kotlin/okhttp/fixtures/short.kt +8 -0
- package/src/targets/kotlin/okhttp/fixtures/text-plain.kt +11 -0
- package/src/targets/kotlin/target.ts +14 -0
- package/src/targets/node/axios/client.ts +89 -0
- package/src/targets/node/axios/fixtures/application-form-encoded.js +22 -0
- package/src/targets/node/axios/fixtures/application-json.js +24 -0
- package/src/targets/node/axios/fixtures/cookies.js +16 -0
- package/src/targets/node/axios/fixtures/custom-method.js +12 -0
- package/src/targets/node/axios/fixtures/full.js +25 -0
- package/src/targets/node/axios/fixtures/headers.js +16 -0
- package/src/targets/node/axios/fixtures/http-insecure.js +12 -0
- package/src/targets/node/axios/fixtures/jsonObj-multiline.js +17 -0
- package/src/targets/node/axios/fixtures/jsonObj-null-value.js +17 -0
- package/src/targets/node/axios/fixtures/multipart-data.js +17 -0
- package/src/targets/node/axios/fixtures/multipart-file.js +17 -0
- package/src/targets/node/axios/fixtures/multipart-form-data-no-params.js +16 -0
- package/src/targets/node/axios/fixtures/multipart-form-data.js +17 -0
- package/src/targets/node/axios/fixtures/nested.js +15 -0
- package/src/targets/node/axios/fixtures/query-encoded.js +15 -0
- package/src/targets/node/axios/fixtures/query.js +15 -0
- package/src/targets/node/axios/fixtures/short.js +12 -0
- package/src/targets/node/axios/fixtures/text-plain.js +17 -0
- package/src/targets/node/fetch/client.ts +153 -0
- package/src/targets/node/fetch/fixtures/application-form-encoded.js +18 -0
- package/src/targets/node/fetch/fixtures/application-json.js +20 -0
- package/src/targets/node/fetch/fixtures/cookies.js +9 -0
- package/src/targets/node/fetch/fixtures/custom-method.js +9 -0
- package/src/targets/node/fetch/fixtures/full.js +21 -0
- package/src/targets/node/fetch/fixtures/headers.js +12 -0
- package/src/targets/node/fetch/fixtures/http-insecure.js +9 -0
- package/src/targets/node/fetch/fixtures/jsonObj-multiline.js +13 -0
- package/src/targets/node/fetch/fixtures/jsonObj-null-value.js +13 -0
- package/src/targets/node/fetch/fixtures/multipart-data.js +17 -0
- package/src/targets/node/fetch/fixtures/multipart-file.js +16 -0
- package/src/targets/node/fetch/fixtures/multipart-form-data-no-params.js +9 -0
- package/src/targets/node/fetch/fixtures/multipart-form-data.js +15 -0
- package/src/targets/node/fetch/fixtures/nested.js +9 -0
- package/src/targets/node/fetch/fixtures/query-encoded.js +9 -0
- package/src/targets/node/fetch/fixtures/query.js +9 -0
- package/src/targets/node/fetch/fixtures/short.js +9 -0
- package/src/targets/node/fetch/fixtures/text-plain.js +9 -0
- package/src/targets/node/native/client.ts +91 -0
- package/src/targets/node/native/fixtures/application-form-encoded.js +28 -0
- package/src/targets/node/native/fixtures/application-json.js +34 -0
- package/src/targets/node/native/fixtures/cookies.js +26 -0
- package/src/targets/node/native/fixtures/custom-method.js +24 -0
- package/src/targets/node/native/fixtures/full.js +30 -0
- package/src/targets/node/native/fixtures/headers.js +28 -0
- package/src/targets/node/native/fixtures/http-insecure.js +24 -0
- package/src/targets/node/native/fixtures/jsonObj-multiline.js +27 -0
- package/src/targets/node/native/fixtures/jsonObj-null-value.js +27 -0
- package/src/targets/node/native/fixtures/multipart-data.js +27 -0
- package/src/targets/node/native/fixtures/multipart-file.js +27 -0
- package/src/targets/node/native/fixtures/multipart-form-data-no-params.js +26 -0
- package/src/targets/node/native/fixtures/multipart-form-data.js +27 -0
- package/src/targets/node/native/fixtures/nested.js +24 -0
- package/src/targets/node/native/fixtures/query-encoded.js +24 -0
- package/src/targets/node/native/fixtures/query.js +24 -0
- package/src/targets/node/native/fixtures/short.js +24 -0
- package/src/targets/node/native/fixtures/text-plain.js +27 -0
- package/src/targets/node/request/client.ts +130 -0
- package/src/targets/node/request/fixtures/application-form-encoded.js +14 -0
- package/src/targets/node/request/fixtures/application-json.js +22 -0
- package/src/targets/node/request/fixtures/cookies.js +13 -0
- package/src/targets/node/request/fixtures/custom-method.js +9 -0
- package/src/targets/node/request/fixtures/full.js +22 -0
- package/src/targets/node/request/fixtures/headers.js +13 -0
- package/src/targets/node/request/fixtures/http-insecure.js +9 -0
- package/src/targets/node/request/fixtures/jsonObj-multiline.js +15 -0
- package/src/targets/node/request/fixtures/jsonObj-null-value.js +15 -0
- package/src/targets/node/request/fixtures/multipart-data.js +21 -0
- package/src/targets/node/request/fixtures/multipart-file.js +20 -0
- package/src/targets/node/request/fixtures/multipart-form-data-no-params.js +13 -0
- package/src/targets/node/request/fixtures/multipart-form-data.js +14 -0
- package/src/targets/node/request/fixtures/nested.js +12 -0
- package/src/targets/node/request/fixtures/query-encoded.js +12 -0
- package/src/targets/node/request/fixtures/query.js +12 -0
- package/src/targets/node/request/fixtures/short.js +9 -0
- package/src/targets/node/request/fixtures/text-plain.js +14 -0
- package/src/targets/node/target.ts +23 -0
- package/src/targets/node/unirest/client.ts +129 -0
- package/src/targets/node/unirest/fixtures/application-form-encoded.js +18 -0
- package/src/targets/node/unirest/fixtures/application-json.js +35 -0
- package/src/targets/node/unirest/fixtures/cookies.js +14 -0
- package/src/targets/node/unirest/fixtures/custom-method.js +9 -0
- package/src/targets/node/unirest/fixtures/full.js +32 -0
- package/src/targets/node/unirest/fixtures/headers.js +15 -0
- package/src/targets/node/unirest/fixtures/http-insecure.js +9 -0
- package/src/targets/node/unirest/fixtures/jsonObj-multiline.js +18 -0
- package/src/targets/node/unirest/fixtures/jsonObj-null-value.js +18 -0
- package/src/targets/node/unirest/fixtures/multipart-data.js +23 -0
- package/src/targets/node/unirest/fixtures/multipart-file.js +21 -0
- package/src/targets/node/unirest/fixtures/multipart-form-data-no-params.js +13 -0
- package/src/targets/node/unirest/fixtures/multipart-form-data.js +19 -0
- package/src/targets/node/unirest/fixtures/nested.js +15 -0
- package/src/targets/node/unirest/fixtures/query-encoded.js +14 -0
- package/src/targets/node/unirest/fixtures/query.js +18 -0
- package/src/targets/node/unirest/fixtures/short.js +9 -0
- package/src/targets/node/unirest/fixtures/text-plain.js +15 -0
- package/src/targets/objc/helpers.ts +60 -0
- package/src/targets/objc/nsurlsession/client.test.ts +36 -0
- package/src/targets/objc/nsurlsession/client.ts +164 -0
- package/src/targets/objc/nsurlsession/fixtures/application-form-encoded.m +25 -0
- package/src/targets/objc/nsurlsession/fixtures/application-json.m +30 -0
- package/src/targets/objc/nsurlsession/fixtures/cookies.m +21 -0
- package/src/targets/objc/nsurlsession/fixtures/custom-method.m +18 -0
- package/src/targets/objc/nsurlsession/fixtures/full.m +26 -0
- package/src/targets/objc/nsurlsession/fixtures/headers.m +23 -0
- package/src/targets/objc/nsurlsession/fixtures/http-insecure.m +18 -0
- package/src/targets/objc/nsurlsession/fixtures/indent-option.m +18 -0
- package/src/targets/objc/nsurlsession/fixtures/json-with-null-value.m +25 -0
- package/src/targets/objc/nsurlsession/fixtures/jsonObj-multiline.m +25 -0
- package/src/targets/objc/nsurlsession/fixtures/jsonObj-null-value.m +25 -0
- package/src/targets/objc/nsurlsession/fixtures/multipart-data.m +44 -0
- package/src/targets/objc/nsurlsession/fixtures/multipart-file.m +43 -0
- package/src/targets/objc/nsurlsession/fixtures/multipart-form-data-no-params.m +21 -0
- package/src/targets/objc/nsurlsession/fixtures/multipart-form-data.m +43 -0
- package/src/targets/objc/nsurlsession/fixtures/nested.m +18 -0
- package/src/targets/objc/nsurlsession/fixtures/pretty-option.m +24 -0
- package/src/targets/objc/nsurlsession/fixtures/query-encoded.m +18 -0
- package/src/targets/objc/nsurlsession/fixtures/query.m +18 -0
- package/src/targets/objc/nsurlsession/fixtures/short.m +18 -0
- package/src/targets/objc/nsurlsession/fixtures/text-plain.m +24 -0
- package/src/targets/objc/nsurlsession/fixtures/timeout-option.m +18 -0
- package/src/targets/objc/target.ts +14 -0
- package/src/targets/ocaml/cohttp/client.ts +72 -0
- package/src/targets/ocaml/cohttp/fixtures/application-form-encoded.ml +11 -0
- package/src/targets/ocaml/cohttp/fixtures/application-json.ml +11 -0
- package/src/targets/ocaml/cohttp/fixtures/cookies.ml +10 -0
- package/src/targets/ocaml/cohttp/fixtures/custom-method.ml +9 -0
- package/src/targets/ocaml/cohttp/fixtures/full.ml +15 -0
- package/src/targets/ocaml/cohttp/fixtures/headers.ml +14 -0
- package/src/targets/ocaml/cohttp/fixtures/http-insecure.ml +9 -0
- package/src/targets/ocaml/cohttp/fixtures/jsonObj-multiline.ml +11 -0
- package/src/targets/ocaml/cohttp/fixtures/jsonObj-null-value.ml +11 -0
- package/src/targets/ocaml/cohttp/fixtures/multipart-data.ml +11 -0
- package/src/targets/ocaml/cohttp/fixtures/multipart-file.ml +11 -0
- package/src/targets/ocaml/cohttp/fixtures/multipart-form-data-no-params.ml +10 -0
- package/src/targets/ocaml/cohttp/fixtures/multipart-form-data.ml +11 -0
- package/src/targets/ocaml/cohttp/fixtures/nested.ml +9 -0
- package/src/targets/ocaml/cohttp/fixtures/query-encoded.ml +9 -0
- package/src/targets/ocaml/cohttp/fixtures/query.ml +9 -0
- package/src/targets/ocaml/cohttp/fixtures/short.ml +9 -0
- package/src/targets/ocaml/cohttp/fixtures/text-plain.ml +11 -0
- package/src/targets/ocaml/target.ts +14 -0
- package/src/targets/php/curl/client.ts +154 -0
- package/src/targets/php/curl/fixtures/application-form-encoded.php +28 -0
- package/src/targets/php/curl/fixtures/application-json.php +28 -0
- package/src/targets/php/curl/fixtures/cookies.php +25 -0
- package/src/targets/php/curl/fixtures/custom-method.php +24 -0
- package/src/targets/php/curl/fixtures/full.php +30 -0
- package/src/targets/php/curl/fixtures/headers.php +29 -0
- package/src/targets/php/curl/fixtures/http-insecure.php +24 -0
- package/src/targets/php/curl/fixtures/jsonObj-multiline.php +28 -0
- package/src/targets/php/curl/fixtures/jsonObj-null-value.php +28 -0
- package/src/targets/php/curl/fixtures/multipart-data.php +28 -0
- package/src/targets/php/curl/fixtures/multipart-file.php +28 -0
- package/src/targets/php/curl/fixtures/multipart-form-data-no-params.php +28 -0
- package/src/targets/php/curl/fixtures/multipart-form-data.php +28 -0
- package/src/targets/php/curl/fixtures/nested.php +24 -0
- package/src/targets/php/curl/fixtures/query-encoded.php +24 -0
- package/src/targets/php/curl/fixtures/query.php +24 -0
- package/src/targets/php/curl/fixtures/short.php +24 -0
- package/src/targets/php/curl/fixtures/text-plain.php +28 -0
- package/src/targets/php/guzzle/client.ts +151 -0
- package/src/targets/php/guzzle/fixtures/application-form-encoded.php +16 -0
- package/src/targets/php/guzzle/fixtures/application-json.php +13 -0
- package/src/targets/php/guzzle/fixtures/cookies.php +12 -0
- package/src/targets/php/guzzle/fixtures/custom-method.php +8 -0
- package/src/targets/php/guzzle/fixtures/full.php +17 -0
- package/src/targets/php/guzzle/fixtures/headers.php +14 -0
- package/src/targets/php/guzzle/fixtures/http-insecure.php +8 -0
- package/src/targets/php/guzzle/fixtures/jsonObj-multiline.php +15 -0
- package/src/targets/php/guzzle/fixtures/jsonObj-null-value.php +13 -0
- package/src/targets/php/guzzle/fixtures/multipart-data.php +23 -0
- package/src/targets/php/guzzle/fixtures/multipart-file.php +19 -0
- package/src/targets/php/guzzle/fixtures/multipart-form-data-no-params.php +12 -0
- package/src/targets/php/guzzle/fixtures/multipart-form-data.php +15 -0
- package/src/targets/php/guzzle/fixtures/nested.php +8 -0
- package/src/targets/php/guzzle/fixtures/query-encoded.php +8 -0
- package/src/targets/php/guzzle/fixtures/query.php +8 -0
- package/src/targets/php/guzzle/fixtures/short.php +8 -0
- package/src/targets/php/guzzle/fixtures/text-plain.php +13 -0
- package/src/targets/php/helpers.ts +67 -0
- package/src/targets/php/http1/client.ts +103 -0
- package/src/targets/php/http1/fixtures/application-form-encoded.php +23 -0
- package/src/targets/php/http1/fixtures/application-json.php +19 -0
- package/src/targets/php/http1/fixtures/cookies.php +18 -0
- package/src/targets/php/http1/fixtures/custom-method.php +13 -0
- package/src/targets/php/http1/fixtures/full.php +37 -0
- package/src/targets/php/http1/fixtures/headers.php +19 -0
- package/src/targets/php/http1/fixtures/http-insecure.php +13 -0
- package/src/targets/php/http1/fixtures/jsonObj-multiline.php +21 -0
- package/src/targets/php/http1/fixtures/jsonObj-null-value.php +19 -0
- package/src/targets/php/http1/fixtures/multipart-data.php +29 -0
- package/src/targets/php/http1/fixtures/multipart-file.php +25 -0
- package/src/targets/php/http1/fixtures/multipart-form-data-no-params.php +17 -0
- package/src/targets/php/http1/fixtures/multipart-form-data.php +24 -0
- package/src/targets/php/http1/fixtures/nested.php +19 -0
- package/src/targets/php/http1/fixtures/query-encoded.php +18 -0
- package/src/targets/php/http1/fixtures/query.php +22 -0
- package/src/targets/php/http1/fixtures/short.php +13 -0
- package/src/targets/php/http1/fixtures/text-plain.php +19 -0
- package/src/targets/php/http2/client.ts +153 -0
- package/src/targets/php/http2/fixtures/application-form-encoded.php +23 -0
- package/src/targets/php/http2/fixtures/application-json.php +20 -0
- package/src/targets/php/http2/fixtures/cookies.php +17 -0
- package/src/targets/php/http2/fixtures/custom-method.php +11 -0
- package/src/targets/php/http2/fixtures/full.php +38 -0
- package/src/targets/php/http2/fixtures/headers.php +17 -0
- package/src/targets/php/http2/fixtures/http-insecure.php +11 -0
- package/src/targets/php/http2/fixtures/jsonObj-multiline.php +22 -0
- package/src/targets/php/http2/fixtures/jsonObj-null-value.php +20 -0
- package/src/targets/php/http2/fixtures/multipart-data.php +25 -0
- package/src/targets/php/http2/fixtures/multipart-file.php +23 -0
- package/src/targets/php/http2/fixtures/multipart-form-data-no-params.php +15 -0
- package/src/targets/php/http2/fixtures/multipart-form-data.php +18 -0
- package/src/targets/php/http2/fixtures/nested.php +17 -0
- package/src/targets/php/http2/fixtures/query-encoded.php +16 -0
- package/src/targets/php/http2/fixtures/query.php +20 -0
- package/src/targets/php/http2/fixtures/short.php +11 -0
- package/src/targets/php/http2/fixtures/text-plain.php +20 -0
- package/src/targets/php/target.ts +21 -0
- package/src/targets/powershell/common.ts +58 -0
- package/src/targets/powershell/restmethod/client.ts +12 -0
- package/src/targets/powershell/restmethod/fixtures/application-form-encoded.ps1 +3 -0
- package/src/targets/powershell/restmethod/fixtures/application-json.ps1 +3 -0
- package/src/targets/powershell/restmethod/fixtures/cookies.ps1 +12 -0
- package/src/targets/powershell/restmethod/fixtures/custom-method.ps1 +1 -0
- package/src/targets/powershell/restmethod/fixtures/full.ps1 +15 -0
- package/src/targets/powershell/restmethod/fixtures/headers.ps1 +5 -0
- package/src/targets/powershell/restmethod/fixtures/http-insecure.ps1 +1 -0
- package/src/targets/powershell/restmethod/fixtures/jsonObj-multiline.ps1 +5 -0
- package/src/targets/powershell/restmethod/fixtures/jsonObj-null-value.ps1 +3 -0
- package/src/targets/powershell/restmethod/fixtures/multipart-data.ps1 +13 -0
- package/src/targets/powershell/restmethod/fixtures/multipart-file.ps1 +9 -0
- package/src/targets/powershell/restmethod/fixtures/multipart-form-data-no-params.ps1 +3 -0
- package/src/targets/powershell/restmethod/fixtures/multipart-form-data.ps1 +8 -0
- package/src/targets/powershell/restmethod/fixtures/nested.ps1 +1 -0
- package/src/targets/powershell/restmethod/fixtures/query-encoded.ps1 +1 -0
- package/src/targets/powershell/restmethod/fixtures/query.ps1 +1 -0
- package/src/targets/powershell/restmethod/fixtures/short.ps1 +1 -0
- package/src/targets/powershell/restmethod/fixtures/text-plain.ps1 +3 -0
- package/src/targets/powershell/target.ts +16 -0
- package/src/targets/powershell/webrequest/client.ts +12 -0
- package/src/targets/powershell/webrequest/fixtures/application-form-encoded.ps1 +3 -0
- package/src/targets/powershell/webrequest/fixtures/application-json.ps1 +3 -0
- package/src/targets/powershell/webrequest/fixtures/cookies.ps1 +12 -0
- package/src/targets/powershell/webrequest/fixtures/custom-method.ps1 +1 -0
- package/src/targets/powershell/webrequest/fixtures/full.ps1 +15 -0
- package/src/targets/powershell/webrequest/fixtures/headers.ps1 +5 -0
- package/src/targets/powershell/webrequest/fixtures/http-insecure.ps1 +1 -0
- package/src/targets/powershell/webrequest/fixtures/jsonObj-multiline.ps1 +5 -0
- package/src/targets/powershell/webrequest/fixtures/jsonObj-null-value.ps1 +3 -0
- package/src/targets/powershell/webrequest/fixtures/multipart-data.ps1 +13 -0
- package/src/targets/powershell/webrequest/fixtures/multipart-file.ps1 +9 -0
- package/src/targets/powershell/webrequest/fixtures/multipart-form-data-no-params.ps1 +3 -0
- package/src/targets/powershell/webrequest/fixtures/multipart-form-data.ps1 +8 -0
- package/src/targets/powershell/webrequest/fixtures/nested.ps1 +1 -0
- package/src/targets/powershell/webrequest/fixtures/query-encoded.ps1 +1 -0
- package/src/targets/powershell/webrequest/fixtures/query.ps1 +1 -0
- package/src/targets/powershell/webrequest/fixtures/short.ps1 +1 -0
- package/src/targets/powershell/webrequest/fixtures/text-plain.ps1 +3 -0
- package/src/targets/python/helpers.ts +81 -0
- package/src/targets/python/requests/client.ts +175 -0
- package/src/targets/python/requests/fixtures/application-form-encoded.py +10 -0
- package/src/targets/python/requests/fixtures/application-json.py +17 -0
- package/src/targets/python/requests/fixtures/cookies.py +9 -0
- package/src/targets/python/requests/fixtures/custom-method.py +7 -0
- package/src/targets/python/requests/fixtures/full.py +14 -0
- package/src/targets/python/requests/fixtures/headers.py +13 -0
- package/src/targets/python/requests/fixtures/http-insecure.py +7 -0
- package/src/targets/python/requests/fixtures/jsonObj-multiline.py +10 -0
- package/src/targets/python/requests/fixtures/jsonObj-null-value.py +10 -0
- package/src/targets/python/requests/fixtures/multipart-data.py +10 -0
- package/src/targets/python/requests/fixtures/multipart-file.py +9 -0
- package/src/targets/python/requests/fixtures/multipart-form-data-no-params.py +9 -0
- package/src/targets/python/requests/fixtures/multipart-form-data.py +10 -0
- package/src/targets/python/requests/fixtures/nested.py +7 -0
- package/src/targets/python/requests/fixtures/query-encoded.py +7 -0
- package/src/targets/python/requests/fixtures/query.py +7 -0
- package/src/targets/python/requests/fixtures/short.py +7 -0
- package/src/targets/python/requests/fixtures/text-plain.py +10 -0
- package/src/targets/python/target.ts +15 -0
- package/src/targets/r/httr/client.test.ts +29 -0
- package/src/targets/r/httr/client.ts +146 -0
- package/src/targets/r/httr/fixtures/application-form-encoded.r +11 -0
- package/src/targets/r/httr/fixtures/application-json.r +11 -0
- package/src/targets/r/httr/fixtures/cookies.r +7 -0
- package/src/targets/r/httr/fixtures/custom-method.r +7 -0
- package/src/targets/r/httr/fixtures/full.r +16 -0
- package/src/targets/r/httr/fixtures/headers.r +7 -0
- package/src/targets/r/httr/fixtures/http-insecure.r +7 -0
- package/src/targets/r/httr/fixtures/jsonObj-multiline.r +11 -0
- package/src/targets/r/httr/fixtures/jsonObj-null-value.r +11 -0
- package/src/targets/r/httr/fixtures/multipart-data.r +11 -0
- package/src/targets/r/httr/fixtures/multipart-file.r +11 -0
- package/src/targets/r/httr/fixtures/multipart-form-data-no-params.r +9 -0
- package/src/targets/r/httr/fixtures/multipart-form-data.r +11 -0
- package/src/targets/r/httr/fixtures/nested.r +12 -0
- package/src/targets/r/httr/fixtures/query-encoded.r +12 -0
- package/src/targets/r/httr/fixtures/query-two-params.r +12 -0
- package/src/targets/r/httr/fixtures/query.r +12 -0
- package/src/targets/r/httr/fixtures/short.r +7 -0
- package/src/targets/r/httr/fixtures/text-plain.r +11 -0
- package/src/targets/r/target.ts +14 -0
- package/src/targets/ruby/native/client.ts +78 -0
- package/src/targets/ruby/native/fixtures/application-form-encoded.rb +15 -0
- package/src/targets/ruby/native/fixtures/application-json.rb +15 -0
- package/src/targets/ruby/native/fixtures/cookies.rb +14 -0
- package/src/targets/ruby/native/fixtures/custom-method.rb +19 -0
- package/src/targets/ruby/native/fixtures/full.rb +17 -0
- package/src/targets/ruby/native/fixtures/headers.rb +16 -0
- package/src/targets/ruby/native/fixtures/http-insecure.rb +11 -0
- package/src/targets/ruby/native/fixtures/jsonObj-multiline.rb +15 -0
- package/src/targets/ruby/native/fixtures/jsonObj-null-value.rb +15 -0
- package/src/targets/ruby/native/fixtures/multipart-data.rb +15 -0
- package/src/targets/ruby/native/fixtures/multipart-file.rb +15 -0
- package/src/targets/ruby/native/fixtures/multipart-form-data-no-params.rb +14 -0
- package/src/targets/ruby/native/fixtures/multipart-form-data.rb +15 -0
- package/src/targets/ruby/native/fixtures/nested.rb +13 -0
- package/src/targets/ruby/native/fixtures/query-encoded.rb +13 -0
- package/src/targets/ruby/native/fixtures/query.rb +13 -0
- package/src/targets/ruby/native/fixtures/short.rb +13 -0
- package/src/targets/ruby/native/fixtures/text-plain.rb +15 -0
- package/src/targets/ruby/target.ts +14 -0
- package/src/targets/shell/curl/client.test.ts +157 -0
- package/src/targets/shell/curl/client.ts +193 -0
- package/src/targets/shell/curl/fixtures/application-form-encoded.sh +5 -0
- package/src/targets/shell/curl/fixtures/application-json.sh +25 -0
- package/src/targets/shell/curl/fixtures/binary-option.sh +1 -0
- package/src/targets/shell/curl/fixtures/cookies.sh +3 -0
- package/src/targets/shell/curl/fixtures/custom-indentation.sh +6 -0
- package/src/targets/shell/curl/fixtures/custom-method.sh +2 -0
- package/src/targets/shell/curl/fixtures/dont-deglob.sh +1 -0
- package/src/targets/shell/curl/fixtures/full.sh +6 -0
- package/src/targets/shell/curl/fixtures/globoff-option.sh +1 -0
- package/src/targets/shell/curl/fixtures/harIsAlreadyEncoded-option-already-encoded.sh +3 -0
- package/src/targets/shell/curl/fixtures/harIsAlreadyEncoded=option-escape-brackets.sh +2 -0
- package/src/targets/shell/curl/fixtures/headers.sh +5 -0
- package/src/targets/shell/curl/fixtures/heredoc-json-encoded-data.sh +9 -0
- package/src/targets/shell/curl/fixtures/http-insecure.sh +2 -0
- package/src/targets/shell/curl/fixtures/http1.sh +3 -0
- package/src/targets/shell/curl/fixtures/http10.sh +1 -0
- package/src/targets/shell/curl/fixtures/json-payloads-smaller-than-20-characters.sh +4 -0
- package/src/targets/shell/curl/fixtures/jsonObj-multiline.sh +6 -0
- package/src/targets/shell/curl/fixtures/jsonObj-null-value.sh +4 -0
- package/src/targets/shell/curl/fixtures/long-globoff-option.sh +1 -0
- package/src/targets/shell/curl/fixtures/multipart-data.sh +5 -0
- package/src/targets/shell/curl/fixtures/multipart-file.sh +4 -0
- package/src/targets/shell/curl/fixtures/multipart-form-data-no-params.sh +3 -0
- package/src/targets/shell/curl/fixtures/multipart-form-data.sh +4 -0
- package/src/targets/shell/curl/fixtures/nested.sh +2 -0
- package/src/targets/shell/curl/fixtures/query-encoded.sh +2 -0
- package/src/targets/shell/curl/fixtures/query.sh +2 -0
- package/src/targets/shell/curl/fixtures/short-options.sh +1 -0
- package/src/targets/shell/curl/fixtures/short.sh +2 -0
- package/src/targets/shell/curl/fixtures/text-plain.sh +4 -0
- package/src/targets/shell/curl/fixtures/urlencode.sh +5 -0
- package/src/targets/shell/httpie/client.test.ts +72 -0
- package/src/targets/shell/httpie/client.ts +144 -0
- package/src/targets/shell/httpie/fixtures/application-form-encoded.sh +4 -0
- package/src/targets/shell/httpie/fixtures/application-json.sh +3 -0
- package/src/targets/shell/httpie/fixtures/build-parameters.sh +1 -0
- package/src/targets/shell/httpie/fixtures/cookies.sh +2 -0
- package/src/targets/shell/httpie/fixtures/custom-indentation.sh +5 -0
- package/src/targets/shell/httpie/fixtures/custom-method.sh +1 -0
- package/src/targets/shell/httpie/fixtures/full.sh +5 -0
- package/src/targets/shell/httpie/fixtures/headers.sh +4 -0
- package/src/targets/shell/httpie/fixtures/http-insecure.sh +1 -0
- package/src/targets/shell/httpie/fixtures/jsonObj-multiline.sh +5 -0
- package/src/targets/shell/httpie/fixtures/jsonObj-null-value.sh +3 -0
- package/src/targets/shell/httpie/fixtures/long-flags.sh +1 -0
- package/src/targets/shell/httpie/fixtures/multipart-data.sh +13 -0
- package/src/targets/shell/httpie/fixtures/multipart-file.sh +9 -0
- package/src/targets/shell/httpie/fixtures/multipart-form-data-no-params.sh +2 -0
- package/src/targets/shell/httpie/fixtures/multipart-form-data.sh +8 -0
- package/src/targets/shell/httpie/fixtures/nested.sh +1 -0
- package/src/targets/shell/httpie/fixtures/query-encoded.sh +1 -0
- package/src/targets/shell/httpie/fixtures/query.sh +1 -0
- package/src/targets/shell/httpie/fixtures/querystring-parameters.sh +1 -0
- package/src/targets/shell/httpie/fixtures/short-flags.sh +1 -0
- package/src/targets/shell/httpie/fixtures/short.sh +1 -0
- package/src/targets/shell/httpie/fixtures/text-plain.sh +3 -0
- package/src/targets/shell/httpie/fixtures/verbose-output.sh +1 -0
- package/src/targets/shell/target.ts +19 -0
- package/src/targets/shell/wget/client.test.ts +35 -0
- package/src/targets/shell/wget/client.ts +63 -0
- package/src/targets/shell/wget/fixtures/application-form-encoded.sh +6 -0
- package/src/targets/shell/wget/fixtures/application-json.sh +6 -0
- package/src/targets/shell/wget/fixtures/cookies.sh +5 -0
- package/src/targets/shell/wget/fixtures/custom-indentation.sh +8 -0
- package/src/targets/shell/wget/fixtures/custom-method.sh +4 -0
- package/src/targets/shell/wget/fixtures/full.sh +8 -0
- package/src/targets/shell/wget/fixtures/headers.sh +7 -0
- package/src/targets/shell/wget/fixtures/http-insecure.sh +4 -0
- package/src/targets/shell/wget/fixtures/jsonObj-multiline.sh +6 -0
- package/src/targets/shell/wget/fixtures/jsonObj-null-value.sh +6 -0
- package/src/targets/shell/wget/fixtures/multipart-data.sh +6 -0
- package/src/targets/shell/wget/fixtures/multipart-file.sh +6 -0
- package/src/targets/shell/wget/fixtures/multipart-form-data-no-params.sh +5 -0
- package/src/targets/shell/wget/fixtures/multipart-form-data.sh +6 -0
- package/src/targets/shell/wget/fixtures/nested.sh +4 -0
- package/src/targets/shell/wget/fixtures/query-encoded.sh +4 -0
- package/src/targets/shell/wget/fixtures/query.sh +4 -0
- package/src/targets/shell/wget/fixtures/short-options.sh +1 -0
- package/src/targets/shell/wget/fixtures/short.sh +4 -0
- package/src/targets/shell/wget/fixtures/text-plain.sh +6 -0
- package/src/targets/shell/wget/fixtures/v-output.sh +1 -0
- package/src/targets/shell/wget/fixtures/verbose-output.sh +1 -0
- package/src/targets/swift/helpers.ts +86 -0
- package/src/targets/swift/nsurlsession/client.test.ts +44 -0
- package/src/targets/swift/nsurlsession/client.ts +157 -0
- package/src/targets/swift/nsurlsession/fixtures/application-form-encoded.swift +25 -0
- package/src/targets/swift/nsurlsession/fixtures/application-json.swift +32 -0
- package/src/targets/swift/nsurlsession/fixtures/cookies.swift +21 -0
- package/src/targets/swift/nsurlsession/fixtures/custom-method.swift +18 -0
- package/src/targets/swift/nsurlsession/fixtures/full.swift +28 -0
- package/src/targets/swift/nsurlsession/fixtures/headers.swift +25 -0
- package/src/targets/swift/nsurlsession/fixtures/http-insecure.swift +18 -0
- package/src/targets/swift/nsurlsession/fixtures/indent-option.swift +18 -0
- package/src/targets/swift/nsurlsession/fixtures/json-null-value.swift +25 -0
- package/src/targets/swift/nsurlsession/fixtures/jsonObj-multiline.swift +25 -0
- package/src/targets/swift/nsurlsession/fixtures/jsonObj-null-value.swift +25 -0
- package/src/targets/swift/nsurlsession/fixtures/multipart-data.swift +56 -0
- package/src/targets/swift/nsurlsession/fixtures/multipart-file.swift +51 -0
- package/src/targets/swift/nsurlsession/fixtures/multipart-form-data-no-params.swift +21 -0
- package/src/targets/swift/nsurlsession/fixtures/multipart-form-data.swift +50 -0
- package/src/targets/swift/nsurlsession/fixtures/nested.swift +18 -0
- package/src/targets/swift/nsurlsession/fixtures/pretty-option.swift +24 -0
- package/src/targets/swift/nsurlsession/fixtures/query-encoded.swift +18 -0
- package/src/targets/swift/nsurlsession/fixtures/query.swift +18 -0
- package/src/targets/swift/nsurlsession/fixtures/short.swift +18 -0
- package/src/targets/swift/nsurlsession/fixtures/text-plain.swift +24 -0
- package/src/targets/swift/nsurlsession/fixtures/timeout-option.swift +18 -0
- package/src/targets/swift/target.ts +14 -0
- package/src/targets/targets.test.ts +297 -0
- package/src/targets/targets.ts +203 -0
- package/src/helpers/code-builder.js +0 -108
- package/src/helpers/headers.js +0 -48
- package/src/helpers/reducer.js +0 -20
- package/src/index.js +0 -361
- package/src/targets/c/index.js +0 -10
- package/src/targets/c/libcurl.js +0 -45
- package/src/targets/clojure/clj_http.js +0 -176
- package/src/targets/clojure/index.js +0 -10
- package/src/targets/csharp/httpclient.js +0 -157
- package/src/targets/csharp/index.js +0 -11
- package/src/targets/csharp/restsharp.js +0 -49
- package/src/targets/go/index.js +0 -10
- package/src/targets/go/native.js +0 -130
- package/src/targets/http/http1.1.js +0 -89
- package/src/targets/http/index.js +0 -10
- package/src/targets/index.js +0 -20
- package/src/targets/java/asynchttp.js +0 -54
- package/src/targets/java/index.js +0 -13
- package/src/targets/java/nethttp.js +0 -59
- package/src/targets/java/okhttp.js +0 -78
- package/src/targets/java/unirest.js +0 -57
- package/src/targets/javascript/axios.js +0 -101
- package/src/targets/javascript/fetch.js +0 -113
- package/src/targets/javascript/index.js +0 -13
- package/src/targets/javascript/jquery.js +0 -89
- package/src/targets/javascript/xhr.js +0 -86
- package/src/targets/kotlin/index.js +0 -10
- package/src/targets/kotlin/okhttp.js +0 -78
- package/src/targets/node/axios.js +0 -76
- package/src/targets/node/fetch.js +0 -141
- package/src/targets/node/index.js +0 -15
- package/src/targets/node/native.js +0 -92
- package/src/targets/node/request.js +0 -126
- package/src/targets/node/unirest.js +0 -120
- package/src/targets/objc/helpers.js +0 -80
- package/src/targets/objc/index.js +0 -10
- package/src/targets/objc/nsurlsession.js +0 -164
- package/src/targets/ocaml/cohttp.js +0 -73
- package/src/targets/ocaml/index.js +0 -10
- package/src/targets/php/curl.js +0 -142
- package/src/targets/php/guzzle.js +0 -135
- package/src/targets/php/helpers.js +0 -87
- package/src/targets/php/http1.js +0 -85
- package/src/targets/php/http2.js +0 -131
- package/src/targets/php/index.js +0 -14
- package/src/targets/powershell/common.js +0 -60
- package/src/targets/powershell/index.js +0 -11
- package/src/targets/powershell/restmethod.js +0 -8
- package/src/targets/powershell/webrequest.js +0 -8
- package/src/targets/python/helpers.js +0 -85
- package/src/targets/python/index.js +0 -11
- package/src/targets/python/requests.js +0 -163
- package/src/targets/r/httr.js +0 -141
- package/src/targets/r/index.js +0 -10
- package/src/targets/ruby/index.js +0 -10
- package/src/targets/ruby/native.js +0 -71
- package/src/targets/shell/curl.js +0 -157
- package/src/targets/shell/helpers.js +0 -23
- package/src/targets/shell/httpie.js +0 -129
- package/src/targets/shell/index.js +0 -13
- package/src/targets/shell/wget.js +0 -52
- package/src/targets/swift/helpers.js +0 -93
- package/src/targets/swift/index.js +0 -10
- package/src/targets/swift/nsurlsession.js +0 -152
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const DEFAULT_INDENTATION_CHARACTER = '';
|
|
2
|
+
const DEFAULT_LINE_JOIN = '\n';
|
|
3
|
+
|
|
4
|
+
export type PostProcessor = (unreplacedCode: string) => string;
|
|
5
|
+
|
|
6
|
+
export interface CodeBuilderOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Desired indentation character for aggregated lines of code
|
|
9
|
+
* @default ''
|
|
10
|
+
*/
|
|
11
|
+
indent?: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Desired character to join each line of code
|
|
15
|
+
* @default \n
|
|
16
|
+
*/
|
|
17
|
+
join?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class CodeBuilder {
|
|
21
|
+
postProcessors: PostProcessor[] = [];
|
|
22
|
+
|
|
23
|
+
code: string[] = [];
|
|
24
|
+
|
|
25
|
+
indentationCharacter: string = DEFAULT_INDENTATION_CHARACTER;
|
|
26
|
+
|
|
27
|
+
lineJoin = DEFAULT_LINE_JOIN;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Helper object to format and aggragate lines of code.
|
|
31
|
+
* Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet.
|
|
32
|
+
*/
|
|
33
|
+
constructor({ indent, join }: CodeBuilderOptions = {}) {
|
|
34
|
+
this.indentationCharacter = indent || DEFAULT_INDENTATION_CHARACTER;
|
|
35
|
+
this.lineJoin = join ?? DEFAULT_LINE_JOIN;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Add given indentation level to given line of code
|
|
40
|
+
*/
|
|
41
|
+
indentLine = (line: string, indentationLevel = 0) => {
|
|
42
|
+
const indent = this.indentationCharacter.repeat(indentationLevel);
|
|
43
|
+
return `${indent}${line}`;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Add the line at the beginning of the current lines
|
|
48
|
+
*/
|
|
49
|
+
unshift = (line: string, indentationLevel?: number) => {
|
|
50
|
+
const newLine = this.indentLine(line, indentationLevel);
|
|
51
|
+
this.code.unshift(newLine);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Add the line at the end of the current lines
|
|
56
|
+
*/
|
|
57
|
+
push = (line: string, indentationLevel?: number) => {
|
|
58
|
+
const newLine = this.indentLine(line, indentationLevel);
|
|
59
|
+
this.code.push(newLine);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Add an empty line at the end of current lines
|
|
64
|
+
*/
|
|
65
|
+
blank = () => {
|
|
66
|
+
this.code.push('');
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Concatenate all current lines using the given lineJoin, then apply any replacers that may have been added
|
|
71
|
+
*/
|
|
72
|
+
join = () => {
|
|
73
|
+
const unreplacedCode = this.code.join(this.lineJoin);
|
|
74
|
+
const replacedOutput = this.postProcessors.reduce((accumulator, replacer) => replacer(accumulator), unreplacedCode);
|
|
75
|
+
return replacedOutput;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Often when writing modules you may wish to add a literal tag or bit of metadata that you wish to transform after other processing as a final step.
|
|
80
|
+
* To do so, you can provide a PostProcessor function and it will be run automatically for you when you call `join()` later on.
|
|
81
|
+
*/
|
|
82
|
+
addPostProcessor = (postProcessor: PostProcessor) => {
|
|
83
|
+
this.postProcessors = [...this.postProcessors, postProcessor];
|
|
84
|
+
};
|
|
85
|
+
}
|
|
@@ -26,35 +26,24 @@
|
|
|
26
26
|
* Extracted from https://github.com/node-fetch/node-fetch/blob/64c5c296a0250b852010746c76144cb9e14698d9/src/utils/form-data.js
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
+
import type FormData from 'form-data';
|
|
30
|
+
|
|
29
31
|
const carriage = '\r\n';
|
|
30
32
|
const dashes = '-'.repeat(2);
|
|
31
33
|
|
|
32
34
|
const NAME = Symbol.toStringTag;
|
|
33
35
|
|
|
34
|
-
const isBlob = object =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/^(Blob|File)$/.test(object[NAME])
|
|
42
|
-
);
|
|
43
|
-
};
|
|
36
|
+
export const isBlob = (object: any) =>
|
|
37
|
+
typeof object === 'object' &&
|
|
38
|
+
typeof object.arrayBuffer === 'function' &&
|
|
39
|
+
typeof object.type === 'string' &&
|
|
40
|
+
typeof object.stream === 'function' &&
|
|
41
|
+
typeof object.constructor === 'function' &&
|
|
42
|
+
/^(Blob|File)$/.test(object[NAME]);
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
* @param {string} boundary
|
|
47
|
-
*/
|
|
48
|
-
const getFooter = boundary => `${dashes}${boundary}${dashes}${carriage.repeat(2)}`;
|
|
44
|
+
const getFooter = (boundary: string) => `${dashes}${boundary}${dashes}${carriage.repeat(2)}`;
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
* @param {string} boundary
|
|
52
|
-
* @param {string} name
|
|
53
|
-
* @param {*} field
|
|
54
|
-
*
|
|
55
|
-
* @return {string}
|
|
56
|
-
*/
|
|
57
|
-
function getHeader(boundary, name, field) {
|
|
46
|
+
const getHeader = (boundary: string, name: string, field: { name: string; type: string }) => {
|
|
58
47
|
let header = '';
|
|
59
48
|
|
|
60
49
|
header += `${dashes}${boundary}${carriage}`;
|
|
@@ -66,28 +55,10 @@ function getHeader(boundary, name, field) {
|
|
|
66
55
|
}
|
|
67
56
|
|
|
68
57
|
return `${header}${carriage.repeat(2)}`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @return {string}
|
|
73
|
-
*/
|
|
74
|
-
module.exports.getBoundary = () => {
|
|
75
|
-
// This generates a 50 character boundary similar to those used by Firefox.
|
|
76
|
-
// They are optimized for boyer-moore parsing.
|
|
77
|
-
let boundary = '--------------------------';
|
|
78
|
-
// eslint-disable-next-line no-plusplus
|
|
79
|
-
for (let i = 0; i < 24; i++) {
|
|
80
|
-
boundary += Math.floor(Math.random() * 10).toString(16);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return boundary;
|
|
84
58
|
};
|
|
85
59
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* @param {string} boundary
|
|
89
|
-
*/
|
|
90
|
-
module.exports.formDataIterator = function* (form, boundary) {
|
|
60
|
+
export const formDataIterator = function* (form: FormData, boundary: string) {
|
|
61
|
+
// @ts-expect-error not sure how this ever worked
|
|
91
62
|
// eslint-disable-next-line no-restricted-syntax
|
|
92
63
|
for (const [name, value] of form) {
|
|
93
64
|
yield getHeader(boundary, name, value);
|
|
@@ -103,5 +74,3 @@ module.exports.formDataIterator = function* (form, boundary) {
|
|
|
103
74
|
|
|
104
75
|
yield getFooter(boundary);
|
|
105
76
|
};
|
|
106
|
-
|
|
107
|
-
module.exports.isBlob = isBlob;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ErrorObject } from 'ajv';
|
|
2
|
+
import type { Request } from 'har-format';
|
|
3
|
+
import Ajv from 'ajv';
|
|
4
|
+
import * as schema from 'har-schema';
|
|
5
|
+
|
|
6
|
+
export class HARError extends Error {
|
|
7
|
+
name = 'HARError';
|
|
8
|
+
|
|
9
|
+
message = 'validation failed';
|
|
10
|
+
|
|
11
|
+
errors: ErrorObject[] = [];
|
|
12
|
+
|
|
13
|
+
constructor(errors: ErrorObject[]) {
|
|
14
|
+
super();
|
|
15
|
+
this.errors = errors;
|
|
16
|
+
Error.captureStackTrace(this, this.constructor);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ajv = new Ajv({
|
|
21
|
+
allErrors: true,
|
|
22
|
+
});
|
|
23
|
+
ajv.addSchema(schema);
|
|
24
|
+
|
|
25
|
+
export const validateHarRequest = (request: any): request is Request => {
|
|
26
|
+
const validate = ajv.getSchema('request.json');
|
|
27
|
+
if (!validate) {
|
|
28
|
+
throw new Error('failed to find HAR request schema');
|
|
29
|
+
}
|
|
30
|
+
const valid = validate(request);
|
|
31
|
+
if (!valid && validate.errors) {
|
|
32
|
+
throw new HARError(validate.errors);
|
|
33
|
+
}
|
|
34
|
+
return true;
|
|
35
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getHeader, getHeaderName, hasHeader } from './headers';
|
|
2
|
+
|
|
3
|
+
const headers = {
|
|
4
|
+
'Content-Type': 'multipart/form-data; boundary=---011000010111000001101001',
|
|
5
|
+
accept: 'application/json',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
describe('headers', () => {
|
|
9
|
+
describe('getHeader', () => {
|
|
10
|
+
it('should get a header', () => {
|
|
11
|
+
expect(getHeader(headers, 'content-type')).toBe('multipart/form-data; boundary=---011000010111000001101001');
|
|
12
|
+
expect(getHeader(headers, 'content-TYPE')).toBe('multipart/form-data; boundary=---011000010111000001101001');
|
|
13
|
+
expect(getHeader(headers, 'Accept')).toBe('application/json');
|
|
14
|
+
expect(getHeader(headers, 'authorization')).toBeUndefined();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('getHeaderName', () => {
|
|
19
|
+
it('should get a header name', () => {
|
|
20
|
+
expect(getHeaderName(headers, 'content-type')).toBe('Content-Type');
|
|
21
|
+
expect(getHeaderName(headers, 'content-TYPE')).toBe('Content-Type');
|
|
22
|
+
expect(getHeaderName(headers, 'Accept')).toBe('accept');
|
|
23
|
+
expect(getHeaderName(headers, 'authorization')).toBeUndefined();
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('hasHeader', () => {
|
|
28
|
+
it('should return if a header is present', () => {
|
|
29
|
+
expect(hasHeader(headers, 'content-type')).toBe(true);
|
|
30
|
+
expect(hasHeader(headers, 'content-TYPE')).toBe(true);
|
|
31
|
+
expect(hasHeader(headers, 'Accept')).toBe(true);
|
|
32
|
+
expect(hasHeader(headers, 'authorization')).toBe(false);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type Headers<T> = Record<string, T>;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Given a headers object retrieve a specific header out of it via a case-insensitive key.
|
|
5
|
+
*/
|
|
6
|
+
export const getHeaderName = <T>(headers: Headers<T>, name: string) =>
|
|
7
|
+
Object.keys(headers).find(header => header.toLowerCase() === name.toLowerCase());
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Given a headers object retrieve the contents of a header out of it via a case-insensitive key.
|
|
11
|
+
*/
|
|
12
|
+
export const getHeader = <T>(headers: Headers<T>, name: string) => {
|
|
13
|
+
const headerName = getHeaderName(headers, name);
|
|
14
|
+
if (!headerName) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return headers[headerName];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Determine if a given case-insensitive header exists within a header object.
|
|
22
|
+
*/
|
|
23
|
+
export const hasHeader = <T>(headers: Headers<T>, name: string) => Boolean(getHeaderName(headers, name));
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Determines if a given MIME type is JSON, or a variant of such.
|
|
27
|
+
*/
|
|
28
|
+
export const isMimeTypeJSON = (mimeType: string) =>
|
|
29
|
+
['application/json', 'application/x-json', 'text/json', 'text/x-json', '+json'].some(
|
|
30
|
+
type => mimeType.indexOf(type) > -1
|
|
31
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { reducer } from './reducer';
|
|
2
|
+
|
|
3
|
+
describe('reducer', () => {
|
|
4
|
+
it('should convert array object pair to key-value object', () => {
|
|
5
|
+
const query = [
|
|
6
|
+
{ name: 'key', value: 'value' },
|
|
7
|
+
{ name: 'foo', value: 'bar' },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
const result = query.reduce(reducer, {});
|
|
11
|
+
|
|
12
|
+
expect(result).toMatchObject({ key: 'value', foo: 'bar' });
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should convert multi-dimensional arrays to key=[array] object', () => {
|
|
16
|
+
const query = [
|
|
17
|
+
{ name: 'key', value: 'value' },
|
|
18
|
+
{ name: 'foo', value: 'bar1' },
|
|
19
|
+
{ name: 'foo', value: 'bar2' },
|
|
20
|
+
{ name: 'foo', value: 'bar3' },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const result = query.reduce(reducer, {});
|
|
24
|
+
|
|
25
|
+
expect(result).toMatchObject({ key: 'value', foo: ['bar1', 'bar2', 'bar3'] });
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type ReducedHelperObject = Record<string, string[] | string>;
|
|
2
|
+
|
|
3
|
+
export const reducer = <T extends { name: string; value: string }>(accumulator: ReducedHelperObject, pair: T) => {
|
|
4
|
+
const currentValue = accumulator[pair.name];
|
|
5
|
+
if (currentValue === undefined) {
|
|
6
|
+
accumulator[pair.name] = pair.value;
|
|
7
|
+
return accumulator;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// If we already have it as array just push the value
|
|
11
|
+
if (Array.isArray(currentValue)) {
|
|
12
|
+
currentValue.push(pair.value);
|
|
13
|
+
return accumulator;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// convert to array since now we have more than one value for this key
|
|
17
|
+
accumulator[pair.name] = [currentValue, pair.value];
|
|
18
|
+
return accumulator;
|
|
19
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use 'strong quoting' using single quotes so that we only need to deal with nested single quote characters.
|
|
3
|
+
* see: http://wiki.bash-hackers.org/syntax/quoting#strong_quoting
|
|
4
|
+
*/
|
|
5
|
+
export const quote = (value = '') => {
|
|
6
|
+
const safe = /^[a-z0-9-_/.@%^=:]+$/i;
|
|
7
|
+
|
|
8
|
+
const isShellSafe = safe.test(value);
|
|
9
|
+
|
|
10
|
+
if (isShellSafe) {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// if the value is not shell safe, then quote it
|
|
15
|
+
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const escape = (value: string) => value.replace(/\r/g, '\\r').replace(/\n/g, '\\n');
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { availableTargets, extname } from './utils';
|
|
2
|
+
|
|
3
|
+
describe('availableTargets', () => {
|
|
4
|
+
it('returns all available targets', () => {
|
|
5
|
+
expect(availableTargets()).toMatchSnapshot();
|
|
6
|
+
});
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
describe('extname', () => {
|
|
10
|
+
it('returns the correct extension', () => {
|
|
11
|
+
expect(extname('c')).toBe('.c');
|
|
12
|
+
expect(extname('clojure')).toBe('.clj');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('returns empty string if the extension is not found', () => {
|
|
16
|
+
// @ts-expect-error intentionally incorrect
|
|
17
|
+
expect(extname('ziltoid')).toBe('');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ClientInfo, TargetId, TargetInfo } from '../targets/targets';
|
|
2
|
+
import { targets } from '../targets/targets';
|
|
3
|
+
|
|
4
|
+
export interface AvailableTarget extends TargetInfo {
|
|
5
|
+
clients: ClientInfo[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const availableTargets = () =>
|
|
9
|
+
Object.keys(targets).map<AvailableTarget>(targetId => ({
|
|
10
|
+
...targets[targetId as TargetId].info,
|
|
11
|
+
clients: Object.keys(targets[targetId as TargetId].clientsById).map(
|
|
12
|
+
clientId => targets[targetId as TargetId].clientsById[clientId].info
|
|
13
|
+
),
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
export const extname = (targetId: TargetId) => targets[targetId]?.info.extname || '';
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import type { Request } from '.';
|
|
2
|
+
import { mimetypes } from './fixtures/mimetypes';
|
|
3
|
+
import headers from './fixtures/requests/headers';
|
|
4
|
+
import query from './fixtures/requests/query';
|
|
5
|
+
import short from './fixtures/requests/short';
|
|
6
|
+
import { HTTPSnippet } from '.';
|
|
7
|
+
|
|
8
|
+
describe('HTTPSnippet', () => {
|
|
9
|
+
it('should return false if no matching target', () => {
|
|
10
|
+
const snippet = new HTTPSnippet(short.log.entries[0].request as Request);
|
|
11
|
+
// @ts-expect-error intentionally incorrect
|
|
12
|
+
const result = snippet.convert(null);
|
|
13
|
+
|
|
14
|
+
expect(result).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should fail validation for non-HAR inputs', () => {
|
|
18
|
+
expect.assertions(1);
|
|
19
|
+
|
|
20
|
+
// @ts-expect-error intentionally incorrect
|
|
21
|
+
const attempt = () => new HTTPSnippet({ ziltoid: 'the omniscient' });
|
|
22
|
+
|
|
23
|
+
expect(attempt).toThrow('validation failed');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should parse HAR file with multiple entries', () => {
|
|
27
|
+
const snippet = new HTTPSnippet({
|
|
28
|
+
log: {
|
|
29
|
+
version: '1.2',
|
|
30
|
+
creator: {
|
|
31
|
+
name: 'HTTPSnippet',
|
|
32
|
+
version: '1.0.0',
|
|
33
|
+
},
|
|
34
|
+
entries: [
|
|
35
|
+
{
|
|
36
|
+
request: {
|
|
37
|
+
method: 'GET',
|
|
38
|
+
url: 'https://httpbin.org/anything',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
request: {
|
|
43
|
+
method: 'POST',
|
|
44
|
+
url: 'https://httpbin.org/anything',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
expect(snippet).toHaveProperty('requests');
|
|
52
|
+
expect(Array.isArray(snippet.requests)).toBeTruthy();
|
|
53
|
+
expect(snippet.requests).toHaveLength(2);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('mimetype conversion', () => {
|
|
57
|
+
it.each([
|
|
58
|
+
{
|
|
59
|
+
input: 'multipart/mixed',
|
|
60
|
+
expected: 'multipart/form-data',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
input: 'multipart/related',
|
|
64
|
+
expected: 'multipart/form-data',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
input: 'multipart/alternative',
|
|
68
|
+
expected: 'multipart/form-data',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
input: 'text/json',
|
|
72
|
+
expected: 'application/json',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
input: 'text/x-json',
|
|
76
|
+
expected: 'application/json',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
input: 'application/x-json',
|
|
80
|
+
expected: 'application/json',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
input: 'invalid-json',
|
|
84
|
+
expected: 'text/plain',
|
|
85
|
+
},
|
|
86
|
+
] as {
|
|
87
|
+
input: keyof typeof mimetypes;
|
|
88
|
+
expected: string;
|
|
89
|
+
}[])('mimetype conversion of $input to $output', ({ input, expected }) => {
|
|
90
|
+
const snippet = new HTTPSnippet(mimetypes[input]);
|
|
91
|
+
const request = snippet.requests[0];
|
|
92
|
+
|
|
93
|
+
expect(request.postData.mimeType).toStrictEqual(expected);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should set postData.text to empty string when postData.params is undefined in application/x-www-form-urlencoded', () => {
|
|
98
|
+
const snippet = new HTTPSnippet(mimetypes['application/x-www-form-urlencoded']);
|
|
99
|
+
const request = snippet.requests[0];
|
|
100
|
+
|
|
101
|
+
expect(request.postData.text).toBe('');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('requestExtras', () => {
|
|
105
|
+
describe('uriObj', () => {
|
|
106
|
+
it('should add uriObj', () => {
|
|
107
|
+
const snippet = new HTTPSnippet(query.log.entries[0].request as Request);
|
|
108
|
+
const request = snippet.requests[0];
|
|
109
|
+
|
|
110
|
+
expect(request.uriObj).toMatchObject({
|
|
111
|
+
auth: null,
|
|
112
|
+
hash: null,
|
|
113
|
+
host: 'httpbin.org',
|
|
114
|
+
hostname: 'httpbin.org',
|
|
115
|
+
href: 'https://httpbin.org/anything?key=value',
|
|
116
|
+
path: '/anything?foo=bar&foo=baz&baz=abc&key=value',
|
|
117
|
+
pathname: '/anything',
|
|
118
|
+
port: null,
|
|
119
|
+
protocol: 'https:',
|
|
120
|
+
query: {
|
|
121
|
+
baz: 'abc',
|
|
122
|
+
key: 'value',
|
|
123
|
+
foo: ['bar', 'baz'],
|
|
124
|
+
},
|
|
125
|
+
search: 'foo=bar&foo=baz&baz=abc&key=value',
|
|
126
|
+
slashes: true,
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should fix the `path` property of uriObj to match queryString', () => {
|
|
131
|
+
const snippet = new HTTPSnippet(query.log.entries[0].request as Request);
|
|
132
|
+
const request = snippet.requests[0];
|
|
133
|
+
|
|
134
|
+
expect(request.uriObj.path).toBe('/anything?foo=bar&foo=baz&baz=abc&key=value');
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('queryObj', () => {
|
|
139
|
+
it('should add queryObj', () => {
|
|
140
|
+
const snippet = new HTTPSnippet(query.log.entries[0].request as Request);
|
|
141
|
+
const request = snippet.requests[0];
|
|
142
|
+
|
|
143
|
+
expect(request.queryObj).toMatchObject({ baz: 'abc', key: 'value', foo: ['bar', 'baz'] });
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
describe('headersObj', () => {
|
|
148
|
+
it('should add headersObj', () => {
|
|
149
|
+
const snippet = new HTTPSnippet(headers.log.entries[0].request as Request);
|
|
150
|
+
const request = snippet.requests[0];
|
|
151
|
+
|
|
152
|
+
expect(request.headersObj).toMatchObject({
|
|
153
|
+
accept: 'application/json',
|
|
154
|
+
'x-foo': 'Bar',
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should add headersObj to source object case insensitive when HTTP/1.0', () => {
|
|
159
|
+
const snippet = new HTTPSnippet({
|
|
160
|
+
...headers.log.entries[0].request,
|
|
161
|
+
httpVersion: 'HTTP/1.1',
|
|
162
|
+
headers: [
|
|
163
|
+
...headers.log.entries[0].request.headers,
|
|
164
|
+
{
|
|
165
|
+
name: 'Kong-Admin-Token',
|
|
166
|
+
value: 'Ziltoid The Omniscient',
|
|
167
|
+
},
|
|
168
|
+
],
|
|
169
|
+
} as Request);
|
|
170
|
+
|
|
171
|
+
const request = snippet.requests[0];
|
|
172
|
+
|
|
173
|
+
expect(request.headersObj).toMatchObject({
|
|
174
|
+
'Kong-Admin-Token': 'Ziltoid The Omniscient',
|
|
175
|
+
accept: 'application/json',
|
|
176
|
+
'x-foo': 'Bar',
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it('should add headersObj to source object lowercased when HTTP/2.x', () => {
|
|
181
|
+
const snippet = new HTTPSnippet({
|
|
182
|
+
...headers.log.entries[0].request,
|
|
183
|
+
httpVersion: 'HTTP/2',
|
|
184
|
+
headers: [
|
|
185
|
+
...headers.log.entries[0].request.headers,
|
|
186
|
+
{
|
|
187
|
+
name: 'Kong-Admin-Token',
|
|
188
|
+
value: 'Ziltoid The Omniscient',
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
} as Request);
|
|
192
|
+
|
|
193
|
+
const request = snippet.requests[0];
|
|
194
|
+
|
|
195
|
+
expect(request.headersObj).toMatchObject({
|
|
196
|
+
'kong-admin-token': 'Ziltoid The Omniscient',
|
|
197
|
+
accept: 'application/json',
|
|
198
|
+
'x-foo': 'Bar',
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
describe('url', () => {
|
|
204
|
+
it('should modify the original url to strip query string', () => {
|
|
205
|
+
const snippet = new HTTPSnippet(query.log.entries[0].request as Request);
|
|
206
|
+
const request = snippet.requests[0];
|
|
207
|
+
|
|
208
|
+
expect(request.url).toBe('https://httpbin.org/anything');
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe('fullUrl', () => {
|
|
213
|
+
it('adds fullURL', () => {
|
|
214
|
+
const snippet = new HTTPSnippet(query.log.entries[0].request as Request);
|
|
215
|
+
const request = snippet.requests[0];
|
|
216
|
+
|
|
217
|
+
expect(request.fullUrl).toBe('https://httpbin.org/anything?foo=bar&foo=baz&baz=abc&key=value');
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
});
|