├── .github └── workflows │ └── publish-to-maven.yml ├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── LICENSE ├── README.md ├── docs ├── generator.png ├── generator.puml ├── highlight │ ├── highlight.min.js │ └── styles │ │ ├── a11y-dark.min.css │ │ ├── a11y-light.min.css │ │ ├── atom-one-dark-reasonable.min.css │ │ ├── atom-one-dark.min.css │ │ ├── atom-one-light.min.css │ │ ├── github.min.css │ │ ├── mono-blue.min.css │ │ ├── monokai-sublime.min.css │ │ ├── monokai.min.css │ │ ├── solarized-dark.min.css │ │ └── solarized-light.min.css ├── images │ └── generators.png ├── index.adoc ├── index.html └── index.pdf ├── images ├── Redoc.png └── Swagger-UI.png ├── lombok.config ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main └── java │ └── io │ └── github │ └── atkawa7 │ └── httpsnippet │ ├── builder │ └── CodeBuilder.java │ ├── generators │ ├── CodeGenerator.java │ ├── HttpSnippetCodeGenerator.java │ ├── c │ │ └── LibCurl.java │ ├── clojure │ │ └── CljHttp.java │ ├── csharp │ │ └── RestSharp.java │ ├── go │ │ └── GoNative.java │ ├── java │ │ ├── AsyncHttp.java │ │ ├── Jsoup.java │ │ ├── NetHttp.java │ │ ├── OkHttp.java │ │ └── Unirest.java │ ├── javascript │ │ ├── Fetch.java │ │ ├── JQuery.java │ │ └── XMLHttpRequest.java │ ├── node │ │ ├── NodeNative.java │ │ ├── NodeRequest.java │ │ └── NodeUnirest.java │ ├── objc │ │ └── ObjNSURLSession.java │ ├── powershell │ │ └── PowerShell.java │ ├── python │ │ ├── Python3Native.java │ │ └── PythonRequests.java │ ├── ruby │ │ └── RubyNative.java │ ├── shell │ │ └── Curl.java │ └── swift │ │ └── Swift.java │ ├── http │ ├── HttpHeaders.java │ ├── HttpMethod.java │ ├── HttpScheme.java │ ├── HttpVersion.java │ └── MediaType.java │ ├── models │ ├── Client.java │ ├── HttpSnippet.java │ ├── Language.java │ └── internal │ │ ├── CodeRequest.java │ │ ├── URLWrapper.java │ │ └── Validation.java │ └── utils │ └── HarUtils.java └── test ├── java └── io │ └── github │ └── atkawa7 │ └── httpsnippet │ ├── builder │ └── CodeBuilderTest.java │ ├── fixtures │ ├── Fixture.java │ ├── FixtureBuilder.java │ ├── FixtureTest.java │ └── FixtureType.java │ ├── http │ ├── HttpMethodTest.java │ ├── HttpSchemeTest.java │ └── HttpVersionTest.java │ ├── models │ └── internal │ │ └── CodeRequestTest.java │ └── utils │ └── HarUtilsTest.java └── resources ├── fixtures ├── application-form-encoded.json ├── application-json.json ├── cookies.json ├── custom-method.json ├── full.json ├── headers.json ├── https.json ├── jsonObj-null-value.json ├── multipart-data.json ├── multipart-file.json ├── multipart-form-data.json ├── query.json ├── short.json └── text-plain.json └── output ├── c └── libcurl │ ├── application-form-encoded.c │ ├── application-json.c │ ├── cookies.c │ ├── custom-method.c │ ├── full.c │ ├── headers.c │ ├── https.c │ ├── jsonObj-null-value.c │ ├── multipart-data.c │ ├── multipart-file.c │ ├── multipart-form-data.c │ ├── query.c │ ├── short.c │ └── text-plain.c ├── clojure └── clj_http │ ├── application-form-encoded.clj │ ├── application-json.clj │ ├── cookies.clj │ ├── custom-method.clj │ ├── full.clj │ ├── headers.clj │ ├── https.clj │ ├── jsonObj-null-value.clj │ ├── multipart-data.clj │ ├── multipart-file.clj │ ├── multipart-form-data.clj │ ├── query.clj │ ├── short.clj │ └── text-plain.clj ├── crystal └── native │ ├── application-form-encoded.cr │ ├── application-json.cr │ ├── cookies.cr │ ├── custom-method.cr │ ├── full.cr │ ├── headers.cr │ ├── https.cr │ ├── insecure-skip-verify.cr │ ├── jsonObj-multiline.cr │ ├── jsonObj-null-value.cr │ ├── multipart-data.cr │ ├── multipart-file.cr │ ├── multipart-form-data-no-params.cr │ ├── multipart-form-data.cr │ ├── nested.cr │ ├── query.cr │ ├── short.cr │ └── text-plain.cr ├── csharp ├── httpclient │ ├── application-form-encoded.cs │ ├── application-json.cs │ ├── cookies.cs │ ├── custom-method.cs │ ├── full.cs │ ├── headers.cs │ ├── https.cs │ ├── jsonObj-multiline.cs │ ├── jsonObj-null-value.cs │ ├── multipart-data.cs │ ├── multipart-file.cs │ ├── multipart-form-data-no-params.cs │ ├── multipart-form-data.cs │ ├── nested.cs │ ├── query.cs │ ├── short.cs │ └── text-plain.cs └── restsharp │ ├── application-form-encoded.cs │ ├── application-json.cs │ ├── cookies.cs │ ├── custom-method.cs │ ├── full.cs │ ├── headers.cs │ ├── https.cs │ ├── jsonObj-null-value.cs │ ├── multipart-data.cs │ ├── multipart-file.cs │ ├── multipart-form-data.cs │ ├── query.cs │ ├── short.cs │ └── text-plain.cs ├── go └── native │ ├── application-form-encoded.go │ ├── application-json.go │ ├── cookies.go │ ├── custom-method.go │ ├── full.go │ ├── headers.go │ ├── https.go │ ├── jsonObj-null-value.go │ ├── multipart-data.go │ ├── multipart-file.go │ ├── multipart-form-data.go │ ├── query.go │ ├── short.go │ └── text-plain.go ├── http └── http1.1 │ ├── application-form-encoded │ ├── application-json │ ├── cookies │ ├── custom-method │ ├── full │ ├── headers │ ├── https │ ├── jsonObj-multiline │ ├── jsonObj-null-value │ ├── multipart-data │ ├── multipart-file │ ├── multipart-form-data │ ├── multipart-form-data-no-params │ ├── nested │ ├── query │ ├── short │ └── text-plain ├── java ├── asynchttp │ ├── application-form-encoded.java │ ├── application-json.java │ ├── cookies.java │ ├── custom-method.java │ ├── full.java │ ├── headers.java │ ├── https.java │ ├── jsonObj-multiline.java │ ├── jsonObj-null-value.java │ ├── multipart-data.java │ ├── multipart-file.java │ ├── multipart-form-data-no-params.java │ ├── multipart-form-data.java │ ├── nested.java │ ├── query.java │ ├── short.java │ └── text-plain.java ├── jsoup │ ├── application-form-encoded.java │ ├── application-json.java │ ├── cookies.java │ ├── custom-method.java │ ├── full.java │ ├── headers.java │ ├── https.java │ ├── jsonObj-null-value.java │ ├── multipart-data.java │ ├── multipart-file.java │ ├── multipart-form-data.java │ ├── query.java │ ├── short.java │ └── text-plain.java ├── nethttp │ ├── application-form-encoded.java │ ├── application-json.java │ ├── cookies.java │ ├── custom-method.java │ ├── full.java │ ├── headers.java │ ├── https.java │ ├── jsonObj-multiline.java │ ├── jsonObj-null-value.java │ ├── multipart-data.java │ ├── multipart-file.java │ ├── multipart-form-data-no-params.java │ ├── multipart-form-data.java │ ├── nested.java │ ├── query.java │ ├── short.java │ └── text-plain.java ├── okhttp │ ├── application-form-encoded.java │ ├── application-json.java │ ├── cookies.java │ ├── custom-method.java │ ├── full.java │ ├── headers.java │ ├── https.java │ ├── jsonObj-null-value.java │ ├── multipart-data.java │ ├── multipart-file.java │ ├── multipart-form-data.java │ ├── query.java │ ├── short.java │ └── text-plain.java └── unirest │ ├── application-form-encoded.java │ ├── application-json.java │ ├── cookies.java │ ├── custom-method.java │ ├── full.java │ ├── headers.java │ ├── https.java │ ├── jsonObj-null-value.java │ ├── multipart-data.java │ ├── multipart-file.java │ ├── multipart-form-data.java │ ├── query.java │ ├── short.java │ └── text-plain.java ├── javascript ├── axios │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-multiline.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data-no-params.js │ ├── multipart-form-data.js │ ├── nested.js │ ├── query.js │ ├── short.js │ └── text-plain.js ├── fetch │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data.js │ ├── query.js │ ├── short.js │ └── text-plain.js ├── jquery │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data.js │ ├── query.js │ ├── short.js │ └── text-plain.js └── xhr │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data.js │ ├── query.js │ ├── short.js │ └── text-plain.js ├── kotlin └── okhttp │ ├── application-form-encoded.kt │ ├── application-json.kt │ ├── cookies.kt │ ├── custom-method.kt │ ├── full.kt │ ├── headers.kt │ ├── https.kt │ ├── jsonObj-multiline.kt │ ├── jsonObj-null-value.kt │ ├── multipart-data.kt │ ├── multipart-file.kt │ ├── multipart-form-data-no-params.kt │ ├── multipart-form-data.kt │ ├── nested.kt │ ├── query.kt │ ├── short.kt │ └── text-plain.kt ├── node ├── axios │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-multiline.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data-no-params.js │ ├── multipart-form-data.js │ ├── nested.js │ ├── query.js │ ├── short.js │ └── text-plain.js ├── fetch │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-multiline.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data-no-params.js │ ├── multipart-form-data.js │ ├── nested.js │ ├── query.js │ ├── short.js │ └── text-plain.js ├── native │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data.js │ ├── query.js │ ├── short.js │ └── text-plain.js ├── request │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data.js │ ├── query.js │ ├── short.js │ └── text-plain.js └── unirest │ ├── application-form-encoded.js │ ├── application-json.js │ ├── cookies.js │ ├── custom-method.js │ ├── full.js │ ├── headers.js │ ├── https.js │ ├── jsonObj-null-value.js │ ├── multipart-data.js │ ├── multipart-file.js │ ├── multipart-form-data.js │ ├── query.js │ ├── short.js │ └── text-plain.js ├── objc └── nsurlsession │ ├── application-form-encoded.m │ ├── application-json.m │ ├── cookies.m │ ├── custom-method.m │ ├── full.m │ ├── headers.m │ ├── https.m │ ├── jsonObj-null-value.m │ ├── multipart-data.m │ ├── multipart-file.m │ ├── multipart-form-data.m │ ├── query.m │ ├── short.m │ └── text-plain.m ├── ocaml └── cohttp │ ├── application-form-encoded.ml │ ├── application-json.ml │ ├── cookies.ml │ ├── custom-method.ml │ ├── full.ml │ ├── headers.ml │ ├── https.ml │ ├── jsonObj-null-value.ml │ ├── multipart-data.ml │ ├── multipart-file.ml │ ├── multipart-form-data.ml │ ├── query.ml │ ├── short.ml │ └── text-plain.ml ├── php ├── curl │ ├── application-form-encoded.php │ ├── application-json.php │ ├── cookies.php │ ├── custom-method.php │ ├── full.php │ ├── headers.php │ ├── https.php │ ├── jsonObj-null-value.php │ ├── multipart-data.php │ ├── multipart-file.php │ ├── multipart-form-data.php │ ├── query.php │ ├── short.php │ └── text-plain.php ├── guzzle │ ├── application-form-encoded.php │ ├── application-json.php │ ├── cookies.php │ ├── custom-method.php │ ├── full.php │ ├── headers.php │ ├── https.php │ ├── jsonObj-multiline.php │ ├── jsonObj-null-value.php │ ├── multipart-data.php │ ├── multipart-file.php │ ├── multipart-form-data-no-params.php │ ├── multipart-form-data.php │ ├── nested.php │ ├── query.php │ ├── short.php │ └── text-plain.php ├── http1 │ ├── application-form-encoded.php │ ├── application-json.php │ ├── cookies.php │ ├── custom-method.php │ ├── full.php │ ├── headers.php │ ├── https.php │ ├── jsonObj-null-value.php │ ├── multipart-data.php │ ├── multipart-file.php │ ├── multipart-form-data.php │ ├── query.php │ ├── short.php │ └── text-plain.php └── http2 │ ├── application-form-encoded.php │ ├── application-json.php │ ├── cookies.php │ ├── custom-method.php │ ├── full.php │ ├── headers.php │ ├── https.php │ ├── jsonObj-null-value.php │ ├── multipart-data.php │ ├── multipart-file.php │ ├── multipart-form-data.php │ ├── query.php │ ├── short.php │ └── text-plain.php ├── powershell ├── restmethod │ ├── application-form-encoded.ps1 │ ├── application-json.ps1 │ ├── cookies.ps1 │ ├── custom-method.ps1 │ ├── full.ps1 │ ├── headers.ps1 │ ├── https.ps1 │ ├── jsonObj-multiline.ps1 │ ├── jsonObj-null-value.ps1 │ ├── multipart-data.ps1 │ ├── multipart-file.ps1 │ ├── multipart-form-data-no-params.ps1 │ ├── multipart-form-data.ps1 │ ├── nested.ps1 │ ├── query.ps1 │ ├── short.ps1 │ └── text-plain.ps1 └── webrequest │ ├── application-form-encoded.ps1 │ ├── application-json.ps1 │ ├── cookies.ps1 │ ├── custom-method.ps1 │ ├── full.ps1 │ ├── headers.ps1 │ ├── https.ps1 │ ├── jsonObj-null-value.ps1 │ ├── multipart-data.ps1 │ ├── multipart-file.ps1 │ ├── multipart-form-data.ps1 │ ├── query.ps1 │ ├── short.ps1 │ └── text-plain.ps1 ├── python ├── python3 │ ├── application-form-encoded.py │ ├── application-json.py │ ├── cookies.py │ ├── custom-method.py │ ├── full.py │ ├── headers.py │ ├── https.py │ ├── jsonObj-null-value.py │ ├── multipart-data.py │ ├── multipart-file.py │ ├── multipart-form-data.py │ ├── query.py │ ├── short.py │ └── text-plain.py └── requests │ ├── application-form-encoded.py │ ├── application-json.py │ ├── cookies.py │ ├── custom-method.py │ ├── full.py │ ├── headers.py │ ├── https.py │ ├── jsonObj-null-value.py │ ├── multipart-data.py │ ├── multipart-file.py │ ├── multipart-form-data.py │ ├── query.py │ ├── short.py │ └── text-plain.py ├── r └── httpr │ ├── application-form-encoded.r │ ├── application-json.r │ ├── cookies.r │ ├── custom-method.r │ ├── full.r │ ├── headers.r │ ├── https.r │ ├── jsonObj-multiline.r │ ├── jsonObj-null-value.r │ ├── multipart-data.r │ ├── multipart-file.r │ ├── multipart-form-data-no-params.r │ ├── multipart-form-data.r │ ├── nested.r │ ├── query-two-params.r │ ├── query.r │ ├── short.r │ └── text-plain.r ├── ruby ├── faraday │ ├── application-form-encoded.rb │ ├── application-json.rb │ ├── cookies.rb │ ├── custom-method.rb │ ├── full.rb │ ├── headers.rb │ ├── https.rb │ ├── jsonObj-multiline.rb │ ├── jsonObj-null-value.rb │ ├── multipart-data.rb │ ├── multipart-file.rb │ ├── multipart-form-data-no-params.rb │ ├── multipart-form-data.rb │ ├── nested.rb │ ├── query.rb │ ├── short.rb │ └── text-plain.rb └── nethttp │ ├── application-form-encoded.rb │ ├── application-json.rb │ ├── cookies.rb │ ├── custom-method.rb │ ├── full.rb │ ├── headers.rb │ ├── https.rb │ ├── jsonObj-null-value.rb │ ├── multipart-data.rb │ ├── multipart-file.rb │ ├── multipart-form-data.rb │ ├── query.rb │ ├── short.rb │ └── text-plain.rb ├── rust └── reqwest │ ├── application-form-encoded.rs │ ├── application-json.rs │ ├── cookies.rs │ ├── custom-method.rs │ ├── full.rs │ ├── headers.rs │ ├── https.rs │ ├── jsonObj-multiline.rs │ ├── jsonObj-null-value.rs │ ├── multipart-data.rs │ ├── multipart-file.rs │ ├── multipart-form-data-no-params.rs │ ├── multipart-form-data.rs │ ├── nested.rs │ ├── query.rs │ ├── short.rs │ └── text-plain.rs ├── shell ├── curl │ ├── application-form-encoded.sh │ ├── application-json.sh │ ├── cookies.sh │ ├── custom-method.sh │ ├── full.sh │ ├── headers.sh │ ├── http1.sh │ ├── https.sh │ ├── jsonObj-null-value.sh │ ├── multipart-data.sh │ ├── multipart-file.sh │ ├── multipart-form-data.sh │ ├── query.sh │ ├── short.sh │ └── text-plain.sh ├── httpie │ ├── application-form-encoded.sh │ ├── application-json.sh │ ├── cookies.sh │ ├── custom-method.sh │ ├── full.sh │ ├── headers.sh │ ├── https.sh │ ├── jsonObj-null-value.sh │ ├── multipart-data.sh │ ├── multipart-file.sh │ ├── multipart-form-data.sh │ ├── query.sh │ ├── short.sh │ └── text-plain.sh └── wget │ ├── application-form-encoded.sh │ ├── application-json.sh │ ├── cookies.sh │ ├── custom-method.sh │ ├── full.sh │ ├── headers.sh │ ├── https.sh │ ├── jsonObj-null-value.sh │ ├── multipart-data.sh │ ├── multipart-file.sh │ ├── multipart-form-data.sh │ ├── query.sh │ ├── short.sh │ └── text-plain.sh └── swift └── nsurlsession ├── application-form-encoded.swift ├── application-json.swift ├── cookies.swift ├── custom-method.swift ├── full.swift ├── headers.swift ├── https.swift ├── jsonObj-null-value.swift ├── multipart-data.swift ├── multipart-file.swift ├── multipart-form-data.swift ├── query.swift ├── short.swift └── text-plain.swift /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.bak 3 | pom.xml.tag 4 | pom.xml.releaseBackup 5 | pom.xml.versionsBackup 6 | pom.xml.next 7 | release.properties 8 | dependency-reduced-pom.xml 9 | buildNumber.properties 10 | .mvn/timing.properties 11 | 12 | # Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) 13 | !/.mvn/wrapper/maven-wrapper.jar 14 | !src/main/java/io/github/atkawa7/httpsnippet/target 15 | 16 | .idea/ 17 | 18 | .DS_Store 19 | *.iml 20 | 21 | bin/ -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atkawa7/httpsnippet/448efa4584add53f70d7b7f08d609bf343d2e90a/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /docs/generator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atkawa7/httpsnippet/448efa4584add53f70d7b7f08d609bf343d2e90a/docs/generator.png -------------------------------------------------------------------------------- /docs/images/generators.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atkawa7/httpsnippet/448efa4584add53f70d7b7f08d609bf343d2e90a/docs/images/generators.png -------------------------------------------------------------------------------- /docs/index.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atkawa7/httpsnippet/448efa4584add53f70d7b7f08d609bf343d2e90a/docs/index.pdf -------------------------------------------------------------------------------- /images/Redoc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atkawa7/httpsnippet/448efa4584add53f70d7b7f08d609bf343d2e90a/images/Redoc.png -------------------------------------------------------------------------------- /images/Swagger-UI.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atkawa7/httpsnippet/448efa4584add53f70d7b7f08d609bf343d2e90a/images/Swagger-UI.png -------------------------------------------------------------------------------- /lombok.config: -------------------------------------------------------------------------------- 1 | lombok.extern.findbugs.addSuppressFBWarnings=true 2 | lombok.log.fieldName=logger 3 | lombok.addJavaxGeneratedAnnotation = false 4 | lombok.addLombokGeneratedAnnotation = true 5 | lombok.equalsAndHashCode.callSuper=CALL 6 | lombok.log.fieldIsStatic=true 7 | -------------------------------------------------------------------------------- /src/main/java/io/github/atkawa7/httpsnippet/http/HttpHeaders.java: -------------------------------------------------------------------------------- 1 | package io.github.atkawa7.httpsnippet.http; 2 | 3 | import lombok.experimental.UtilityClass; 4 | 5 | @UtilityClass 6 | public class HttpHeaders { 7 | public static final String COOKIE = "Cookie"; 8 | public static final String CONTENT_TYPE = "Content-Type"; 9 | public static final String ACCEPT = "Accept"; 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/io/github/atkawa7/httpsnippet/http/HttpScheme.java: -------------------------------------------------------------------------------- 1 | package io.github.atkawa7.httpsnippet.http; 2 | 3 | public enum HttpScheme { 4 | HTTP("http"), 5 | HTTPS("https"); 6 | private String scheme; 7 | 8 | HttpScheme(String scheme) { 9 | this.scheme = scheme; 10 | } 11 | 12 | public boolean equalsIgnoreCase(String scheme) { 13 | return this.scheme.equalsIgnoreCase(scheme); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/io/github/atkawa7/httpsnippet/models/HttpSnippet.java: -------------------------------------------------------------------------------- 1 | package io.github.atkawa7.httpsnippet.models; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Builder; 5 | import lombok.Data; 6 | import lombok.NoArgsConstructor; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | @NoArgsConstructor 11 | @Builder 12 | public class HttpSnippet { 13 | private Client client; 14 | private Language language; 15 | private String code; 16 | private String displayName; 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/io/github/atkawa7/httpsnippet/fixtures/Fixture.java: -------------------------------------------------------------------------------- 1 | package io.github.atkawa7.httpsnippet.fixtures; 2 | 3 | import io.github.atkawa7.har.HarRequest; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Getter; 6 | 7 | @AllArgsConstructor 8 | @Getter 9 | public class Fixture { 10 | private FixtureType fixtureType; 11 | private HarRequest harRequest; 12 | 13 | @Override 14 | public String toString() { 15 | return "Fixture{name='" + fixtureType.getName() + "'}"; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/io/github/atkawa7/httpsnippet/http/HttpSchemeTest.java: -------------------------------------------------------------------------------- 1 | package io.github.atkawa7.httpsnippet.http; 2 | 3 | import static org.junit.jupiter.api.Assertions.*; 4 | 5 | import org.junit.jupiter.params.ParameterizedTest; 6 | import org.junit.jupiter.params.provider.EnumSource; 7 | 8 | class HttpSchemeTest { 9 | 10 | @ParameterizedTest 11 | @EnumSource(HttpScheme.class) 12 | void testEqualsIgnoreCase(HttpScheme scheme) { 13 | assertTrue(scheme.equalsIgnoreCase(scheme.name())); 14 | assertFalse(scheme.equalsIgnoreCase("foo")); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/application-form-encoded.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "POST", 3 | "url": "http://mockbin.com/har", 4 | "headers": [ 5 | { 6 | "name": "content-type", 7 | "value": "application/x-www-form-urlencoded" 8 | } 9 | ], 10 | "postData": { 11 | "mimeType": "application/x-www-form-urlencoded", 12 | "params": [ 13 | { 14 | "name": "foo", 15 | "value": "bar" 16 | }, 17 | { 18 | "name": "hello", 19 | "value": "world" 20 | } 21 | ] 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/application-json.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "POST", 3 | "url": "http://mockbin.com/har", 4 | "headers": [ 5 | { 6 | "name": "content-type", 7 | "value": "application/json" 8 | } 9 | ], 10 | "postData": { 11 | "mimeType": "application/json", 12 | "text": "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/cookies.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "POST", 3 | "url": "http://mockbin.com/har", 4 | "cookies": [ 5 | { 6 | "name": "foo", 7 | "value": "bar" 8 | }, 9 | { 10 | "name": "bar", 11 | "value": "baz" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/custom-method.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "PROPFIND", 3 | "url": "http://mockbin.com/har" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/headers.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "GET", 3 | "url": "http://mockbin.com/har", 4 | "headers": [ 5 | { 6 | "name": "accept", 7 | "value": "application/json" 8 | }, 9 | { 10 | "name": "x-foo", 11 | "value": "Bar" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/https.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "GET", 3 | "url": "https://mockbin.com/har" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/jsonObj-null-value.json: -------------------------------------------------------------------------------- 1 | { 2 | "url": "http://mockbin.com/har", 3 | "method": "POST", 4 | "headers": [{ 5 | "name": "content-type", 6 | "value": "application/json" 7 | }], 8 | "postData": { 9 | "params": [], 10 | "text": "{\"foo\":null}", 11 | "mimeType": "application/json" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/multipart-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "POST", 3 | "url": "http://mockbin.com/har", 4 | "headers": [ 5 | { 6 | "name": "content-type", 7 | "value": "multipart/form-data" 8 | } 9 | ], 10 | "postData": { 11 | "mimeType": "multipart/form-data", 12 | "params": [ 13 | { 14 | "name": "foo", 15 | "value": "Hello World", 16 | "fileName": "hello.txt", 17 | "contentType": "text/plain" 18 | } 19 | ] 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/multipart-file.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "POST", 3 | "url": "http://mockbin.com/har", 4 | "headers": [ 5 | { 6 | "name": "content-type", 7 | "value": "multipart/form-data" 8 | } 9 | ], 10 | "postData": { 11 | "mimeType": "multipart/form-data", 12 | "params": [ 13 | { 14 | "name": "foo", 15 | "fileName": "hello.txt", 16 | "contentType": "text/plain" 17 | } 18 | ] 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/multipart-form-data.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "POST", 3 | "url": "http://mockbin.com/har", 4 | "headers": [ 5 | { 6 | "name": "content-type", 7 | "value": "multipart/form-data" 8 | } 9 | ], 10 | "postData": { 11 | "mimeType": "multipart/form-data", 12 | "params": [ 13 | { 14 | "name": "foo", 15 | "value": "bar" 16 | } 17 | ] 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/query.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "GET", 3 | "url": "http://mockbin.com/har?key=value", 4 | "httpVersion": "HTTP/1.1", 5 | "queryString": [ 6 | { 7 | "name": "foo", 8 | "value": "bar" 9 | }, 10 | { 11 | "name": "foo", 12 | "value": "baz" 13 | }, 14 | { 15 | "name": "baz", 16 | "value": "abc" 17 | } 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/short.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "GET", 3 | "url": "http://mockbin.com/har" 4 | } 5 | -------------------------------------------------------------------------------- /src/test/resources/fixtures/text-plain.json: -------------------------------------------------------------------------------- 1 | { 2 | "method": "POST", 3 | "url": "http://mockbin.com/har", 4 | "headers": [ 5 | { 6 | "name": "content-type", 7 | "value": "text/plain" 8 | } 9 | ], 10 | "postData": { 11 | "mimeType": "text/plain", 12 | "text": "Hello World" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/application-form-encoded.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); 5 | 6 | struct curl_slist *headers = NULL; 7 | headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded"); 8 | curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); 9 | 10 | curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&hello=world"); 11 | 12 | CURLcode ret = curl_easy_perform(hnd); 13 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/cookies.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); 5 | 6 | curl_easy_setopt(hnd, CURLOPT_COOKIE, "foo=bar; bar=baz"); 7 | 8 | CURLcode ret = curl_easy_perform(hnd); 9 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/custom-method.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); 5 | 6 | CURLcode ret = curl_easy_perform(hnd); 7 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/headers.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); 5 | 6 | struct curl_slist *headers = NULL; 7 | headers = curl_slist_append(headers, "accept: application/json"); 8 | headers = curl_slist_append(headers, "x-foo: Bar"); 9 | curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); 10 | 11 | CURLcode ret = curl_easy_perform(hnd); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/https.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "https://mockbin.com/har"); 5 | 6 | CURLcode ret = curl_easy_perform(hnd); 7 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/jsonObj-null-value.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); 5 | 6 | struct curl_slist *headers = NULL; 7 | headers = curl_slist_append(headers, "content-type: application/json"); 8 | curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); 9 | 10 | curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"foo\":null}"); 11 | 12 | CURLcode ret = curl_easy_perform(hnd); 13 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/query.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value"); 5 | 6 | CURLcode ret = curl_easy_perform(hnd); 7 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/short.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); 5 | 6 | CURLcode ret = curl_easy_perform(hnd); 7 | -------------------------------------------------------------------------------- /src/test/resources/output/c/libcurl/text-plain.c: -------------------------------------------------------------------------------- 1 | CURL *hnd = curl_easy_init(); 2 | 3 | curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); 4 | curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); 5 | 6 | struct curl_slist *headers = NULL; 7 | headers = curl_slist_append(headers, "content-type: text/plain"); 8 | curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); 9 | 10 | curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "Hello World"); 11 | 12 | CURLcode ret = curl_easy_perform(hnd); 13 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/application-form-encoded.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/post "http://mockbin.com/har" {:form-params {:foo "bar" 4 | :hello "world"}}) 5 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/cookies.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/post "http://mockbin.com/har" {:headers {:cookie "foo=bar; bar=baz"}}) 4 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/custom-method.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/get "http://mockbin.com/har") 4 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/full.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/post "http://mockbin.com/har" {:headers {:cookie "foo=bar; bar=baz"} 4 | :query-params {:foo ["bar" "baz"] 5 | :baz "abc" 6 | :key "value"} 7 | :form-params {:foo "bar"} 8 | :accept :json}) 9 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/headers.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/get "http://mockbin.com/har" {:headers {:x-foo "Bar"} 4 | :accept :json}) 5 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/https.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/get "https://mockbin.com/har") 4 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/jsonObj-null-value.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/post "http://mockbin.com/har" {:content-type :json 4 | :form-params {:foo nil}}) 5 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/multipart-data.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/post "http://mockbin.com/har" {:multipart [{:name "foo" 4 | :content "Hello World"}]}) 5 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/multipart-file.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/post "http://mockbin.com/har" {:multipart [{:name "foo" 4 | :content (clojure.java.io/file "test/fixtures/files/hello.txt")}]}) 5 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/multipart-form-data.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/post "http://mockbin.com/har" {:multipart [{:name "foo" 4 | :content "bar"}]}) 5 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/query.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/get "http://mockbin.com/har" {:query-params {:foo ["bar" "baz"] 4 | :baz "abc" 5 | :key "value"}}) 6 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/short.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/get "http://mockbin.com/har") 4 | -------------------------------------------------------------------------------- /src/test/resources/output/clojure/clj_http/text-plain.clj: -------------------------------------------------------------------------------- 1 | (require '[clj-http.client :as client]) 2 | 3 | (client/post "http://mockbin.com/har" {:body "Hello World"}) 4 | -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/application-form-encoded.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "content-type" => "application/x-www-form-urlencoded" 6 | } 7 | reqBody = "foo=bar&hello=world" 8 | 9 | response = HTTP::Client.post url, headers: headers, body: reqBody 10 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/application-json.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "content-type" => "application/json" 6 | } 7 | reqBody = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 8 | 9 | response = HTTP::Client.post url, headers: headers, body: reqBody 10 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/cookies.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "cookie" => "foo=bar; bar=baz" 6 | } 7 | 8 | response = HTTP::Client.post url, headers: headers 9 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/custom-method.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | response = HTTP::Client.exec "PROPFIND", url 6 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/full.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value" 4 | headers = HTTP::Headers{ 5 | "cookie" => "foo=bar; bar=baz" 6 | "accept" => "application/json" 7 | "content-type" => "application/x-www-form-urlencoded" 8 | } 9 | reqBody = "foo=bar" 10 | 11 | response = HTTP::Client.post url, headers: headers, body: reqBody 12 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/headers.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "accept" => "application/json" 6 | "x-foo" => "Bar" 7 | "quoted-value" => "\"quoted\" 'string'" 8 | } 9 | 10 | response = HTTP::Client.get url, headers: headers 11 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/https.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "https://mockbin.com/har" 4 | 5 | response = HTTP::Client.get url 6 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/insecure-skip-verify.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "https://mockbin.com/har" 4 | 5 | response = HTTP::Client.get url, tls: OpenSSL::SSL::Context::Client.insecure 6 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/jsonObj-multiline.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "content-type" => "application/json" 6 | } 7 | reqBody = "{\n \"foo\": \"bar\"\n}" 8 | 9 | response = HTTP::Client.post url, headers: headers, body: reqBody 10 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/jsonObj-null-value.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "content-type" => "application/json" 6 | } 7 | reqBody = "{\"foo\":null}" 8 | 9 | response = HTTP::Client.post url, headers: headers, body: reqBody 10 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/multipart-file.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "content-type" => "multipart/form-data; boundary=---011000010111000001101001" 6 | } 7 | reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--\r\n" 8 | 9 | response = HTTP::Client.post url, headers: headers, body: reqBody 10 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/multipart-form-data-no-params.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "Content-Type" => "multipart/form-data" 6 | } 7 | 8 | response = HTTP::Client.post url, headers: headers 9 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/multipart-form-data.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "Content-Type" => "multipart/form-data; boundary=---011000010111000001101001" 6 | } 7 | reqBody = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" 8 | 9 | response = HTTP::Client.post url, headers: headers, body: reqBody 10 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/nested.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value" 4 | 5 | response = HTTP::Client.get url 6 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/query.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value" 4 | 5 | response = HTTP::Client.get url 6 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/short.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | response = HTTP::Client.get url 6 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/crystal/native/text-plain.cr: -------------------------------------------------------------------------------- 1 | require "http/client" 2 | 3 | url = "http://mockbin.com/har" 4 | headers = HTTP::Headers{ 5 | "content-type" => "text/plain" 6 | } 7 | reqBody = "Hello World" 8 | 9 | response = HTTP::Client.post url, headers: headers, body: reqBody 10 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/csharp/httpclient/custom-method.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Headers; 2 | var client = new HttpClient(); 3 | var request = new HttpRequestMessage 4 | { 5 | Method = new HttpMethod("PROPFIND"), 6 | RequestUri = new Uri("http://mockbin.com/har"), 7 | }; 8 | using (var response = await client.SendAsync(request)) 9 | { 10 | response.EnsureSuccessStatusCode(); 11 | var body = await response.Content.ReadAsStringAsync(); 12 | Console.WriteLine(body); 13 | } -------------------------------------------------------------------------------- /src/test/resources/output/csharp/httpclient/https.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Headers; 2 | var client = new HttpClient(); 3 | var request = new HttpRequestMessage 4 | { 5 | Method = HttpMethod.Get, 6 | RequestUri = new Uri("https://mockbin.com/har"), 7 | }; 8 | using (var response = await client.SendAsync(request)) 9 | { 10 | response.EnsureSuccessStatusCode(); 11 | var body = await response.Content.ReadAsStringAsync(); 12 | Console.WriteLine(body); 13 | } -------------------------------------------------------------------------------- /src/test/resources/output/csharp/httpclient/multipart-form-data-no-params.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Headers; 2 | var client = new HttpClient(); 3 | var request = new HttpRequestMessage 4 | { 5 | Method = HttpMethod.Post, 6 | RequestUri = new Uri("http://mockbin.com/har"), 7 | }; 8 | using (var response = await client.SendAsync(request)) 9 | { 10 | response.EnsureSuccessStatusCode(); 11 | var body = await response.Content.ReadAsStringAsync(); 12 | Console.WriteLine(body); 13 | } -------------------------------------------------------------------------------- /src/test/resources/output/csharp/httpclient/nested.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Headers; 2 | var client = new HttpClient(); 3 | var request = new HttpRequestMessage 4 | { 5 | Method = HttpMethod.Get, 6 | RequestUri = new Uri("http://mockbin.com/har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value"), 7 | }; 8 | using (var response = await client.SendAsync(request)) 9 | { 10 | response.EnsureSuccessStatusCode(); 11 | var body = await response.Content.ReadAsStringAsync(); 12 | Console.WriteLine(body); 13 | } -------------------------------------------------------------------------------- /src/test/resources/output/csharp/httpclient/query.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Headers; 2 | var client = new HttpClient(); 3 | var request = new HttpRequestMessage 4 | { 5 | Method = HttpMethod.Get, 6 | RequestUri = new Uri("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"), 7 | }; 8 | using (var response = await client.SendAsync(request)) 9 | { 10 | response.EnsureSuccessStatusCode(); 11 | var body = await response.Content.ReadAsStringAsync(); 12 | Console.WriteLine(body); 13 | } -------------------------------------------------------------------------------- /src/test/resources/output/csharp/httpclient/short.cs: -------------------------------------------------------------------------------- 1 | using System.Net.Http.Headers; 2 | var client = new HttpClient(); 3 | var request = new HttpRequestMessage 4 | { 5 | Method = HttpMethod.Get, 6 | RequestUri = new Uri("http://mockbin.com/har"), 7 | }; 8 | using (var response = await client.SendAsync(request)) 9 | { 10 | response.EnsureSuccessStatusCode(); 11 | var body = await response.Content.ReadAsStringAsync(); 12 | Console.WriteLine(body); 13 | } -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/application-form-encoded.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.POST); 3 | request.AddHeader("content-type", "application/x-www-form-urlencoded"); 4 | request.AddParameter("application/x-www-form-urlencoded", "foo=bar&hello=world", ParameterType.RequestBody); 5 | IRestResponse response = client.Execute(request); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/application-json.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.POST); 3 | request.AddHeader("content-type", "application/json"); 4 | request.AddParameter("application/json", "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}", ParameterType.RequestBody); 5 | IRestResponse response = client.Execute(request); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/cookies.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.POST); 3 | request.AddCookie("foo", "bar"); 4 | request.AddCookie("bar", "baz"); 5 | IRestResponse response = client.Execute(request); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/custom-method.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.GET); 3 | IRestResponse response = client.Execute(request); 4 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/full.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value"); 2 | var request = new RestRequest(Method.POST); 3 | request.AddHeader("accept", "application/json"); 4 | request.AddHeader("content-type", "application/x-www-form-urlencoded"); 5 | request.AddCookie("foo", "bar"); 6 | request.AddCookie("bar", "baz"); 7 | request.AddParameter("application/x-www-form-urlencoded", "foo=bar", ParameterType.RequestBody); 8 | IRestResponse response = client.Execute(request); 9 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/headers.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.GET); 3 | request.AddHeader("accept", "application/json"); 4 | request.AddHeader("x-foo", "Bar"); 5 | IRestResponse response = client.Execute(request); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/https.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("https://mockbin.com/har"); 2 | var request = new RestRequest(Method.GET); 3 | IRestResponse response = client.Execute(request); 4 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/jsonObj-null-value.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.POST); 3 | request.AddHeader("content-type", "application/json"); 4 | request.AddParameter("application/json", "{\"foo\":null}", ParameterType.RequestBody); 5 | IRestResponse response = client.Execute(request); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/multipart-data.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.POST); 3 | request.AddHeader("content-type", "multipart/form-data"); 4 | request.AddFile("foo", "hello.txt"); 5 | IRestResponse response = client.Execute(request); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/multipart-form-data.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.POST); 3 | request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001"); 4 | request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); 5 | IRestResponse response = client.Execute(request); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/query.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value"); 2 | var request = new RestRequest(Method.GET); 3 | IRestResponse response = client.Execute(request); 4 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/short.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.GET); 3 | IRestResponse response = client.Execute(request); 4 | -------------------------------------------------------------------------------- /src/test/resources/output/csharp/restsharp/text-plain.cs: -------------------------------------------------------------------------------- 1 | var client = new RestClient("http://mockbin.com/har"); 2 | var request = new RestRequest(Method.POST); 3 | request.AddHeader("content-type", "text/plain"); 4 | request.AddParameter("text/plain", "Hello World", ParameterType.RequestBody); 5 | IRestResponse response = client.Execute(request); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/go/native/cookies.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "io/ioutil" 7 | ) 8 | 9 | func main() { 10 | 11 | url := "http://mockbin.com/har" 12 | 13 | req, _ := http.NewRequest("POST", url, nil) 14 | 15 | req.Header.Add("Cookie", "foo=bar; bar=baz") 16 | 17 | res, _ := http.DefaultClient.Do(req) 18 | 19 | defer res.Body.Close() 20 | body, _ := ioutil.ReadAll(res.Body) 21 | 22 | fmt.Println(res) 23 | fmt.Println(string(body)) 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/test/resources/output/go/native/custom-method.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "io/ioutil" 7 | ) 8 | 9 | func main() { 10 | 11 | url := "http://mockbin.com/har" 12 | 13 | req, _ := http.NewRequest("GET", url, nil) 14 | 15 | res, _ := http.DefaultClient.Do(req) 16 | 17 | defer res.Body.Close() 18 | body, _ := ioutil.ReadAll(res.Body) 19 | 20 | fmt.Println(res) 21 | fmt.Println(string(body)) 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/output/go/native/headers.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "io/ioutil" 7 | ) 8 | 9 | func main() { 10 | 11 | url := "http://mockbin.com/har" 12 | 13 | req, _ := http.NewRequest("GET", url, nil) 14 | 15 | req.Header.Add("x-foo", "Bar") 16 | req.Header.Add("accept", "application/json") 17 | 18 | res, _ := http.DefaultClient.Do(req) 19 | 20 | defer res.Body.Close() 21 | body, _ := ioutil.ReadAll(res.Body) 22 | 23 | fmt.Println(res) 24 | fmt.Println(string(body)) 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/resources/output/go/native/https.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "io/ioutil" 7 | ) 8 | 9 | func main() { 10 | 11 | url := "https://mockbin.com/har" 12 | 13 | req, _ := http.NewRequest("GET", url, nil) 14 | 15 | res, _ := http.DefaultClient.Do(req) 16 | 17 | defer res.Body.Close() 18 | body, _ := ioutil.ReadAll(res.Body) 19 | 20 | fmt.Println(res) 21 | fmt.Println(string(body)) 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/output/go/native/query.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "io/ioutil" 7 | ) 8 | 9 | func main() { 10 | 11 | url := "http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value" 12 | 13 | req, _ := http.NewRequest("GET", url, nil) 14 | 15 | res, _ := http.DefaultClient.Do(req) 16 | 17 | defer res.Body.Close() 18 | body, _ := ioutil.ReadAll(res.Body) 19 | 20 | fmt.Println(res) 21 | fmt.Println(string(body)) 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/output/go/native/short.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "io/ioutil" 7 | ) 8 | 9 | func main() { 10 | 11 | url := "http://mockbin.com/har" 12 | 13 | req, _ := http.NewRequest("GET", url, nil) 14 | 15 | res, _ := http.DefaultClient.Do(req) 16 | 17 | defer res.Body.Close() 18 | body, _ := ioutil.ReadAll(res.Body) 19 | 20 | fmt.Println(res) 21 | fmt.Println(string(body)) 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/application-form-encoded: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: application/x-www-form-urlencoded 3 | Host: mockbin.com 4 | Content-Length: 19 5 | 6 | foo=bar&hello=world -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/application-json: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: application/json 3 | Host: mockbin.com 4 | Content-Length: 118 5 | 6 | {"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false} -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/cookies: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Cookie: foo=bar; bar=baz 3 | Host: mockbin.com 4 | 5 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/custom-method: -------------------------------------------------------------------------------- 1 | PROPFIND /har HTTP/1.1 2 | Host: mockbin.com 3 | 4 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/full: -------------------------------------------------------------------------------- 1 | POST /har?foo=bar&foo=baz&baz=abc&key=value HTTP/1.1 2 | Cookie: foo=bar; bar=baz 3 | Accept: application/json 4 | Content-Type: application/x-www-form-urlencoded 5 | Host: mockbin.com 6 | Content-Length: 7 7 | 8 | foo=bar -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/headers: -------------------------------------------------------------------------------- 1 | GET /har HTTP/1.1 2 | Accept: application/json 3 | X-Foo: Bar 4 | Quoted-Value: "quoted" 'string' 5 | Host: mockbin.com 6 | 7 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/https: -------------------------------------------------------------------------------- 1 | GET /har HTTP/1.1 2 | Host: mockbin.com 3 | 4 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/jsonObj-multiline: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: application/json 3 | Host: mockbin.com 4 | Content-Length: 18 5 | 6 | { 7 | "foo": "bar" 8 | } -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/jsonObj-null-value: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: application/json 3 | Host: mockbin.com 4 | Content-Length: 12 5 | 6 | {"foo":null} -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/multipart-data: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: multipart/form-data; boundary=---011000010111000001101001 3 | Host: mockbin.com 4 | Content-Length: 266 5 | 6 | -----011000010111000001101001 7 | Content-Disposition: form-data; name="foo"; filename="hello.txt" 8 | Content-Type: text/plain 9 | 10 | Hello World 11 | -----011000010111000001101001 12 | Content-Disposition: form-data; name="bar" 13 | 14 | Bonjour le monde 15 | -----011000010111000001101001-- 16 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/multipart-file: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: multipart/form-data; boundary=---011000010111000001101001 3 | Host: mockbin.com 4 | Content-Length: 160 5 | 6 | -----011000010111000001101001 7 | Content-Disposition: form-data; name="foo"; filename="hello.txt" 8 | Content-Type: text/plain 9 | 10 | 11 | -----011000010111000001101001-- 12 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/multipart-form-data: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: multipart/form-data; boundary=---011000010111000001101001 3 | Host: mockbin.com 4 | Content-Length: 115 5 | 6 | -----011000010111000001101001 7 | Content-Disposition: form-data; name="foo" 8 | 9 | bar 10 | -----011000010111000001101001-- 11 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/multipart-form-data-no-params: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: multipart/form-data 3 | Host: mockbin.com 4 | 5 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/nested: -------------------------------------------------------------------------------- 1 | GET /har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value HTTP/1.1 2 | Host: mockbin.com 3 | 4 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/query: -------------------------------------------------------------------------------- 1 | GET /har?foo=bar&foo=baz&baz=abc&key=value HTTP/1.1 2 | Host: mockbin.com 3 | 4 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/short: -------------------------------------------------------------------------------- 1 | GET /har HTTP/1.1 2 | Host: mockbin.com 3 | 4 | -------------------------------------------------------------------------------- /src/test/resources/output/http/http1.1/text-plain: -------------------------------------------------------------------------------- 1 | POST /har HTTP/1.1 2 | Content-Type: text/plain 3 | Host: mockbin.com 4 | Content-Length: 11 5 | 6 | Hello World -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/application-form-encoded.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har") 3 | .setHeader("content-type", "application/x-www-form-urlencoded") 4 | .setBody("foo=bar&hello=world") 5 | .execute() 6 | .toCompletableFuture() 7 | .thenAccept(System.out::println) 8 | .join(); 9 | 10 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/application-json.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har") 3 | .setHeader("content-type", "application/json") 4 | .setBody("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}") 5 | .execute() 6 | .toCompletableFuture() 7 | .thenAccept(System.out::println) 8 | .join(); 9 | 10 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/cookies.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har") 3 | .setHeader("cookie", "foo=bar; bar=baz") 4 | .execute() 5 | .toCompletableFuture() 6 | .thenAccept(System.out::println) 7 | .join(); 8 | 9 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/custom-method.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("PROPFIND", "http://mockbin.com/har") 3 | .execute() 4 | .toCompletableFuture() 5 | .thenAccept(System.out::println) 6 | .join(); 7 | 8 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/full.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") 3 | .setHeader("cookie", "foo=bar; bar=baz") 4 | .setHeader("accept", "application/json") 5 | .setHeader("content-type", "application/x-www-form-urlencoded") 6 | .setBody("foo=bar") 7 | .execute() 8 | .toCompletableFuture() 9 | .thenAccept(System.out::println) 10 | .join(); 11 | 12 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/headers.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("GET", "http://mockbin.com/har") 3 | .setHeader("accept", "application/json") 4 | .setHeader("x-foo", "Bar") 5 | .setHeader("quoted-value", "\"quoted\" 'string'") 6 | .execute() 7 | .toCompletableFuture() 8 | .thenAccept(System.out::println) 9 | .join(); 10 | 11 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/https.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("GET", "https://mockbin.com/har") 3 | .execute() 4 | .toCompletableFuture() 5 | .thenAccept(System.out::println) 6 | .join(); 7 | 8 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/jsonObj-multiline.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har") 3 | .setHeader("content-type", "application/json") 4 | .setBody("{\n \"foo\": \"bar\"\n}") 5 | .execute() 6 | .toCompletableFuture() 7 | .thenAccept(System.out::println) 8 | .join(); 9 | 10 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/jsonObj-null-value.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har") 3 | .setHeader("content-type", "application/json") 4 | .setBody("{\"foo\":null}") 5 | .execute() 6 | .toCompletableFuture() 7 | .thenAccept(System.out::println) 8 | .join(); 9 | 10 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/multipart-form-data-no-params.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har") 3 | .setHeader("Content-Type", "multipart/form-data") 4 | .execute() 5 | .toCompletableFuture() 6 | .thenAccept(System.out::println) 7 | .join(); 8 | 9 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/multipart-form-data.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har") 3 | .setHeader("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") 4 | .setBody("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n") 5 | .execute() 6 | .toCompletableFuture() 7 | .thenAccept(System.out::println) 8 | .join(); 9 | 10 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/nested.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("GET", "http://mockbin.com/har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value") 3 | .execute() 4 | .toCompletableFuture() 5 | .thenAccept(System.out::println) 6 | .join(); 7 | 8 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/query.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("GET", "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") 3 | .execute() 4 | .toCompletableFuture() 5 | .thenAccept(System.out::println) 6 | .join(); 7 | 8 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/short.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("GET", "http://mockbin.com/har") 3 | .execute() 4 | .toCompletableFuture() 5 | .thenAccept(System.out::println) 6 | .join(); 7 | 8 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/asynchttp/text-plain.java: -------------------------------------------------------------------------------- 1 | AsyncHttpClient client = new DefaultAsyncHttpClient(); 2 | client.prepare("POST", "http://mockbin.com/har") 3 | .setHeader("content-type", "text/plain") 4 | .setBody("Hello World") 5 | .execute() 6 | .toCompletableFuture() 7 | .thenAccept(System.out::println) 8 | .join(); 9 | 10 | client.close(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/application-form-encoded.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.POST) 3 | .header("content-type", "application/x-www-form-urlencoded") 4 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/application-json.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.POST) 3 | .header("content-type", "application/json") 4 | .requestBody("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}") -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/cookies.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.POST) 3 | .header("Cookie", "foo=bar; bar=baz") 4 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/custom-method.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.GET) 3 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/full.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value") 2 | .method(Method.POST) 3 | .header("Cookie", "foo=bar; bar=baz") 4 | .header("content-type", "application/x-www-form-urlencoded") 5 | .header("accept", "application/json") 6 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/headers.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.GET) 3 | .header("x-foo", "Bar") 4 | .header("accept", "application/json") 5 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/https.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("https://mockbin.com/har") 2 | .method(Method.GET) 3 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/jsonObj-null-value.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.POST) 3 | .header("content-type", "application/json") 4 | .requestBody("{\"foo\":null}") -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/multipart-data.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.POST) 3 | .header("content-type", "multipart/form-data") 4 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/multipart-file.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.POST) 3 | .header("content-type", "multipart/form-data") 4 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/multipart-form-data.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.POST) 3 | .header("content-type", "multipart/form-data") 4 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/query.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value") 2 | .method(Method.GET) 3 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/short.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.GET) 3 | .execute().body(); -------------------------------------------------------------------------------- /src/test/resources/output/java/jsoup/text-plain.java: -------------------------------------------------------------------------------- 1 | String response = Jsoup.connect("http://mockbin.com/har") 2 | .method(Method.POST) 3 | .header("content-type", "text/plain") 4 | .requestBody("Hello World") -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/application-form-encoded.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .header("content-type", "application/x-www-form-urlencoded") 4 | .method("POST", HttpRequest.BodyPublishers.ofString("foo=bar&hello=world")) 5 | .build(); 6 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 7 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/cookies.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .header("cookie", "foo=bar; bar=baz") 4 | .method("POST", HttpRequest.BodyPublishers.noBody()) 5 | .build(); 6 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 7 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/custom-method.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .method("PROPFIND", HttpRequest.BodyPublishers.noBody()) 4 | .build(); 5 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 6 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/full.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")) 3 | .header("cookie", "foo=bar; bar=baz") 4 | .header("accept", "application/json") 5 | .header("content-type", "application/x-www-form-urlencoded") 6 | .method("POST", HttpRequest.BodyPublishers.ofString("foo=bar")) 7 | .build(); 8 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 9 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/headers.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .header("accept", "application/json") 4 | .header("x-foo", "Bar") 5 | .header("quoted-value", "\"quoted\" 'string'") 6 | .method("GET", HttpRequest.BodyPublishers.noBody()) 7 | .build(); 8 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 9 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/https.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("https://mockbin.com/har")) 3 | .method("GET", HttpRequest.BodyPublishers.noBody()) 4 | .build(); 5 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 6 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/jsonObj-multiline.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .header("content-type", "application/json") 4 | .method("POST", HttpRequest.BodyPublishers.ofString("{\n \"foo\": \"bar\"\n}")) 5 | .build(); 6 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 7 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/jsonObj-null-value.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .header("content-type", "application/json") 4 | .method("POST", HttpRequest.BodyPublishers.ofString("{\"foo\":null}")) 5 | .build(); 6 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 7 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/multipart-form-data-no-params.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .header("Content-Type", "multipart/form-data") 4 | .method("POST", HttpRequest.BodyPublishers.noBody()) 5 | .build(); 6 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 7 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/nested.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value")) 3 | .method("GET", HttpRequest.BodyPublishers.noBody()) 4 | .build(); 5 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 6 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/query.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")) 3 | .method("GET", HttpRequest.BodyPublishers.noBody()) 4 | .build(); 5 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 6 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/short.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .method("GET", HttpRequest.BodyPublishers.noBody()) 4 | .build(); 5 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 6 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/nethttp/text-plain.java: -------------------------------------------------------------------------------- 1 | HttpRequest request = HttpRequest.newBuilder() 2 | .uri(URI.create("http://mockbin.com/har")) 3 | .header("content-type", "text/plain") 4 | .method("POST", HttpRequest.BodyPublishers.ofString("Hello World")) 5 | .build(); 6 | HttpResponse response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString()); 7 | System.out.println(response.body()); -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/application-form-encoded.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | RequestBody body = new FormBody.Builder() 4 | .add("foo", "bar") 5 | .add("hello", "world") 6 | .build(); 7 | Request request = new Request.Builder() 8 | .url("http://mockbin.com/har") 9 | .post(body) 10 | .addHeader("content-type", "application/x-www-form-urlencoded") 11 | .build(); 12 | 13 | Response response = client.newCall(request).execute(); 14 | -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/cookies.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | Request request = new Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .post(null) 6 | .addHeader("Cookie", "foo=bar; bar=baz") 7 | .build(); 8 | 9 | Response response = client.newCall(request).execute(); 10 | -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/custom-method.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | Request request = new Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .get() 6 | .build(); 7 | 8 | Response response = client.newCall(request).execute(); 9 | -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/headers.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | Request request = new Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .get() 6 | .addHeader("x-foo", "Bar") 7 | .addHeader("accept", "application/json") 8 | .build(); 9 | 10 | Response response = client.newCall(request).execute(); 11 | -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/https.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | Request request = new Request.Builder() 4 | .url("https://mockbin.com/har") 5 | .get() 6 | .build(); 7 | 8 | Response response = client.newCall(request).execute(); 9 | -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/jsonObj-null-value.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | MediaType mediaType = MediaType.parse("application/json"); 4 | RequestBody body = RequestBody.create(mediaType, "{\"foo\":null}"); 5 | Request request = new Request.Builder() 6 | .url("http://mockbin.com/har") 7 | .post(body) 8 | .addHeader("content-type", "application/json") 9 | .build(); 10 | 11 | Response response = client.newCall(request).execute(); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/query.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | Request request = new Request.Builder() 4 | .url("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value") 5 | .get() 6 | .build(); 7 | 8 | Response response = client.newCall(request).execute(); 9 | -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/short.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | Request request = new Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .get() 6 | .build(); 7 | 8 | Response response = client.newCall(request).execute(); 9 | -------------------------------------------------------------------------------- /src/test/resources/output/java/okhttp/text-plain.java: -------------------------------------------------------------------------------- 1 | OkHttpClient client = new OkHttpClient(); 2 | 3 | MediaType mediaType = MediaType.parse("text/plain"); 4 | RequestBody body = RequestBody.create(mediaType, "Hello World"); 5 | Request request = new Request.Builder() 6 | .url("http://mockbin.com/har") 7 | .post(body) 8 | .addHeader("content-type", "text/plain") 9 | .build(); 10 | 11 | Response response = client.newCall(request).execute(); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/application-form-encoded.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har") 2 | .header("content-type", "application/x-www-form-urlencoded") 3 | .field("foo","bar") 4 | .field("hello","world") 5 | .asString(); 6 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/application-json.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har") 2 | .header("content-type", "application/json") 3 | .body("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}") 4 | .asString(); 5 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/cookies.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har") 2 | .header("Cookie", "foo=bar; bar=baz") 3 | .asString(); 4 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/custom-method.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.get("http://mockbin.com/har") 2 | .asString(); 3 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/full.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value") 2 | .header("Cookie", "foo=bar; bar=baz") 3 | .header("content-type", "application/x-www-form-urlencoded") 4 | .header("accept", "application/json") 5 | .field("foo","bar") 6 | .asString(); 7 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/headers.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.get("http://mockbin.com/har") 2 | .header("x-foo", "Bar") 3 | .header("accept", "application/json") 4 | .asString(); 5 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/https.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.get("https://mockbin.com/har") 2 | .asString(); 3 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/jsonObj-null-value.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har") 2 | .header("content-type", "application/json") 3 | .body("{\"foo\":null}") 4 | .asString(); 5 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/multipart-data.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har") 2 | .header("content-type", "multipart/form-data") 3 | .field("foo", new File("hello.txt")) 4 | .asString(); 5 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/multipart-file.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har") 2 | .header("content-type", "multipart/form-data; boundary=---011000010111000001101001") 3 | .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--\r\n") 4 | .asString(); 5 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/multipart-form-data.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har") 2 | .header("content-type", "multipart/form-data; boundary=---011000010111000001101001") 3 | .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n") 4 | .asString(); 5 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/query.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.get("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value") 2 | .asString(); 3 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/short.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.get("http://mockbin.com/har") 2 | .asString(); 3 | -------------------------------------------------------------------------------- /src/test/resources/output/java/unirest/text-plain.java: -------------------------------------------------------------------------------- 1 | HttpResponse response = Unirest.post("http://mockbin.com/har") 2 | .header("content-type", "text/plain") 3 | .body("Hello World") 4 | .asString(); 5 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/application-form-encoded.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const encodedParams = new URLSearchParams(); 4 | encodedParams.set('foo', 'bar'); 5 | encodedParams.set('hello', 'world'); 6 | 7 | const options = { 8 | method: 'POST', 9 | url: 'http://mockbin.com/har', 10 | headers: {'content-type': 'application/x-www-form-urlencoded'}, 11 | data: encodedParams, 12 | }; 13 | 14 | try { 15 | const { data } = await axios.request(options); 16 | console.log(data); 17 | } catch (error) { 18 | console.error(error); 19 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/cookies.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {cookie: 'foo=bar; bar=baz'} 7 | }; 8 | 9 | try { 10 | const { data } = await axios.request(options); 11 | console.log(data); 12 | } catch (error) { 13 | console.error(error); 14 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/custom-method.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = {method: 'PROPFIND', url: 'http://mockbin.com/har'}; 4 | 5 | try { 6 | const { data } = await axios.request(options); 7 | console.log(data); 8 | } catch (error) { 9 | console.error(error); 10 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/headers.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = { 4 | method: 'GET', 5 | url: 'http://mockbin.com/har', 6 | headers: { 7 | accept: 'application/json', 8 | 'x-foo': 'Bar', 9 | 'quoted-value': '"quoted" \'string\'' 10 | } 11 | }; 12 | 13 | try { 14 | const { data } = await axios.request(options); 15 | console.log(data); 16 | } catch (error) { 17 | console.error(error); 18 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/https.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = {method: 'GET', url: 'https://mockbin.com/har'}; 4 | 5 | try { 6 | const { data } = await axios.request(options); 7 | console.log(data); 8 | } catch (error) { 9 | console.error(error); 10 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/jsonObj-multiline.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {'content-type': 'application/json'}, 7 | data: {foo: 'bar'} 8 | }; 9 | 10 | try { 11 | const { data } = await axios.request(options); 12 | console.log(data); 13 | } catch (error) { 14 | console.error(error); 15 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/jsonObj-null-value.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {'content-type': 'application/json'}, 7 | data: {foo: null} 8 | }; 9 | 10 | try { 11 | const { data } = await axios.request(options); 12 | console.log(data); 13 | } catch (error) { 14 | console.error(error); 15 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/multipart-data.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const form = new FormData(); 4 | form.append('foo', 'Hello World'); 5 | form.append('bar', 'Bonjour le monde'); 6 | 7 | const options = { 8 | method: 'POST', 9 | url: 'http://mockbin.com/har', 10 | headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'}, 11 | data: '[form]' 12 | }; 13 | 14 | try { 15 | const { data } = await axios.request(options); 16 | console.log(data); 17 | } catch (error) { 18 | console.error(error); 19 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/multipart-file.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const form = new FormData(); 4 | form.append('foo', 'test/fixtures/files/hello.txt'); 5 | 6 | const options = { 7 | method: 'POST', 8 | url: 'http://mockbin.com/har', 9 | headers: {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'}, 10 | data: '[form]' 11 | }; 12 | 13 | try { 14 | const { data } = await axios.request(options); 15 | console.log(data); 16 | } catch (error) { 17 | console.error(error); 18 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/multipart-form-data-no-params.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {'Content-Type': 'multipart/form-data'} 7 | }; 8 | 9 | try { 10 | const { data } = await axios.request(options); 11 | console.log(data); 12 | } catch (error) { 13 | console.error(error); 14 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/multipart-form-data.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const form = new FormData(); 4 | form.append('foo', 'bar'); 5 | 6 | const options = { 7 | method: 'POST', 8 | url: 'http://mockbin.com/har', 9 | headers: {'Content-Type': 'multipart/form-data; boundary=---011000010111000001101001'}, 10 | data: '[form]' 11 | }; 12 | 13 | try { 14 | const { data } = await axios.request(options); 15 | console.log(data); 16 | } catch (error) { 17 | console.error(error); 18 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/nested.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = { 4 | method: 'GET', 5 | url: 'http://mockbin.com/har', 6 | params: {'foo[bar]': 'baz,zap', fiz: 'buz', key: 'value'} 7 | }; 8 | 9 | try { 10 | const { data } = await axios.request(options); 11 | console.log(data); 12 | } catch (error) { 13 | console.error(error); 14 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/query.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = { 4 | method: 'GET', 5 | url: 'http://mockbin.com/har', 6 | params: {foo: ['bar', 'baz'], baz: 'abc', key: 'value'} 7 | }; 8 | 9 | try { 10 | const { data } = await axios.request(options); 11 | console.log(data); 12 | } catch (error) { 13 | console.error(error); 14 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/short.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = {method: 'GET', url: 'http://mockbin.com/har'}; 4 | 5 | try { 6 | const { data } = await axios.request(options); 7 | console.log(data); 8 | } catch (error) { 9 | console.error(error); 10 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/axios/text-plain.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios'; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {'content-type': 'text/plain'}, 7 | data: 'Hello World' 8 | }; 9 | 10 | try { 11 | const { data } = await axios.request(options); 12 | console.log(data); 13 | } catch (error) { 14 | console.error(error); 15 | } -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/application-json.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "POST", 4 | "headers": { 5 | "content-type": "application/json" 6 | }, 7 | "body": "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 8 | } 9 | 10 | fetch("http://mockbin.com/har", fetchOptions) 11 | .then(response => response.json()) 12 | .then(data => console.log(data)) 13 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/cookies.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "POST", 4 | "headers": { 5 | "Cookie": "foo=bar; bar=baz" 6 | } 7 | } 8 | 9 | fetch("http://mockbin.com/har", fetchOptions) 10 | .then(response => response.json()) 11 | .then(data => console.log(data)) 12 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/custom-method.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "GET", 4 | "headers": { } 5 | } 6 | 7 | fetch("http://mockbin.com/har", fetchOptions) 8 | .then(response => response.json()) 9 | .then(data => console.log(data)) 10 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/headers.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "GET", 4 | "headers": { 5 | "x-foo": "Bar", 6 | "accept": "application/json" 7 | } 8 | } 9 | 10 | fetch("http://mockbin.com/har", fetchOptions) 11 | .then(response => response.json()) 12 | .then(data => console.log(data)) 13 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/https.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "GET", 4 | "headers": { } 5 | } 6 | 7 | fetch("https://mockbin.com/har", fetchOptions) 8 | .then(response => response.json()) 9 | .then(data => console.log(data)) 10 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/jsonObj-null-value.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "POST", 4 | "headers": { 5 | "content-type": "application/json" 6 | }, 7 | "body": "{\"foo\":null}" 8 | } 9 | 10 | fetch("http://mockbin.com/har", fetchOptions) 11 | .then(response => response.json()) 12 | .then(data => console.log(data)) 13 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/multipart-data.js: -------------------------------------------------------------------------------- 1 | let form = new FormData(); 2 | form.append("foo", "hello.txt"); 3 | 4 | const fetchOptions = { 5 | "mode": "cors", 6 | "method": "POST", 7 | "headers": { 8 | "content-type": "multipart/form-data" 9 | }, 10 | "body": form 11 | } 12 | 13 | fetch("http://mockbin.com/har", fetchOptions) 14 | .then(response => response.json()) 15 | .then(data => console.log(data)) 16 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/multipart-file.js: -------------------------------------------------------------------------------- 1 | let form = new FormData(); 2 | form.append('foo', 'test/fixtures/files/hello.txt'); 3 | 4 | const fetchOptions = { 5 | mode: 'cors', 6 | method: 'POST', 7 | body: form, 8 | }; 9 | 10 | fetch("http://mockbin.com/har", fetchOptions) 11 | .then(response => response.json()) 12 | .then(data => console.log(data)) 13 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/multipart-form-data.js: -------------------------------------------------------------------------------- 1 | let form = new FormData(); 2 | form.append('foo', 'bar'); 3 | 4 | const fetchOptions = { 5 | mode: 'cors', 6 | method: 'POST', 7 | body: form, 8 | }; 9 | 10 | fetch("http://mockbin.com/har", fetchOptions) 11 | .then(response => response.json()) 12 | .then(data => console.log(data)) 13 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/query.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "GET", 4 | "headers": { } 5 | } 6 | 7 | fetch("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value", fetchOptions) 8 | .then(response => response.json()) 9 | .then(data => console.log(data)) 10 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/short.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "GET", 4 | "headers": { } 5 | } 6 | 7 | fetch("http://mockbin.com/har", fetchOptions) 8 | .then(response => response.json()) 9 | .then(data => console.log(data)) 10 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/fetch/text-plain.js: -------------------------------------------------------------------------------- 1 | const fetchOptions = { 2 | "mode": "cors", 3 | "method": "POST", 4 | "headers": { 5 | "content-type": "text/plain" 6 | }, 7 | "body": "Hello World" 8 | } 9 | 10 | fetch("http://mockbin.com/har", fetchOptions) 11 | .then(response => response.json()) 12 | .then(data => console.log(data)) 13 | .catch(error => console.log(error)); -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/application-form-encoded.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har", 5 | "method": "POST", 6 | "headers": { 7 | "content-type": "application/x-www-form-urlencoded" 8 | }, 9 | "data": { 10 | "foo": "bar", 11 | "hello": "world" 12 | } 13 | } 14 | 15 | $.ajax(settings).done(function (response) { 16 | console.log(response); 17 | }); 18 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/application-json.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har", 5 | "method": "POST", 6 | "headers": { 7 | "content-type": "application/json" 8 | }, 9 | "processData": false, 10 | "data": "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 11 | } 12 | 13 | $.ajax(settings).done(function (response) { 14 | console.log(response); 15 | }); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/cookies.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har", 5 | "method": "POST", 6 | "headers": { 7 | "Cookie": "foo=bar; bar=baz" 8 | } 9 | } 10 | 11 | $.ajax(settings).done(function (response) { 12 | console.log(response); 13 | }); 14 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/custom-method.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har", 5 | "method": "GET", 6 | "headers": { } 7 | } 8 | 9 | $.ajax(settings).done(function (response) { 10 | console.log(response); 11 | }); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/full.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value", 5 | "method": "POST", 6 | "headers": { 7 | "Cookie": "foo=bar; bar=baz", 8 | "content-type": "application/x-www-form-urlencoded", 9 | "accept": "application/json" 10 | }, 11 | "data": { 12 | "foo": "bar" 13 | } 14 | } 15 | 16 | $.ajax(settings).done(function (response) { 17 | console.log(response); 18 | }); 19 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/headers.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har", 5 | "method": "GET", 6 | "headers": { 7 | "x-foo": "Bar", 8 | "accept": "application/json" 9 | } 10 | } 11 | 12 | $.ajax(settings).done(function (response) { 13 | console.log(response); 14 | }); 15 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/https.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "https://mockbin.com/har", 5 | "method": "GET", 6 | "headers": { } 7 | } 8 | 9 | $.ajax(settings).done(function (response) { 10 | console.log(response); 11 | }); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/jsonObj-null-value.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har", 5 | "method": "POST", 6 | "headers": { 7 | "content-type": "application/json" 8 | }, 9 | "processData": false, 10 | "data": "{\"foo\":null}" 11 | } 12 | 13 | $.ajax(settings).done(function (response) { 14 | console.log(response); 15 | }); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/multipart-data.js: -------------------------------------------------------------------------------- 1 | var form = new FormData(); 2 | form.append("foo", "hello.txt"); 3 | 4 | var settings = { 5 | "async": true, 6 | "crossDomain": true, 7 | "url": "http://mockbin.com/har", 8 | "method": "POST", 9 | "headers": { 10 | "content-type": "multipart/form-data" 11 | }, 12 | "processData": false, 13 | "contentType": false, 14 | "mimeType": "multipart/form-data", 15 | "data": form 16 | } 17 | 18 | $.ajax(settings).done(function (response) { 19 | console.log(response); 20 | }); 21 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/multipart-file.js: -------------------------------------------------------------------------------- 1 | var form = new FormData(); 2 | form.append("foo", "test/fixtures/files/hello.txt"); 3 | 4 | var settings = { 5 | "async": true, 6 | "crossDomain": true, 7 | "url": "http://mockbin.com/har", 8 | "method": "POST", 9 | "headers": {}, 10 | "processData": false, 11 | "contentType": false, 12 | "mimeType": "multipart/form-data", 13 | "data": form 14 | } 15 | 16 | $.ajax(settings).done(function (response) { 17 | console.log(response); 18 | }); 19 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/multipart-form-data.js: -------------------------------------------------------------------------------- 1 | var form = new FormData(); 2 | form.append("foo", "bar"); 3 | 4 | var settings = { 5 | "async": true, 6 | "crossDomain": true, 7 | "url": "http://mockbin.com/har", 8 | "method": "POST", 9 | "headers": {}, 10 | "processData": false, 11 | "contentType": false, 12 | "mimeType": "multipart/form-data", 13 | "data": form 14 | } 15 | 16 | $.ajax(settings).done(function (response) { 17 | console.log(response); 18 | }); 19 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/query.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value", 5 | "method": "GET", 6 | "headers": { } 7 | } 8 | 9 | $.ajax(settings).done(function (response) { 10 | console.log(response); 11 | }); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/short.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har", 5 | "method": "GET", 6 | "headers": { } 7 | } 8 | 9 | $.ajax(settings).done(function (response) { 10 | console.log(response); 11 | }); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/jquery/text-plain.js: -------------------------------------------------------------------------------- 1 | var settings = { 2 | "async": true, 3 | "crossDomain": true, 4 | "url": "http://mockbin.com/har", 5 | "method": "POST", 6 | "headers": { 7 | "content-type": "text/plain" 8 | }, 9 | "data": "Hello World" 10 | } 11 | 12 | $.ajax(settings).done(function (response) { 13 | console.log(response); 14 | }); 15 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/application-form-encoded.js: -------------------------------------------------------------------------------- 1 | var data = "foo=bar&hello=world"; 2 | 3 | var xhr = new XMLHttpRequest(); 4 | xhr.withCredentials = true; 5 | 6 | xhr.addEventListener("readystatechange", function () { 7 | if (this.readyState === this.DONE) { 8 | console.log(this.responseText); 9 | } 10 | }); 11 | 12 | xhr.open("POST", "http://mockbin.com/har"); 13 | xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded"); 14 | 15 | xhr.send(data); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/cookies.js: -------------------------------------------------------------------------------- 1 | var data = null; 2 | 3 | var xhr = new XMLHttpRequest(); 4 | xhr.withCredentials = true; 5 | 6 | xhr.addEventListener("readystatechange", function () { 7 | if (this.readyState === this.DONE) { 8 | console.log(this.responseText); 9 | } 10 | }); 11 | 12 | xhr.open("POST", "http://mockbin.com/har"); 13 | xhr.setRequestHeader("Cookie", "foo=bar; bar=baz"); 14 | 15 | xhr.send(data); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/custom-method.js: -------------------------------------------------------------------------------- 1 | var data = null; 2 | 3 | var xhr = new XMLHttpRequest(); 4 | xhr.withCredentials = true; 5 | 6 | xhr.addEventListener("readystatechange", function () { 7 | if (this.readyState === this.DONE) { 8 | console.log(this.responseText); 9 | } 10 | }); 11 | 12 | xhr.open("GET", "http://mockbin.com/har"); 13 | 14 | xhr.send(data); 15 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/headers.js: -------------------------------------------------------------------------------- 1 | var data = null; 2 | 3 | var xhr = new XMLHttpRequest(); 4 | xhr.withCredentials = true; 5 | 6 | xhr.addEventListener("readystatechange", function () { 7 | if (this.readyState === this.DONE) { 8 | console.log(this.responseText); 9 | } 10 | }); 11 | 12 | xhr.open("GET", "http://mockbin.com/har"); 13 | xhr.setRequestHeader("x-foo", "Bar"); 14 | xhr.setRequestHeader("accept", "application/json"); 15 | 16 | xhr.send(data); 17 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/https.js: -------------------------------------------------------------------------------- 1 | var data = null; 2 | 3 | var xhr = new XMLHttpRequest(); 4 | xhr.withCredentials = true; 5 | 6 | xhr.addEventListener("readystatechange", function () { 7 | if (this.readyState === this.DONE) { 8 | console.log(this.responseText); 9 | } 10 | }); 11 | 12 | xhr.open("GET", "https://mockbin.com/har"); 13 | 14 | xhr.send(data); 15 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/jsonObj-null-value.js: -------------------------------------------------------------------------------- 1 | var data = JSON.stringify({ 2 | "foo": null 3 | }); 4 | 5 | var xhr = new XMLHttpRequest(); 6 | xhr.withCredentials = true; 7 | 8 | xhr.addEventListener("readystatechange", function () { 9 | if (this.readyState === this.DONE) { 10 | console.log(this.responseText); 11 | } 12 | }); 13 | 14 | xhr.open("POST", "http://mockbin.com/har"); 15 | xhr.setRequestHeader("content-type", "application/json"); 16 | 17 | xhr.send(data); 18 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/multipart-data.js: -------------------------------------------------------------------------------- 1 | var data = new FormData(); 2 | data.append("foo", "hello.txt"); 3 | 4 | var xhr = new XMLHttpRequest(); 5 | xhr.withCredentials = true; 6 | 7 | xhr.addEventListener("readystatechange", function () { 8 | if (this.readyState === this.DONE) { 9 | console.log(this.responseText); 10 | } 11 | }); 12 | 13 | xhr.open("POST", "http://mockbin.com/har"); 14 | xhr.setRequestHeader("content-type", "multipart/form-data"); 15 | 16 | xhr.send(data); 17 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/multipart-file.js: -------------------------------------------------------------------------------- 1 | var data = new FormData(); 2 | data.append("foo", "test/fixtures/files/hello.txt"); 3 | 4 | var xhr = new XMLHttpRequest(); 5 | xhr.withCredentials = true; 6 | 7 | xhr.addEventListener("readystatechange", function () { 8 | if (this.readyState === this.DONE) { 9 | console.log(this.responseText); 10 | } 11 | }); 12 | 13 | xhr.open("POST", "http://mockbin.com/har"); 14 | 15 | xhr.send(data); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/multipart-form-data.js: -------------------------------------------------------------------------------- 1 | var data = new FormData(); 2 | data.append("foo", "bar"); 3 | 4 | var xhr = new XMLHttpRequest(); 5 | xhr.withCredentials = true; 6 | 7 | xhr.addEventListener("readystatechange", function () { 8 | if (this.readyState === this.DONE) { 9 | console.log(this.responseText); 10 | } 11 | }); 12 | 13 | xhr.open("POST", "http://mockbin.com/har"); 14 | 15 | xhr.send(data); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/query.js: -------------------------------------------------------------------------------- 1 | var data = null; 2 | 3 | var xhr = new XMLHttpRequest(); 4 | xhr.withCredentials = true; 5 | 6 | xhr.addEventListener("readystatechange", function () { 7 | if (this.readyState === this.DONE) { 8 | console.log(this.responseText); 9 | } 10 | }); 11 | 12 | xhr.open("GET", "http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value"); 13 | 14 | xhr.send(data); 15 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/short.js: -------------------------------------------------------------------------------- 1 | var data = null; 2 | 3 | var xhr = new XMLHttpRequest(); 4 | xhr.withCredentials = true; 5 | 6 | xhr.addEventListener("readystatechange", function () { 7 | if (this.readyState === this.DONE) { 8 | console.log(this.responseText); 9 | } 10 | }); 11 | 12 | xhr.open("GET", "http://mockbin.com/har"); 13 | 14 | xhr.send(data); 15 | -------------------------------------------------------------------------------- /src/test/resources/output/javascript/xhr/text-plain.js: -------------------------------------------------------------------------------- 1 | var data = "Hello World"; 2 | 3 | var xhr = new XMLHttpRequest(); 4 | xhr.withCredentials = true; 5 | 6 | xhr.addEventListener("readystatechange", function () { 7 | if (this.readyState === this.DONE) { 8 | console.log(this.responseText); 9 | } 10 | }); 11 | 12 | xhr.open("POST", "http://mockbin.com/har"); 13 | xhr.setRequestHeader("content-type", "text/plain"); 14 | 15 | xhr.send(data); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/application-form-encoded.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val mediaType = MediaType.parse("application/x-www-form-urlencoded") 4 | val body = RequestBody.create(mediaType, "foo=bar&hello=world") 5 | val request = Request.Builder() 6 | .url("http://mockbin.com/har") 7 | .post(body) 8 | .addHeader("content-type", "application/x-www-form-urlencoded") 9 | .build() 10 | 11 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/application-json.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val mediaType = MediaType.parse("application/json") 4 | val body = RequestBody.create(mediaType, "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}") 5 | val request = Request.Builder() 6 | .url("http://mockbin.com/har") 7 | .post(body) 8 | .addHeader("content-type", "application/json") 9 | .build() 10 | 11 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/cookies.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val request = Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .post(null) 6 | .addHeader("cookie", "foo=bar; bar=baz") 7 | .build() 8 | 9 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/custom-method.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val request = Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .method("PROPFIND", null) 6 | .build() 7 | 8 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/full.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val mediaType = MediaType.parse("application/x-www-form-urlencoded") 4 | val body = RequestBody.create(mediaType, "foo=bar") 5 | val request = Request.Builder() 6 | .url("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") 7 | .post(body) 8 | .addHeader("cookie", "foo=bar; bar=baz") 9 | .addHeader("accept", "application/json") 10 | .addHeader("content-type", "application/x-www-form-urlencoded") 11 | .build() 12 | 13 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/headers.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val request = Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .get() 6 | .addHeader("accept", "application/json") 7 | .addHeader("x-foo", "Bar") 8 | .addHeader("quoted-value", "\"quoted\" 'string'") 9 | .build() 10 | 11 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/https.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val request = Request.Builder() 4 | .url("https://mockbin.com/har") 5 | .get() 6 | .build() 7 | 8 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/jsonObj-multiline.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val mediaType = MediaType.parse("application/json") 4 | val body = RequestBody.create(mediaType, "{\n \"foo\": \"bar\"\n}") 5 | val request = Request.Builder() 6 | .url("http://mockbin.com/har") 7 | .post(body) 8 | .addHeader("content-type", "application/json") 9 | .build() 10 | 11 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/jsonObj-null-value.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val mediaType = MediaType.parse("application/json") 4 | val body = RequestBody.create(mediaType, "{\"foo\":null}") 5 | val request = Request.Builder() 6 | .url("http://mockbin.com/har") 7 | .post(body) 8 | .addHeader("content-type", "application/json") 9 | .build() 10 | 11 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/multipart-form-data-no-params.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val request = Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .post(null) 6 | .addHeader("Content-Type", "multipart/form-data") 7 | .build() 8 | 9 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/nested.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val request = Request.Builder() 4 | .url("http://mockbin.com/har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value") 5 | .get() 6 | .build() 7 | 8 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/query.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val request = Request.Builder() 4 | .url("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") 5 | .get() 6 | .build() 7 | 8 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/short.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val request = Request.Builder() 4 | .url("http://mockbin.com/har") 5 | .get() 6 | .build() 7 | 8 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/kotlin/okhttp/text-plain.kt: -------------------------------------------------------------------------------- 1 | val client = OkHttpClient() 2 | 3 | val mediaType = MediaType.parse("text/plain") 4 | val body = RequestBody.create(mediaType, "Hello World") 5 | val request = Request.Builder() 6 | .url("http://mockbin.com/har") 7 | .post(body) 8 | .addHeader("content-type", "text/plain") 9 | .build() 10 | 11 | val response = client.newCall(request).execute() -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/cookies.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {cookie: 'foo=bar; bar=baz'} 7 | }; 8 | 9 | try { 10 | const { data } = await axios.request(options); 11 | console.log(data); 12 | } catch (error) { 13 | console.error(error); 14 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/custom-method.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = {method: 'PROPFIND', url: 'http://mockbin.com/har'}; 4 | 5 | try { 6 | const { data } = await axios.request(options); 7 | console.log(data); 8 | } catch (error) { 9 | console.error(error); 10 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/headers.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = { 4 | method: 'GET', 5 | url: 'http://mockbin.com/har', 6 | headers: { 7 | accept: 'application/json', 8 | 'x-foo': 'Bar', 9 | 'quoted-value': '"quoted" \'string\'' 10 | } 11 | }; 12 | 13 | try { 14 | const { data } = await axios.request(options); 15 | console.log(data); 16 | } catch (error) { 17 | console.error(error); 18 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/https.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = {method: 'GET', url: 'https://mockbin.com/har'}; 4 | 5 | try { 6 | const { data } = await axios.request(options); 7 | console.log(data); 8 | } catch (error) { 9 | console.error(error); 10 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/jsonObj-multiline.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {'content-type': 'application/json'}, 7 | data: {foo: 'bar'} 8 | }; 9 | 10 | try { 11 | const { data } = await axios.request(options); 12 | console.log(data); 13 | } catch (error) { 14 | console.error(error); 15 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/jsonObj-null-value.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {'content-type': 'application/json'}, 7 | data: {foo: null} 8 | }; 9 | 10 | try { 11 | const { data } = await axios.request(options); 12 | console.log(data); 13 | } catch (error) { 14 | console.error(error); 15 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/multipart-form-data-no-params.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {'Content-Type': 'multipart/form-data'} 7 | }; 8 | 9 | try { 10 | const { data } = await axios.request(options); 11 | console.log(data); 12 | } catch (error) { 13 | console.error(error); 14 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/nested.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = { 4 | method: 'GET', 5 | url: 'http://mockbin.com/har', 6 | params: {'foo[bar]': 'baz,zap', fiz: 'buz', key: 'value'} 7 | }; 8 | 9 | try { 10 | const { data } = await axios.request(options); 11 | console.log(data); 12 | } catch (error) { 13 | console.error(error); 14 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/query.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = { 4 | method: 'GET', 5 | url: 'http://mockbin.com/har', 6 | params: {foo: ['bar', 'baz'], baz: 'abc', key: 'value'} 7 | }; 8 | 9 | try { 10 | const { data } = await axios.request(options); 11 | console.log(data); 12 | } catch (error) { 13 | console.error(error); 14 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/short.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = {method: 'GET', url: 'http://mockbin.com/har'}; 4 | 5 | try { 6 | const { data } = await axios.request(options); 7 | console.log(data); 8 | } catch (error) { 9 | console.error(error); 10 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/axios/text-plain.js: -------------------------------------------------------------------------------- 1 | const axios = require('axios').default; 2 | 3 | const options = { 4 | method: 'POST', 5 | url: 'http://mockbin.com/har', 6 | headers: {'content-type': 'text/plain'}, 7 | data: 'Hello World' 8 | }; 9 | 10 | try { 11 | const { data } = await axios.request(options); 12 | console.log(data); 13 | } catch (error) { 14 | console.error(error); 15 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/application-json.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = { 5 | method: 'POST', 6 | headers: {'content-type': 'application/json'}, 7 | body: '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' 8 | }; 9 | 10 | try { 11 | const response = await fetch(url, options); 12 | const data = await response.json(); 13 | console.log(data); 14 | } catch (error) { 15 | console.error(error); 16 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/cookies.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = {method: 'POST', headers: {cookie: 'foo=bar; bar=baz'}}; 5 | 6 | try { 7 | const response = await fetch(url, options); 8 | const data = await response.json(); 9 | console.log(data); 10 | } catch (error) { 11 | console.error(error); 12 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/custom-method.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = {method: 'PROPFIND'}; 5 | 6 | try { 7 | const response = await fetch(url, options); 8 | const data = await response.json(); 9 | console.log(data); 10 | } catch (error) { 11 | console.error(error); 12 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/headers.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = { 5 | method: 'GET', 6 | headers: { 7 | accept: 'application/json', 8 | 'x-foo': 'Bar', 9 | 'quoted-value': '"quoted" \'string\'' 10 | } 11 | }; 12 | 13 | try { 14 | const response = await fetch(url, options); 15 | const data = await response.json(); 16 | console.log(data); 17 | } catch (error) { 18 | console.error(error); 19 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/https.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'https://mockbin.com/har'; 4 | const options = {method: 'GET'}; 5 | 6 | try { 7 | const response = await fetch(url, options); 8 | const data = await response.json(); 9 | console.log(data); 10 | } catch (error) { 11 | console.error(error); 12 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/jsonObj-multiline.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = { 5 | method: 'POST', 6 | headers: {'content-type': 'application/json'}, 7 | body: '{"foo":"bar"}' 8 | }; 9 | 10 | try { 11 | const response = await fetch(url, options); 12 | const data = await response.json(); 13 | console.log(data); 14 | } catch (error) { 15 | console.error(error); 16 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/jsonObj-null-value.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = { 5 | method: 'POST', 6 | headers: {'content-type': 'application/json'}, 7 | body: '{"foo":null}' 8 | }; 9 | 10 | try { 11 | const response = await fetch(url, options); 12 | const data = await response.json(); 13 | console.log(data); 14 | } catch (error) { 15 | console.error(error); 16 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/multipart-form-data-no-params.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = {method: 'POST', headers: {'Content-Type': 'multipart/form-data'}}; 5 | 6 | try { 7 | const response = await fetch(url, options); 8 | const data = await response.json(); 9 | console.log(data); 10 | } catch (error) { 11 | console.error(error); 12 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/multipart-form-data.js: -------------------------------------------------------------------------------- 1 | const FormData = require('form-data'); 2 | const fetch = require('node-fetch'); 3 | 4 | const formData = new FormData(); 5 | formData.append('foo', 'bar'); 6 | 7 | const url = 'http://mockbin.com/har'; 8 | const options = {method: 'POST'}; 9 | options.body = formData; 10 | 11 | try { 12 | const response = await fetch(url, options); 13 | const data = await response.json(); 14 | console.log(data); 15 | } catch (error) { 16 | console.error(error); 17 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/nested.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value'; 4 | const options = {method: 'GET'}; 5 | 6 | try { 7 | const response = await fetch(url, options); 8 | const data = await response.json(); 9 | console.log(data); 10 | } catch (error) { 11 | console.error(error); 12 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/query.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value'; 4 | const options = {method: 'GET'}; 5 | 6 | try { 7 | const response = await fetch(url, options); 8 | const data = await response.json(); 9 | console.log(data); 10 | } catch (error) { 11 | console.error(error); 12 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/short.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = {method: 'GET'}; 5 | 6 | try { 7 | const response = await fetch(url, options); 8 | const data = await response.json(); 9 | console.log(data); 10 | } catch (error) { 11 | console.error(error); 12 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/fetch/text-plain.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | const url = 'http://mockbin.com/har'; 4 | const options = {method: 'POST', headers: {'content-type': 'text/plain'}, body: 'Hello World'}; 5 | 6 | try { 7 | const response = await fetch(url, options); 8 | const data = await response.json(); 9 | console.log(data); 10 | } catch (error) { 11 | console.error(error); 12 | } -------------------------------------------------------------------------------- /src/test/resources/output/node/native/custom-method.js: -------------------------------------------------------------------------------- 1 | var http = require("http"); 2 | 3 | var options = { 4 | "method": "GET", 5 | "hostname": "mockbin.com", 6 | "port": 80, 7 | "path": "/har", 8 | "headers": { } 9 | }; 10 | 11 | var req = http.request(options, function (res) { 12 | var chunks = []; 13 | 14 | res.on("data", function (chunk) { 15 | chunks.push(chunk); 16 | }); 17 | 18 | res.on("end", function () { 19 | var body = Buffer.concat(chunks); 20 | console.log(body.toString()); 21 | }); 22 | }); 23 | 24 | req.end(); 25 | -------------------------------------------------------------------------------- /src/test/resources/output/node/native/https.js: -------------------------------------------------------------------------------- 1 | var http = require("https"); 2 | 3 | var options = { 4 | "method": "GET", 5 | "hostname": "mockbin.com", 6 | "port": 443, 7 | "path": "/har", 8 | "headers": { } 9 | }; 10 | 11 | var req = http.request(options, function (res) { 12 | var chunks = []; 13 | 14 | res.on("data", function (chunk) { 15 | chunks.push(chunk); 16 | }); 17 | 18 | res.on("end", function () { 19 | var body = Buffer.concat(chunks); 20 | console.log(body.toString()); 21 | }); 22 | }); 23 | 24 | req.end(); 25 | -------------------------------------------------------------------------------- /src/test/resources/output/node/native/short.js: -------------------------------------------------------------------------------- 1 | var http = require("http"); 2 | 3 | var options = { 4 | "method": "GET", 5 | "hostname": "mockbin.com", 6 | "port": 80, 7 | "path": "/har", 8 | "headers": { } 9 | }; 10 | 11 | var req = http.request(options, function (res) { 12 | var chunks = []; 13 | 14 | res.on("data", function (chunk) { 15 | chunks.push(chunk); 16 | }); 17 | 18 | res.on("end", function () { 19 | var body = Buffer.concat(chunks); 20 | console.log(body.toString()); 21 | }); 22 | }); 23 | 24 | req.end(); 25 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/application-form-encoded.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { 4 | "method": "POST", 5 | "url": "http://mockbin.com/har", 6 | "headers": { 7 | "content-type": "application/x-www-form-urlencoded" 8 | }, 9 | "form": { 10 | "foo": "bar", 11 | "hello": "world" 12 | } 13 | }; 14 | 15 | request(options, function (error, response, body) { 16 | if (error) throw new Error(error); 17 | 18 | console.log(body); 19 | }); 20 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/cookies.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var jar = request.jar(); 4 | jar.setCookie(request.cookie("foo=bar"), "http://mockbin.com/har"); 5 | jar.setCookie(request.cookie("bar=baz"), "http://mockbin.com/har"); 6 | 7 | var options = { 8 | "method": "POST", 9 | "url": "http://mockbin.com/har", 10 | "jar": jar 11 | }; 12 | 13 | request(options, function (error, response, body) { 14 | if (error) throw new Error(error); 15 | 16 | console.log(body); 17 | }); 18 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/custom-method.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { 4 | "method": "GET", 5 | "url": "http://mockbin.com/har" 6 | }; 7 | 8 | request(options, function (error, response, body) { 9 | if (error) throw new Error(error); 10 | 11 | console.log(body); 12 | }); 13 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/headers.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { 4 | "method": "GET", 5 | "url": "http://mockbin.com/har", 6 | "headers": { 7 | "x-foo": "Bar", 8 | "accept": "application/json" 9 | } 10 | }; 11 | 12 | request(options, function (error, response, body) { 13 | if (error) throw new Error(error); 14 | 15 | console.log(body); 16 | }); 17 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/https.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { 4 | "method": "GET", 5 | "url": "https://mockbin.com/har" 6 | }; 7 | 8 | request(options, function (error, response, body) { 9 | if (error) throw new Error(error); 10 | 11 | console.log(body); 12 | }); 13 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/jsonObj-null-value.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { 4 | "method": "POST", 5 | "url": "http://mockbin.com/har", 6 | "headers": { 7 | "content-type": "application/json" 8 | }, 9 | "body": { 10 | "foo": null 11 | }, 12 | "json": true 13 | }; 14 | 15 | request(options, function (error, response, body) { 16 | if (error) throw new Error(error); 17 | 18 | console.log(body); 19 | }); 20 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/multipart-form-data.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { method: 'POST', 4 | url: 'http://mockbin.com/har', 5 | headers: { 'content-type': 'multipart/form-data; boundary=---011000010111000001101001' }, 6 | formData: { foo: 'bar' } }; 7 | 8 | request(options, function (error, response, body) { 9 | if (error) throw new Error(error); 10 | 11 | console.log(body); 12 | }); 13 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/query.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { 4 | "method": "GET", 5 | "url": "http://mockbin.com/har", 6 | "qs": { 7 | "foo": [ 8 | "bar", 9 | "baz" 10 | ], 11 | "baz": "abc", 12 | "key": "value" 13 | } 14 | }; 15 | 16 | request(options, function (error, response, body) { 17 | if (error) throw new Error(error); 18 | 19 | console.log(body); 20 | }); 21 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/short.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { 4 | "method": "GET", 5 | "url": "http://mockbin.com/har" 6 | }; 7 | 8 | request(options, function (error, response, body) { 9 | if (error) throw new Error(error); 10 | 11 | console.log(body); 12 | }); 13 | -------------------------------------------------------------------------------- /src/test/resources/output/node/request/text-plain.js: -------------------------------------------------------------------------------- 1 | var request = require("request"); 2 | 3 | var options = { 4 | "method": "POST", 5 | "url": "http://mockbin.com/har", 6 | "headers": { 7 | "content-type": "text/plain" 8 | }, 9 | "body": "Hello World" 10 | }; 11 | 12 | request(options, function (error, response, body) { 13 | if (error) throw new Error(error); 14 | 15 | console.log(body); 16 | }); 17 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/application-form-encoded.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("POST", "http://mockbin.com/har"); 4 | 5 | req.headers({ 6 | "content-type": "application/x-www-form-urlencoded" 7 | }); 8 | 9 | req.form({ 10 | "foo": "bar", 11 | "hello": "world" 12 | }); 13 | 14 | req.end(function (res) { 15 | if (res.error) throw new Error(res.error); 16 | 17 | console.log(res.body); 18 | }); 19 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/cookies.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("POST", "http://mockbin.com/har"); 4 | 5 | var CookieJar = unirest.jar(); 6 | CookieJar.add("foo=bar","http://mockbin.com/har"); 7 | CookieJar.add("bar=baz","http://mockbin.com/har"); 8 | req.jar(CookieJar); 9 | 10 | 11 | req.end(function (res) { 12 | if (res.error) throw new Error(res.error); 13 | 14 | console.log(res.body); 15 | }); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/custom-method.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("GET", "http://mockbin.com/har"); 4 | 5 | 6 | req.end(function (res) { 7 | if (res.error) throw new Error(res.error); 8 | 9 | console.log(res.body); 10 | }); 11 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/headers.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("GET", "http://mockbin.com/har"); 4 | 5 | req.headers({ 6 | "x-foo": "Bar", 7 | "accept": "application/json" 8 | }); 9 | 10 | 11 | req.end(function (res) { 12 | if (res.error) throw new Error(res.error); 13 | 14 | console.log(res.body); 15 | }); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/https.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("GET", "https://mockbin.com/har"); 4 | 5 | 6 | req.end(function (res) { 7 | if (res.error) throw new Error(res.error); 8 | 9 | console.log(res.body); 10 | }); 11 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/jsonObj-null-value.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("POST", "http://mockbin.com/har"); 4 | 5 | req.headers({ 6 | "content-type": "application/json" 7 | }); 8 | 9 | req.type("json"); 10 | req.send({ 11 | "foo": null 12 | }); 13 | 14 | req.end(function (res) { 15 | if (res.error) throw new Error(res.error); 16 | 17 | console.log(res.body); 18 | }); 19 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/multipart-data.js: -------------------------------------------------------------------------------- 1 | var fs = require("fs"); 2 | var unirest = require("unirest"); 3 | 4 | var req = unirest("POST", "http://mockbin.com/har"); 5 | 6 | req.headers({ 7 | "content-type": "multipart/form-data" 8 | }); 9 | 10 | req.multipart([ 11 | { 12 | "content-type": "text/plain", 13 | "body": fs.createReadStream("hello.txt") 14 | } 15 | ]); 16 | 17 | req.end(function (res) { 18 | if (res.error) throw new Error(res.error); 19 | 20 | console.log(res.body); 21 | }); 22 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/multipart-form-data.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("POST", "http://mockbin.com/har"); 4 | 5 | req.headers({ 6 | "content-type": "multipart/form-data; boundary=---011000010111000001101001" 7 | }); 8 | 9 | req.multipart([ 10 | { 11 | "body": "bar" 12 | } 13 | ]); 14 | 15 | req.end(function (res) { 16 | if (res.error) throw new Error(res.error); 17 | 18 | console.log(res.body); 19 | }); 20 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/query.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("GET", "http://mockbin.com/har"); 4 | 5 | req.query({ 6 | "foo": [ 7 | "bar", 8 | "baz" 9 | ], 10 | "baz": "abc", 11 | "key": "value" 12 | }); 13 | 14 | 15 | req.end(function (res) { 16 | if (res.error) throw new Error(res.error); 17 | 18 | console.log(res.body); 19 | }); 20 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/short.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("GET", "http://mockbin.com/har"); 4 | 5 | 6 | req.end(function (res) { 7 | if (res.error) throw new Error(res.error); 8 | 9 | console.log(res.body); 10 | }); 11 | -------------------------------------------------------------------------------- /src/test/resources/output/node/unirest/text-plain.js: -------------------------------------------------------------------------------- 1 | var unirest = require("unirest"); 2 | 3 | var req = unirest("POST", "http://mockbin.com/har"); 4 | 5 | req.headers({ 6 | "content-type": "text/plain" 7 | }); 8 | 9 | req.send("Hello World"); 10 | 11 | req.end(function (res) { 12 | if (res.error) throw new Error(res.error); 13 | 14 | console.log(res.body); 15 | }); 16 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/application-form-encoded.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har" in 6 | let headers = Header.add (Header.init ()) "content-type" "application/x-www-form-urlencoded" in 7 | let body = Cohttp_lwt_body.of_string "foo=bar&hello=world" in 8 | 9 | Client.call ~headers ~body `POST uri 10 | >>= fun (res, body_stream) -> 11 | (* Do stuff with the result *) 12 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/application-json.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har" in 6 | let headers = Header.add (Header.init ()) "content-type" "application/json" in 7 | let body = Cohttp_lwt_body.of_string "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" in 8 | 9 | Client.call ~headers ~body `POST uri 10 | >>= fun (res, body_stream) -> 11 | (* Do stuff with the result *) 12 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/cookies.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har" in 6 | let headers = Header.add (Header.init ()) "cookie" "foo=bar; bar=baz" in 7 | 8 | Client.call ~headers `POST uri 9 | >>= fun (res, body_stream) -> 10 | (* Do stuff with the result *) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/custom-method.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har" in 6 | 7 | Client.call (Code.method_of_string "PROPFIND") uri 8 | >>= fun (res, body_stream) -> 9 | (* Do stuff with the result *) 10 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/full.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value" in 6 | let headers = Header.add_list (Header.init ()) [ 7 | ("cookie", "foo=bar; bar=baz"); 8 | ("accept", "application/json"); 9 | ("content-type", "application/x-www-form-urlencoded"); 10 | ] in 11 | let body = Cohttp_lwt_body.of_string "foo=bar" in 12 | 13 | Client.call ~headers ~body `POST uri 14 | >>= fun (res, body_stream) -> 15 | (* Do stuff with the result *) 16 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/headers.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har" in 6 | let headers = Header.add_list (Header.init ()) [ 7 | ("accept", "application/json"); 8 | ("x-foo", "Bar"); 9 | ] in 10 | 11 | Client.call ~headers `GET uri 12 | >>= fun (res, body_stream) -> 13 | (* Do stuff with the result *) 14 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/https.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "https://mockbin.com/har" in 6 | 7 | Client.call `GET uri 8 | >>= fun (res, body_stream) -> 9 | (* Do stuff with the result *) 10 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/jsonObj-null-value.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har" in 6 | let headers = Header.add (Header.init ()) "content-type" "application/json" in 7 | let body = Cohttp_lwt_body.of_string "{\"foo\":null}" in 8 | 9 | Client.call ~headers ~body `POST uri 10 | >>= fun (res, body_stream) -> 11 | (* Do stuff with the result *) 12 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/query.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value" in 6 | 7 | Client.call `GET uri 8 | >>= fun (res, body_stream) -> 9 | (* Do stuff with the result *) 10 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/short.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har" in 6 | 7 | Client.call `GET uri 8 | >>= fun (res, body_stream) -> 9 | (* Do stuff with the result *) 10 | -------------------------------------------------------------------------------- /src/test/resources/output/ocaml/cohttp/text-plain.ml: -------------------------------------------------------------------------------- 1 | open Cohttp_lwt_unix 2 | open Cohttp 3 | open Lwt 4 | 5 | let uri = Uri.of_string "http://mockbin.com/har" in 6 | let headers = Header.add (Header.init ()) "content-type" "text/plain" in 7 | let body = Cohttp_lwt_body.of_string "Hello World" in 8 | 9 | Client.call ~headers ~body `POST uri 10 | >>= fun (res, body_stream) -> 11 | (* Do stuff with the result *) 12 | -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/application-form-encoded.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'form_params' => [ 7 | 'foo' => 'bar', 8 | 'hello' => 'world' 9 | ], 10 | 'headers' => [ 11 | 'content-type' => 'application/x-www-form-urlencoded', 12 | ], 13 | ]); 14 | 15 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/application-json.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'body' => '{"number":1,"string":"f\\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}', 7 | 'headers' => [ 8 | 'content-type' => 'application/json', 9 | ], 10 | ]); 11 | 12 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/cookies.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'headers' => [ 7 | 'cookie' => 'foo=bar; bar=baz', 8 | ], 9 | ]); 10 | 11 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/custom-method.php: -------------------------------------------------------------------------------- 1 | request('PROPFIND', 'http://mockbin.com/har'); 6 | 7 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/full.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value', [ 6 | 'form_params' => [ 7 | 'foo' => 'bar' 8 | ], 9 | 'headers' => [ 10 | 'accept' => 'application/json', 11 | 'content-type' => 'application/x-www-form-urlencoded', 12 | 'cookie' => 'foo=bar; bar=baz', 13 | ], 14 | ]); 15 | 16 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/headers.php: -------------------------------------------------------------------------------- 1 | request('GET', 'http://mockbin.com/har', [ 6 | 'headers' => [ 7 | 'accept' => 'application/json', 8 | 'quoted-value' => '"quoted" \'string\'', 9 | 'x-foo' => 'Bar', 10 | ], 11 | ]); 12 | 13 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/https.php: -------------------------------------------------------------------------------- 1 | request('GET', 'https://mockbin.com/har'); 6 | 7 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/jsonObj-multiline.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'body' => '{ 7 | "foo": "bar" 8 | }', 9 | 'headers' => [ 10 | 'content-type' => 'application/json', 11 | ], 12 | ]); 13 | 14 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/jsonObj-null-value.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'body' => '{"foo":null}', 7 | 'headers' => [ 8 | 'content-type' => 'application/json', 9 | ], 10 | ]); 11 | 12 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/multipart-file.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'multipart' => [ 7 | [ 8 | 'name' => 'foo', 9 | 'filename' => 'test/fixtures/files/hello.txt', 10 | 'contents' => null, 11 | 'headers' => [ 12 | 'Content-Type' => 'text/plain' 13 | ] 14 | ] 15 | ] 16 | ]); 17 | 18 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/multipart-form-data-no-params.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'headers' => [ 7 | 'Content-Type' => 'multipart/form-data', 8 | ], 9 | ]); 10 | 11 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/multipart-form-data.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'multipart' => [ 7 | [ 8 | 'name' => 'foo', 9 | 'contents' => 'bar' 10 | ] 11 | ] 12 | ]); 13 | 14 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/nested.php: -------------------------------------------------------------------------------- 1 | request('GET', 'http://mockbin.com/har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value'); 6 | 7 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/query.php: -------------------------------------------------------------------------------- 1 | request('GET', 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value'); 6 | 7 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/short.php: -------------------------------------------------------------------------------- 1 | request('GET', 'http://mockbin.com/har'); 6 | 7 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/guzzle/text-plain.php: -------------------------------------------------------------------------------- 1 | request('POST', 'http://mockbin.com/har', [ 6 | 'body' => 'Hello World', 7 | 'headers' => [ 8 | 'content-type' => 'text/plain', 9 | ], 10 | ]); 11 | 12 | echo $response->getBody(); -------------------------------------------------------------------------------- /src/test/resources/output/php/http1/cookies.php: -------------------------------------------------------------------------------- 1 | setUrl('http://mockbin.com/har'); 5 | $request->setMethod(HTTP_METH_POST); 6 | 7 | $request->setCookies(array( 8 | 'bar' => 'baz', 9 | 'foo' => 'bar' 10 | )); 11 | 12 | try { 13 | $response = $request->send(); 14 | 15 | echo $response->getBody(); 16 | } catch (HttpException $ex) { 17 | echo $ex; 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http1/custom-method.php: -------------------------------------------------------------------------------- 1 | setUrl('http://mockbin.com/har'); 5 | $request->setMethod(HTTP_METH_PROPFIND); 6 | 7 | try { 8 | $response = $request->send(); 9 | 10 | echo $response->getBody(); 11 | } catch (HttpException $ex) { 12 | echo $ex; 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http1/headers.php: -------------------------------------------------------------------------------- 1 | setUrl('http://mockbin.com/har'); 5 | $request->setMethod(HTTP_METH_GET); 6 | 7 | $request->setHeaders(array( 8 | 'x-foo' => 'Bar', 9 | 'accept' => 'application/json' 10 | )); 11 | 12 | try { 13 | $response = $request->send(); 14 | 15 | echo $response->getBody(); 16 | } catch (HttpException $ex) { 17 | echo $ex; 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http1/https.php: -------------------------------------------------------------------------------- 1 | setUrl('https://mockbin.com/har'); 5 | $request->setMethod(HTTP_METH_GET); 6 | 7 | try { 8 | $response = $request->send(); 9 | 10 | echo $response->getBody(); 11 | } catch (HttpException $ex) { 12 | echo $ex; 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http1/jsonObj-null-value.php: -------------------------------------------------------------------------------- 1 | setUrl('http://mockbin.com/har'); 5 | $request->setMethod(HTTP_METH_POST); 6 | 7 | $request->setHeaders(array( 8 | 'content-type' => 'application/json' 9 | )); 10 | 11 | $request->setBody('{"foo":null}'); 12 | 13 | try { 14 | $response = $request->send(); 15 | 16 | echo $response->getBody(); 17 | } catch (HttpException $ex) { 18 | echo $ex; 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http1/query.php: -------------------------------------------------------------------------------- 1 | setUrl('http://mockbin.com/har'); 5 | $request->setMethod(HTTP_METH_GET); 6 | 7 | $request->setQueryData(array( 8 | 'foo' => array( 9 | 'bar', 10 | 'baz' 11 | ), 12 | 'baz' => 'abc', 13 | 'key' => 'value' 14 | )); 15 | 16 | try { 17 | $response = $request->send(); 18 | 19 | echo $response->getBody(); 20 | } catch (HttpException $ex) { 21 | echo $ex; 22 | } 23 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http1/short.php: -------------------------------------------------------------------------------- 1 | setUrl('http://mockbin.com/har'); 5 | $request->setMethod(HTTP_METH_GET); 6 | 7 | try { 8 | $response = $request->send(); 9 | 10 | echo $response->getBody(); 11 | } catch (HttpException $ex) { 12 | echo $ex; 13 | } 14 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http1/text-plain.php: -------------------------------------------------------------------------------- 1 | setUrl('http://mockbin.com/har'); 5 | $request->setMethod(HTTP_METH_POST); 6 | 7 | $request->setHeaders(array( 8 | 'content-type' => 'text/plain' 9 | )); 10 | 11 | $request->setBody('Hello World'); 12 | 13 | try { 14 | $response = $request->send(); 15 | 16 | echo $response->getBody(); 17 | } catch (HttpException $ex) { 18 | echo $ex; 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/cookies.php: -------------------------------------------------------------------------------- 1 | setRequestUrl('http://mockbin.com/har'); 7 | $request->setRequestMethod('POST'); 8 | 9 | $client->setCookies(array( 10 | 'bar' => 'baz', 11 | 'foo' => 'bar' 12 | )); 13 | 14 | $client->enqueue($request)->send(); 15 | $response = $client->getResponse(); 16 | 17 | echo $response->getBody(); 18 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/custom-method.php: -------------------------------------------------------------------------------- 1 | setRequestUrl('http://mockbin.com/har'); 7 | $request->setRequestMethod('PROPFIND'); 8 | $client->enqueue($request)->send(); 9 | $response = $client->getResponse(); 10 | 11 | echo $response->getBody(); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/headers.php: -------------------------------------------------------------------------------- 1 | setRequestUrl('http://mockbin.com/har'); 7 | $request->setRequestMethod('GET'); 8 | $request->setHeaders(array( 9 | 'x-foo' => 'Bar', 10 | 'accept' => 'application/json' 11 | )); 12 | 13 | $client->enqueue($request)->send(); 14 | $response = $client->getResponse(); 15 | 16 | echo $response->getBody(); 17 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/https.php: -------------------------------------------------------------------------------- 1 | setRequestUrl('https://mockbin.com/har'); 7 | $request->setRequestMethod('GET'); 8 | $client->enqueue($request)->send(); 9 | $response = $client->getResponse(); 10 | 11 | echo $response->getBody(); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/jsonObj-null-value.php: -------------------------------------------------------------------------------- 1 | append('{"foo":null}'); 8 | 9 | $request->setRequestUrl('http://mockbin.com/har'); 10 | $request->setRequestMethod('POST'); 11 | $request->setBody($body); 12 | 13 | $request->setHeaders(array( 14 | 'content-type' => 'application/json' 15 | )); 16 | 17 | $client->enqueue($request)->send(); 18 | $response = $client->getResponse(); 19 | 20 | echo $response->getBody(); 21 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/multipart-form-data.php: -------------------------------------------------------------------------------- 1 | addForm(array( 8 | 'foo' => 'bar' 9 | ), NULL); 10 | 11 | $request->setRequestUrl('http://mockbin.com/har'); 12 | $request->setRequestMethod('POST'); 13 | $request->setBody($body); 14 | 15 | $client->enqueue($request)->send(); 16 | $response = $client->getResponse(); 17 | 18 | echo $response->getBody(); 19 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/query.php: -------------------------------------------------------------------------------- 1 | setRequestUrl('http://mockbin.com/har'); 7 | $request->setRequestMethod('GET'); 8 | $request->setQuery(new http\QueryString(array( 9 | 'foo' => array( 10 | 'bar', 11 | 'baz' 12 | ), 13 | 'baz' => 'abc', 14 | 'key' => 'value' 15 | ))); 16 | 17 | $client->enqueue($request)->send(); 18 | $response = $client->getResponse(); 19 | 20 | echo $response->getBody(); 21 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/short.php: -------------------------------------------------------------------------------- 1 | setRequestUrl('http://mockbin.com/har'); 7 | $request->setRequestMethod('GET'); 8 | $client->enqueue($request)->send(); 9 | $response = $client->getResponse(); 10 | 11 | echo $response->getBody(); 12 | -------------------------------------------------------------------------------- /src/test/resources/output/php/http2/text-plain.php: -------------------------------------------------------------------------------- 1 | append('Hello World'); 8 | 9 | $request->setRequestUrl('http://mockbin.com/har'); 10 | $request->setRequestMethod('POST'); 11 | $request->setBody($body); 12 | 13 | $request->setHeaders(array( 14 | 'content-type' => 'text/plain' 15 | )); 16 | 17 | $client->enqueue($request)->send(); 18 | $response = $client->getResponse(); 19 | 20 | echo $response->getBody(); 21 | -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/application-form-encoded.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "application/x-www-form-urlencoded") 3 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'application/x-www-form-urlencoded' -Body 'foo=bar&hello=world' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/application-json.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "application/json") 3 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/cookies.ps1: -------------------------------------------------------------------------------- 1 | $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession 2 | $cookie = New-Object System.Net.Cookie 3 | $cookie.Name = 'foo' 4 | $cookie.Value = 'bar' 5 | $cookie.Domain = 'mockbin.com' 6 | $session.Cookies.Add($cookie) 7 | $cookie = New-Object System.Net.Cookie 8 | $cookie.Name = 'bar' 9 | $cookie.Value = 'baz' 10 | $cookie.Domain = 'mockbin.com' 11 | $session.Cookies.Add($cookie) 12 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -WebSession $session -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/custom-method.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -CustomMethod PROPFIND -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/headers.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("accept", "application/json") 3 | $headers.Add("x-foo", "Bar") 4 | $headers.Add("quoted-value", "`"quoted`" 'string'") 5 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method GET -Headers $headers -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/https.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-RestMethod -Uri 'https://mockbin.com/har' -Method GET -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/jsonObj-multiline.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "application/json") 3 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'application/json' -Body '{ 4 | "foo": "bar" 5 | }' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/jsonObj-null-value.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "application/json") 3 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"foo":null}' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/multipart-file.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001") 3 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001 4 | Content-Disposition: form-data; name="foo"; filename="hello.txt" 5 | Content-Type: text/plain 6 | 7 | 8 | -----011000010111000001101001-- 9 | ' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/multipart-form-data-no-params.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("Content-Type", "multipart/form-data") 3 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/multipart-form-data.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") 3 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'multipart/form-data; boundary=---011000010111000001101001' -Body '-----011000010111000001101001 4 | Content-Disposition: form-data; name="foo" 5 | 6 | bar 7 | -----011000010111000001101001-- 8 | ' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/nested.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har?foo%5Bbar%5D=baz%2Czap&fiz=buz&key=value' -Method GET -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/query.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' -Method GET -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/short.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method GET -------------------------------------------------------------------------------- /src/test/resources/output/powershell/restmethod/text-plain.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "text/plain") 3 | $response = Invoke-RestMethod -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'text/plain' -Body 'Hello World' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/application-form-encoded.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "application/x-www-form-urlencoded") 3 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/application-json.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "application/json") 3 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/cookies.ps1: -------------------------------------------------------------------------------- 1 | $session = New-Object Microsoft.PowerShell.Commands.WebRequestSession 2 | $cookie = New-Object System.Net.Cookie 3 | $cookie.Name = 'foo' 4 | $cookie.Value = 'bar' 5 | $cookie.Domain = 'null' 6 | $session.Cookies.Add($cookie) 7 | $cookie = New-Object System.Net.Cookie 8 | $cookie.Name = 'bar' 9 | $cookie.Value = 'baz' 10 | $cookie.Domain = 'null' 11 | $session.Cookies.Add($cookie) 12 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method POST -WebSession $session -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/custom-method.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method GET -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/headers.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("accept", "application/json") 3 | $headers.Add("x-foo", "Bar") 4 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method GET -Headers $headers -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/https.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-WebRequest -Uri 'https://mockbin.com/har' -Method GET -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/jsonObj-null-value.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "application/json") 3 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'application/json' -Body '{"foo":null}' -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/multipart-data.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "multipart/form-data") 3 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/multipart-file.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "multipart/form-data") 3 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/multipart-form-data.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "multipart/form-data") 3 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/query.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value' -Method GET -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/short.ps1: -------------------------------------------------------------------------------- 1 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method GET -------------------------------------------------------------------------------- /src/test/resources/output/powershell/webrequest/text-plain.ps1: -------------------------------------------------------------------------------- 1 | $headers=@{} 2 | $headers.Add("content-type", "text/plain") 3 | $response = Invoke-WebRequest -Uri 'http://mockbin.com/har' -Method POST -Headers $headers -ContentType 'text/plain' -Body 'Hello World' -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/application-form-encoded.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | payload = "foo=bar&hello=world" 6 | 7 | headers = {"content-type":"application/x-www-form-urlencoded"} 8 | 9 | conn.request("POST", "/har", payload, headers) 10 | 11 | res = conn.getresponse() 12 | data = res.read() 13 | 14 | print(data.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/application-json.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | payload = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 6 | 7 | headers = {"content-type":"application/json"} 8 | 9 | conn.request("POST", "/har", payload, headers) 10 | 11 | res = conn.getresponse() 12 | data = res.read() 13 | 14 | print(data.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/cookies.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | headers = {"Cookie":"foo=bar; bar=baz"} 6 | 7 | conn.request("POST", "/har", headers=headers) 8 | 9 | res = conn.getresponse() 10 | data = res.read() 11 | 12 | print(data.decode("utf-8")) 13 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/custom-method.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | conn.request("GET", "/har") 6 | 7 | res = conn.getresponse() 8 | data = res.read() 9 | 10 | print(data.decode("utf-8")) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/full.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | payload = "foo=bar" 6 | 7 | headers = {"Cookie":"foo=bar; bar=baz","content-type":"application/x-www-form-urlencoded","accept":"application/json"} 8 | 9 | conn.request("POST", "/har?baz=abc&foo=bar&foo=baz&key=value", payload, headers) 10 | 11 | res = conn.getresponse() 12 | data = res.read() 13 | 14 | print(data.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/headers.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | headers = {"x-foo":"Bar","accept":"application/json"} 6 | 7 | conn.request("GET", "/har", headers=headers) 8 | 9 | res = conn.getresponse() 10 | data = res.read() 11 | 12 | print(data.decode("utf-8")) 13 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/https.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPSConnection("mockbin.com") 4 | 5 | conn.request("GET", "/har") 6 | 7 | res = conn.getresponse() 8 | data = res.read() 9 | 10 | print(data.decode("utf-8")) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/jsonObj-null-value.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | payload = "{\"foo\":null}" 6 | 7 | headers = {"content-type":"application/json"} 8 | 9 | conn.request("POST", "/har", payload, headers) 10 | 11 | res = conn.getresponse() 12 | data = res.read() 13 | 14 | print(data.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/multipart-form-data.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" 6 | 7 | headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" } 8 | 9 | conn.request("POST", "/har", payload, headers) 10 | 11 | res = conn.getresponse() 12 | data = res.read() 13 | 14 | print(data.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/query.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | conn.request("GET", "/har?baz=abc&foo=bar&foo=baz&key=value") 6 | 7 | res = conn.getresponse() 8 | data = res.read() 9 | 10 | print(data.decode("utf-8")) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/short.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | conn.request("GET", "/har") 6 | 7 | res = conn.getresponse() 8 | data = res.read() 9 | 10 | print(data.decode("utf-8")) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/python3/text-plain.py: -------------------------------------------------------------------------------- 1 | import http.client 2 | 3 | conn = http.client.HTTPConnection("mockbin.com") 4 | 5 | payload = "Hello World" 6 | 7 | headers = {"content-type":"text/plain"} 8 | 9 | conn.request("POST", "/har", payload, headers) 10 | 11 | res = conn.getresponse() 12 | data = res.read() 13 | 14 | print(data.decode("utf-8")) 15 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/application-form-encoded.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | payload = "foo=bar&hello=world" 6 | headers = {"content-type":"application/x-www-form-urlencoded"} 7 | 8 | response = requests.request("POST", url, data=payload, headers=headers) 9 | 10 | print(response.text) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/application-json.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | payload = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 6 | headers = {"content-type":"application/json"} 7 | 8 | response = requests.request("POST", url, data=payload, headers=headers) 9 | 10 | print(response.text) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/cookies.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | headers = {"Cookie":"foo=bar; bar=baz"} 6 | 7 | response = requests.request("POST", url, headers=headers) 8 | 9 | print(response.text) 10 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/custom-method.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | response = requests.request("GET", url) 6 | 7 | print(response.text) 8 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/full.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | querystring = { 6 | "foo": [ 7 | "bar", 8 | "baz" 9 | ], 10 | "baz": "abc", 11 | "key": "value" 12 | } 13 | 14 | payload = "foo=bar" 15 | headers = {"Cookie":"foo=bar; bar=baz","content-type":"application/x-www-form-urlencoded","accept":"application/json"} 16 | 17 | response = requests.request("POST", url, data=payload, headers=headers, params=querystring) 18 | 19 | print(response.text) 20 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/headers.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | headers = {"x-foo":"Bar","accept":"application/json"} 6 | 7 | response = requests.request("GET", url, headers=headers) 8 | 9 | print(response.text) 10 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/https.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "https://mockbin.com/har" 4 | 5 | response = requests.request("GET", url) 6 | 7 | print(response.text) 8 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/jsonObj-null-value.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | payload = "{\"foo\":null}" 6 | headers = {"content-type":"application/json"} 7 | 8 | response = requests.request("POST", url, data=payload, headers=headers) 9 | 10 | print(response.text) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/multipart-data.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\nHello World\r\n-----011000010111000001101001--\r\n" 6 | headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'} 7 | 8 | response = requests.request("POST", url, data=payload, headers=headers) 9 | 10 | print(response.text) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/multipart-file.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--\r\n" 6 | headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'} 7 | 8 | response = requests.request("POST", url, data=payload, headers=headers) 9 | 10 | print(response.text) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/multipart-form-data.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" 6 | headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'} 7 | 8 | response = requests.request("POST", url, data=payload, headers=headers) 9 | 10 | print(response.text) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/query.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | querystring = { 6 | "foo": [ 7 | "bar", 8 | "baz" 9 | ], 10 | "baz": "abc", 11 | "key": "value" 12 | } 13 | 14 | response = requests.request("GET", url, params=querystring) 15 | 16 | print(response.text) 17 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/short.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | response = requests.request("GET", url) 6 | 7 | print(response.text) 8 | -------------------------------------------------------------------------------- /src/test/resources/output/python/requests/text-plain.py: -------------------------------------------------------------------------------- 1 | import requests 2 | 3 | url = "http://mockbin.com/har" 4 | 5 | payload = "Hello World" 6 | headers = {"content-type":"text/plain"} 7 | 8 | response = requests.request("POST", url, data=payload, headers=headers) 9 | 10 | print(response.text) 11 | -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/application-form-encoded.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | payload <- "foo=bar&hello=world" 6 | 7 | encode <- "form" 8 | 9 | response <- VERB("POST", url, body = payload, content_type("application/x-www-form-urlencoded"), encode = encode) 10 | 11 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/application-json.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | payload <- "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 6 | 7 | encode <- "json" 8 | 9 | response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode) 10 | 11 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/cookies.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | response <- VERB("POST", url, content_type("application/octet-stream"), set_cookies(`foo` = "bar", `bar` = "baz")) 6 | 7 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/custom-method.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | response <- VERB("PROPFIND", url, content_type("application/octet-stream")) 6 | 7 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/full.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | queryString <- list( 6 | foo = "bar,baz", 7 | baz = "abc" 8 | ) 9 | 10 | payload <- "foo=bar" 11 | 12 | encode <- "form" 13 | 14 | response <- VERB("POST", url, body = payload, query = queryString, content_type("application/x-www-form-urlencoded"), accept("application/json"), set_cookies(`foo` = "bar", `bar` = "baz"), encode = encode) 15 | 16 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/headers.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | response <- VERB("GET", url, add_headers('x-foo' = 'Bar', 'quoted-value' = '"quoted" \'string\''), content_type("application/octet-stream"), accept("application/json")) 6 | 7 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/https.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "https://mockbin.com/har" 4 | 5 | response <- VERB("GET", url, content_type("application/octet-stream")) 6 | 7 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/jsonObj-multiline.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | payload <- "{\n \"foo\": \"bar\"\n}" 6 | 7 | encode <- "json" 8 | 9 | response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode) 10 | 11 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/jsonObj-null-value.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | payload <- "{\"foo\":null}" 6 | 7 | encode <- "json" 8 | 9 | response <- VERB("POST", url, body = payload, content_type("application/json"), encode = encode) 10 | 11 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/multipart-file.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--\r\n" 6 | 7 | encode <- "multipart" 8 | 9 | response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode) 10 | 11 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/multipart-form-data-no-params.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | payload <- "" 6 | 7 | response <- VERB("POST", url, body = payload, content_type("multipart/form-data")) 8 | 9 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/multipart-form-data.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | payload <- "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" 6 | 7 | encode <- "multipart" 8 | 9 | response <- VERB("POST", url, body = payload, content_type("multipart/form-data"), encode = encode) 10 | 11 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/nested.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | queryString <- list( 6 | foo[bar] = "baz,zap", 7 | fiz = "buz" 8 | ) 9 | 10 | response <- VERB("GET", url, query = queryString, content_type("application/octet-stream")) 11 | 12 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/query-two-params.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | queryString <- list( 6 | perPage = "100", 7 | page = "1" 8 | ) 9 | 10 | response <- VERB("GET", url, query = queryString, content_type("application/octet-stream")) 11 | 12 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/query.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | queryString <- list( 6 | foo = "bar,baz", 7 | baz = "abc" 8 | ) 9 | 10 | response <- VERB("GET", url, query = queryString, content_type("application/octet-stream")) 11 | 12 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/short.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | response <- VERB("GET", url, content_type("application/octet-stream")) 6 | 7 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/r/httpr/text-plain.r: -------------------------------------------------------------------------------- 1 | library(httr) 2 | 3 | url <- "http://mockbin.com/har" 4 | 5 | payload <- "Hello World" 6 | 7 | encode <- "raw" 8 | 9 | response <- VERB("POST", url, body = payload, content_type("text/plain"), encode = encode) 10 | 11 | content(response, "text") -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/application-form-encoded.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | data = { 4 | :foo => "bar", 5 | :hello => "world", 6 | } 7 | 8 | conn = Faraday.new( 9 | url: 'http://mockbin.com', 10 | headers: {'Content-Type' => 'application/x-www-form-urlencoded'} 11 | ) 12 | 13 | response = conn.post('/har') do |req| 14 | req.body = URI.encode_www_form(data) 15 | end 16 | 17 | puts response.status 18 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/application-json.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | headers: {'Content-Type' => 'application/json'} 6 | ) 7 | 8 | response = conn.post('/har') do |req| 9 | req.body = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 10 | end 11 | 12 | puts response.status 13 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/cookies.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | ) 6 | 7 | response = conn.post('/har') do |req| 8 | req.headers['cookie'] = 'foo=bar; bar=baz' 9 | end 10 | 11 | puts response.status 12 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/custom-method.rb: -------------------------------------------------------------------------------- 1 | # Faraday cannot currently run PROPFIND requests. Please use another client. -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/headers.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | ) 6 | 7 | response = conn.get('/har') do |req| 8 | req.headers['accept'] = 'application/json' 9 | req.headers['x-foo'] = 'Bar' 10 | req.headers['quoted-value'] = '"quoted" \'string\'' 11 | end 12 | 13 | puts response.status 14 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/https.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'https://mockbin.com', 5 | ) 6 | 7 | response = conn.get('/har') do |req| 8 | end 9 | 10 | puts response.status 11 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/jsonObj-multiline.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | headers: {'Content-Type' => 'application/json'} 6 | ) 7 | 8 | response = conn.post('/har') do |req| 9 | req.body = "{\n \"foo\": \"bar\"\n}" 10 | end 11 | 12 | puts response.status 13 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/jsonObj-null-value.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | headers: {'Content-Type' => 'application/json'} 6 | ) 7 | 8 | response = conn.post('/har') do |req| 9 | req.body = "{\"foo\":null}" 10 | end 11 | 12 | puts response.status 13 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/multipart-file.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'} 6 | ) 7 | 8 | response = conn.post('/har') do |req| 9 | req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"; filename=\"hello.txt\"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--\r\n" 10 | end 11 | 12 | puts response.status 13 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/multipart-form-data-no-params.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | headers: {'Content-Type' => 'multipart/form-data'} 6 | ) 7 | 8 | response = conn.post('/har') do |req| 9 | end 10 | 11 | puts response.status 12 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/multipart-form-data.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | headers: {'Content-Type' => 'multipart/form-data; boundary=---011000010111000001101001'} 6 | ) 7 | 8 | response = conn.post('/har') do |req| 9 | req.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" 10 | end 11 | 12 | puts response.status 13 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/nested.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | ) 6 | 7 | response = conn.get('/har') do |req| 8 | req.params['foo[bar]'] = 'baz,zap' 9 | req.params['fiz'] = 'buz' 10 | req.params['key'] = 'value' 11 | end 12 | 13 | puts response.status 14 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/query.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | ) 6 | 7 | response = conn.get('/har') do |req| 8 | req.params['foo'] = ["bar","baz"] 9 | req.params['baz'] = 'abc' 10 | req.params['key'] = 'value' 11 | end 12 | 13 | puts response.status 14 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/short.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | ) 6 | 7 | response = conn.get('/har') do |req| 8 | end 9 | 10 | puts response.status 11 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/faraday/text-plain.rb: -------------------------------------------------------------------------------- 1 | require 'faraday' 2 | 3 | conn = Faraday.new( 4 | url: 'http://mockbin.com', 5 | headers: {'Content-Type' => 'text/plain'} 6 | ) 7 | 8 | response = conn.post('/har') do |req| 9 | req.body = "Hello World" 10 | end 11 | 12 | puts response.status 13 | puts response.body -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/application-form-encoded.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Post.new(url) 9 | request["content-type"] = "application/x-www-form-urlencoded" 10 | request.body = "foo=bar&hello=world" 11 | 12 | response = http.request(request) 13 | puts response.read_body 14 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/application-json.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Post.new(url) 9 | request["content-type"] = "application/json" 10 | request.body = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" 11 | 12 | response = http.request(request) 13 | puts response.read_body 14 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/cookies.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Post.new(url) 9 | request["Cookie"] = "foo=bar; bar=baz" 10 | 11 | response = http.request(request) 12 | puts response.read_body 13 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/custom-method.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Get.new(url) 9 | 10 | response = http.request(request) 11 | puts response.read_body 12 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/full.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Post.new(url) 9 | request["Cookie"] = "foo=bar; bar=baz" 10 | request["content-type"] = "application/x-www-form-urlencoded" 11 | request["accept"] = "application/json" 12 | request.body = "foo=bar" 13 | 14 | response = http.request(request) 15 | puts response.read_body 16 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/headers.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Get.new(url) 9 | request["x-foo"] = "Bar" 10 | request["accept"] = "application/json" 11 | 12 | response = http.request(request) 13 | puts response.read_body 14 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/https.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | require 'openssl' 4 | 5 | url = URI("https://mockbin.com/har") 6 | 7 | http = Net::HTTP.new(url.host, url.port) 8 | http.use_ssl = true 9 | http.verify_mode = OpenSSL::SSL::VERIFY_NONE 10 | 11 | request = Net::HTTP::Get.new(url) 12 | 13 | response = http.request(request) 14 | puts response.read_body 15 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/jsonObj-null-value.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Post.new(url) 9 | request["content-type"] = "application/json" 10 | request.body = "{\"foo\":null}" 11 | 12 | response = http.request(request) 13 | puts response.read_body 14 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/multipart-form-data.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Post.new(url) 9 | request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001' 10 | request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" 11 | 12 | response = http.request(request) 13 | puts response.read_body 14 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/query.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Get.new(url) 9 | 10 | response = http.request(request) 11 | puts response.read_body 12 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/short.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Get.new(url) 9 | 10 | response = http.request(request) 11 | puts response.read_body 12 | -------------------------------------------------------------------------------- /src/test/resources/output/ruby/nethttp/text-plain.rb: -------------------------------------------------------------------------------- 1 | require 'uri' 2 | require 'net/http' 3 | 4 | url = URI("http://mockbin.com/har") 5 | 6 | http = Net::HTTP.new(url.host, url.port) 7 | 8 | request = Net::HTTP::Post.new(url) 9 | request["content-type"] = "text/plain" 10 | request.body = "Hello World" 11 | 12 | response = http.request(request) 13 | puts response.read_body 14 | -------------------------------------------------------------------------------- /src/test/resources/output/rust/reqwest/custom-method.rs: -------------------------------------------------------------------------------- 1 | use std::str::FromStr; 2 | use reqwest; 3 | 4 | #[tokio::main] 5 | pub async fn main() { 6 | let url = "http://mockbin.com/har"; 7 | 8 | let client = reqwest::Client::new(); 9 | let response = client.request(reqwest::Method::from_str("PROPFIND").unwrap(), url) 10 | .send() 11 | .await; 12 | 13 | let results = response.unwrap() 14 | .json::() 15 | .await 16 | .unwrap(); 17 | 18 | dbg!(results); 19 | } 20 | -------------------------------------------------------------------------------- /src/test/resources/output/rust/reqwest/https.rs: -------------------------------------------------------------------------------- 1 | use reqwest; 2 | 3 | #[tokio::main] 4 | pub async fn main() { 5 | let url = "https://mockbin.com/har"; 6 | 7 | let client = reqwest::Client::new(); 8 | let response = client.get(url) 9 | .send() 10 | .await; 11 | 12 | let results = response.unwrap() 13 | .json::() 14 | .await 15 | .unwrap(); 16 | 17 | dbg!(results); 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/output/rust/reqwest/short.rs: -------------------------------------------------------------------------------- 1 | use reqwest; 2 | 3 | #[tokio::main] 4 | pub async fn main() { 5 | let url = "http://mockbin.com/har"; 6 | 7 | let client = reqwest::Client::new(); 8 | let response = client.get(url) 9 | .send() 10 | .await; 11 | 12 | let results = response.unwrap() 13 | .json::() 14 | .await 15 | .unwrap(); 16 | 17 | dbg!(results); 18 | } 19 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/application-form-encoded.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url 'http://mockbin.com/har' \ 3 | --header 'content-type: application/x-www-form-urlencoded' \ 4 | --data 'foo=bar' \ 5 | --data 'hello=world' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/application-json.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url 'http://mockbin.com/har' \ 3 | --header 'content-type: application/json' \ 4 | --data '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/cookies.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url 'http://mockbin.com/har' \ 3 | --cookie 'foo=bar; bar=baz' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/custom-method.sh: -------------------------------------------------------------------------------- 1 | curl --request GET \ 2 | --url 'http://mockbin.com/har' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/full.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url 'http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value' \ 3 | --header 'accept: application/json' \ 4 | --header 'content-type: application/x-www-form-urlencoded' \ 5 | --cookie 'foo=bar; bar=baz' \ 6 | --data 'foo=bar' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/headers.sh: -------------------------------------------------------------------------------- 1 | curl --request GET \ 2 | --url 'http://mockbin.com/har' \ 3 | --header 'accept: application/json' \ 4 | --header 'x-foo: Bar' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/http1.sh: -------------------------------------------------------------------------------- 1 | curl --request GET \ 2 | --url "http://mockbin.com/request" \ 3 | --http1.0 -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/https.sh: -------------------------------------------------------------------------------- 1 | curl --request GET \ 2 | --url 'https://mockbin.com/har' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/jsonObj-null-value.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url 'http://mockbin.com/har' \ 3 | --header 'content-type: application/json' \ 4 | --data '{"foo":null}' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/multipart-data.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url http://mockbin.com/har \ 3 | --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ 4 | --form 'foo=Hello World' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/multipart-file.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url http://mockbin.com/har \ 3 | --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ 4 | --form foo=@test/fixtures/files/hello.txt -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/multipart-form-data.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url http://mockbin.com/har \ 3 | --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ 4 | --form foo=bar -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/query.sh: -------------------------------------------------------------------------------- 1 | curl --request GET \ 2 | --url 'http://mockbin.com/har?baz=abc&foo=bar&foo=baz&key=value' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/short.sh: -------------------------------------------------------------------------------- 1 | curl --request GET \ 2 | --url 'http://mockbin.com/har' -------------------------------------------------------------------------------- /src/test/resources/output/shell/curl/text-plain.sh: -------------------------------------------------------------------------------- 1 | curl --request POST \ 2 | --url 'http://mockbin.com/har' \ 3 | --header 'content-type: text/plain' \ 4 | --data 'Hello World' -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/application-form-encoded.sh: -------------------------------------------------------------------------------- 1 | http --form POST http://mockbin.com/har \ 2 | content-type:application/x-www-form-urlencoded \ 3 | foo=bar \ 4 | hello=world 5 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/application-json.sh: -------------------------------------------------------------------------------- 1 | echo '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' | \ 2 | http POST http://mockbin.com/har \ 3 | content-type:application/json 4 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/cookies.sh: -------------------------------------------------------------------------------- 1 | http POST http://mockbin.com/har \ 2 | cookie:'foo=bar; bar=baz' 3 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/custom-method.sh: -------------------------------------------------------------------------------- 1 | http PROPFIND http://mockbin.com/har 2 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/full.sh: -------------------------------------------------------------------------------- 1 | http --form POST 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' \ 2 | accept:application/json \ 3 | content-type:application/x-www-form-urlencoded \ 4 | cookie:'foo=bar; bar=baz' \ 5 | foo=bar 6 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/headers.sh: -------------------------------------------------------------------------------- 1 | http GET http://mockbin.com/har \ 2 | accept:application/json \ 3 | x-foo:Bar 4 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/https.sh: -------------------------------------------------------------------------------- 1 | http GET https://mockbin.com/har 2 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/jsonObj-null-value.sh: -------------------------------------------------------------------------------- 1 | echo '{"foo":null}' | \ 2 | http POST http://mockbin.com/har \ 3 | content-type:application/json 4 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/multipart-data.sh: -------------------------------------------------------------------------------- 1 | echo '-----011000010111000001101001 2 | Content-Disposition: form-data; name="foo"; filename="hello.txt" 3 | Content-Type: text/plain 4 | 5 | Hello World 6 | -----011000010111000001101001-- 7 | ' | \ 8 | http POST http://mockbin.com/har \ 9 | content-type:'multipart/form-data; boundary=---011000010111000001101001' 10 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/multipart-file.sh: -------------------------------------------------------------------------------- 1 | echo '-----011000010111000001101001 2 | Content-Disposition: form-data; name="foo"; filename="hello.txt" 3 | Content-Type: text/plain 4 | 5 | 6 | -----011000010111000001101001-- 7 | ' | \ 8 | http POST http://mockbin.com/har \ 9 | content-type:'multipart/form-data; boundary=---011000010111000001101001' 10 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/multipart-form-data.sh: -------------------------------------------------------------------------------- 1 | echo '-----011000010111000001101001 2 | Content-Disposition: form-data; name="foo" 3 | 4 | bar 5 | -----011000010111000001101001-- 6 | ' | \ 7 | http POST http://mockbin.com/har \ 8 | content-type:'multipart/form-data; boundary=---011000010111000001101001' 9 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/query.sh: -------------------------------------------------------------------------------- 1 | http GET 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' 2 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/short.sh: -------------------------------------------------------------------------------- 1 | http GET http://mockbin.com/har 2 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/httpie/text-plain.sh: -------------------------------------------------------------------------------- 1 | echo 'Hello World' | \ 2 | http POST http://mockbin.com/har \ 3 | content-type:text/plain 4 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/application-form-encoded.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'content-type: application/x-www-form-urlencoded' \ 4 | --body-data 'foo=bar&hello=world' \ 5 | --output-document \ 6 | - http://mockbin.com/har 7 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/application-json.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'content-type: application/json' \ 4 | --body-data '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' \ 5 | --output-document \ 6 | - http://mockbin.com/har 7 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/cookies.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'cookie: foo=bar; bar=baz' \ 4 | --output-document \ 5 | - http://mockbin.com/har 6 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/custom-method.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method PROPFIND \ 3 | --output-document \ 4 | - http://mockbin.com/har 5 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/full.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'cookie: foo=bar; bar=baz' \ 4 | --header 'accept: application/json' \ 5 | --header 'content-type: application/x-www-form-urlencoded' \ 6 | --body-data foo=bar \ 7 | --output-document \ 8 | - 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' 9 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/headers.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method GET \ 3 | --header 'accept: application/json' \ 4 | --header 'x-foo: Bar' \ 5 | --output-document \ 6 | - http://mockbin.com/har 7 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/https.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method GET \ 3 | --output-document \ 4 | - https://mockbin.com/har 5 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/jsonObj-null-value.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'content-type: application/json' \ 4 | --body-data '{"foo":null}' \ 5 | --output-document \ 6 | - http://mockbin.com/har 7 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/multipart-data.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ 4 | --body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="foo"; filename="hello.txt"\r\nContent-Type: text/plain\r\n\r\nHello World\r\n-----011000010111000001101001--\r\n' \ 5 | --output-document \ 6 | - http://mockbin.com/har 7 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/multipart-file.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ 4 | --body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="foo"; filename="hello.txt"\r\nContent-Type: text/plain\r\n\r\n\r\n-----011000010111000001101001--\r\n' \ 5 | --output-document \ 6 | - http://mockbin.com/har 7 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/multipart-form-data.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ 4 | --body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="foo"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n' \ 5 | --output-document \ 6 | - http://mockbin.com/har 7 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/query.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method GET \ 3 | --output-document \ 4 | - 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' 5 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/short.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method GET \ 3 | --output-document \ 4 | - http://mockbin.com/har 5 | -------------------------------------------------------------------------------- /src/test/resources/output/shell/wget/text-plain.sh: -------------------------------------------------------------------------------- 1 | wget --quiet \ 2 | --method POST \ 3 | --header 'content-type: text/plain' \ 4 | --body-data 'Hello World' \ 5 | --output-document \ 6 | - http://mockbin.com/har 7 | --------------------------------------------------------------------------------