diff --git a/packages/insomnia-app/app/common/__tests__/database.test.js b/packages/insomnia-app/app/common/__tests__/database.test.js index e46756fb5c..ff121a70cd 100644 --- a/packages/insomnia-app/app/common/__tests__/database.test.js +++ b/packages/insomnia-app/app/common/__tests__/database.test.js @@ -102,7 +102,7 @@ describe('requestCreate()', () => { }; const r = await models.request.create(patch); - expect(Object.keys(r).length).toBe(19); + expect(Object.keys(r).length).toBe(20); expect(r._id).toMatch(/^req_[a-zA-Z0-9]{32}$/); expect(r.created).toBeGreaterThanOrEqual(now); diff --git a/packages/insomnia-app/app/models/__tests__/request.test.js b/packages/insomnia-app/app/models/__tests__/request.test.js index b3dae19ff5..aebb357399 100644 --- a/packages/insomnia-app/app/models/__tests__/request.test.js +++ b/packages/insomnia-app/app/models/__tests__/request.test.js @@ -19,7 +19,8 @@ describe('init()', () => { settingStoreCookies: true, settingSendCookies: true, settingDisableRenderRequestBody: false, - settingEncodeUrl: true + settingEncodeUrl: true, + settingRebuildPath: true }); }); }); @@ -53,7 +54,8 @@ describe('create()', async () => { settingStoreCookies: true, settingSendCookies: true, settingDisableRenderRequestBody: false, - settingEncodeUrl: true + settingEncodeUrl: true, + settingRebuildPath: true }; expect(request).toEqual(expected); @@ -315,7 +317,8 @@ describe('migrate()', () => { settingStoreCookies: true, settingSendCookies: true, settingDisableRenderRequestBody: false, - settingEncodeUrl: true + settingEncodeUrl: true, + settingRebuildPath: true }; const migrated = await models.initModel(models.request.type, original); diff --git a/packages/insomnia-app/app/plugins/context/__tests__/data.test.js b/packages/insomnia-app/app/plugins/context/__tests__/data.test.js index e1777f7403..926dc34123 100644 --- a/packages/insomnia-app/app/plugins/context/__tests__/data.test.js +++ b/packages/insomnia-app/app/plugins/context/__tests__/data.test.js @@ -80,6 +80,7 @@ describe('app.import.*', () => { settingEncodeUrl: true, settingSendCookies: true, settingStoreCookies: true, + settingRebuildPath: true, type: 'Request', url: 'https://insomnia.rest' }]); @@ -126,6 +127,7 @@ describe('app.import.*', () => { settingEncodeUrl: true, settingSendCookies: true, settingStoreCookies: true, + settingRebuildPath: true, type: 'Request', url: 'https://insomnia.rest' }]); @@ -196,6 +198,7 @@ describe('app.export.*', () => { settingEncodeUrl: true, settingSendCookies: true, settingStoreCookies: true, + settingRebuildPath: true, url: 'https://insomnia.rest' }] }); diff --git a/packages/insomnia-httpsnippet/.editorconfig b/packages/insomnia-httpsnippet/.editorconfig new file mode 100755 index 0000000000..e717f5eb63 --- /dev/null +++ b/packages/insomnia-httpsnippet/.editorconfig @@ -0,0 +1,13 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/packages/insomnia-httpsnippet/.gitignore b/packages/insomnia-httpsnippet/.gitignore new file mode 100755 index 0000000000..dddca890ce --- /dev/null +++ b/packages/insomnia-httpsnippet/.gitignore @@ -0,0 +1,3 @@ +*.log +node_modules +coverage* diff --git a/packages/insomnia-httpsnippet/.jshintrc b/packages/insomnia-httpsnippet/.jshintrc new file mode 100755 index 0000000000..086f6bacbb --- /dev/null +++ b/packages/insomnia-httpsnippet/.jshintrc @@ -0,0 +1,4 @@ +{ + "asi": true, + "node": true +} diff --git a/packages/insomnia-httpsnippet/.npmignore b/packages/insomnia-httpsnippet/.npmignore new file mode 100755 index 0000000000..59e4f4a9aa --- /dev/null +++ b/packages/insomnia-httpsnippet/.npmignore @@ -0,0 +1,3 @@ +.jshintrc +.editorconfig +test diff --git a/packages/insomnia-httpsnippet/.travis.yml b/packages/insomnia-httpsnippet/.travis.yml new file mode 100755 index 0000000000..bc27bef00c --- /dev/null +++ b/packages/insomnia-httpsnippet/.travis.yml @@ -0,0 +1,21 @@ +language: node_js + +node_js: + - iojs + - 0.10 + - 0.12 + +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq --yes python3 php5-curl php5-cli + +after_script: + - npm run codeclimate + +notifications: + webhooks: + urls: + - https://webhooks.gitter.im/e/95c4e911f2486588f98c + on_success: always + on_failure: always + on_start: false diff --git a/packages/insomnia-httpsnippet/CONTRIBUTING.md b/packages/insomnia-httpsnippet/CONTRIBUTING.md new file mode 100755 index 0000000000..82e260334e --- /dev/null +++ b/packages/insomnia-httpsnippet/CONTRIBUTING.md @@ -0,0 +1,139 @@ +# Contributing to this project + +Please take a moment to review this document in order to make the contribution +process easy and effective for everyone involved. + +Following these guidelines helps to communicate that you respect the time of +the developers managing and developing this open source project. In return, +they should reciprocate that respect in addressing your issue or assessing +patches and features. + +## Using the issue tracker + +The [issue tracker](/issues) is the preferred channel for [bug reports](#bug-reports), +[features requests](#feature-requests) and [submitting pull requests](#pull-requests), +but please respect the following restrictions: + +* Please **do not** use the issue tracker for personal support requests (use + [Stack Overflow](http://stackoverflow.com) or IRC). + +* Please **do not** derail or troll issues. Keep the discussion on topic and + respect the opinions of others. + +## Bug reports + +A bug is a _demonstrable problem_ that is caused by the code in the repository. +Good bug reports are extremely helpful - thank you! + +Guidelines for bug reports: + +1. **Use the GitHub issue search** — check if the issue has already been + reported. + +2. **Check if the issue has been fixed** — try to reproduce it using the + latest `master` or development branch in the repository. + +3. **Isolate the problem** — create a [reduced test + case](http://css-tricks.com/6263-reduced-test-cases/) and a live example. + +A good bug report shouldn't leave others needing to chase you up for more +information. Please try to be as detailed as possible in your report. What is +your environment? What steps will reproduce the issue? What browser(s) and OS +experience the problem? What would you expect to be the outcome? All these +details will help people to fix any potential bugs. + +Example: + +> Short and descriptive example bug report title +> +> A summary of the issue and the browser/OS environment in which it occurs. If +> suitable, include the steps required to reproduce the bug. +> +> 1. This is the first step +> 2. This is the second step +> 3. Further steps, etc. +> +> `` - a link to the reduced test case +> +> Any other information you want to share that is relevant to the issue being +> reported. This might include the lines of code that you have identified as +> causing the bug, and potential solutions (and your opinions on their +> merits). + +## Feature requests + +Feature requests are welcome. But take a moment to find out whether your idea +fits with the scope and aims of the project. It's up to *you* to make a strong +case to convince the project's developers of the merits of this feature. Please +provide as much detail and context as possible. + +## Pull requests + +Good pull requests (patches, improvements, new features) are a fantastic +help. They should remain focused in scope and avoid containing unrelated +commits. + +**Please ask first** before embarking on any significant pull request (e.g. +implementing features, refactoring code, porting to a different language), +otherwise you risk spending a lot of time working on something that the +project's developers might not want to merge into the project. + +Please adhere to the coding conventions used throughout a project (indentation, +accurate comments, etc.) and any other requirements (such as test coverage). + +Follow this process if you'd like your work considered for inclusion in the +project: + +1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, + and configure the remotes: + + ```bash + # Clone your fork of the repo into the current directory + git clone https://github.com// + # Navigate to the newly cloned directory + cd + # Assign the original repo to a remote called "upstream" + git remote add upstream https://github.com/Mashape/httpsnippet.git + ``` + +2. If you cloned a while ago, get the latest changes from upstream: + + ```bash + git checkout + git pull upstream + ``` + +3. Create a new topic branch (off the main project development branch) to + contain your feature, change, or fix: + + ```bash + git checkout -b + ``` + +4. Commit your changes in logical chunks. Please adhere to these [git commit + message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) + or your code is unlikely be merged into the main project. Use Git's + [interactive rebase](https://help.github.com/articles/interactive-rebase) + feature to tidy up your commits before making them public. + +5. Locally merge (or rebase) the upstream development branch into your topic branch: + + ```bash + git pull [--rebase] upstream + ``` + +6. Push your topic branch up to your fork: + + ```bash + git push origin + ``` + +7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) + with a clear title and description. + +**IMPORTANT**: By submitting a patch, you agree to allow the project owner to +license your work under the same license as that used by the project. + +## Creating New Conversion Targets + +For a info on creating new conversion targets, please review this [guideline](https://github.com/Mashape/httpsnippet/wiki/Creating-Targets) diff --git a/packages/insomnia-httpsnippet/LICENSE b/packages/insomnia-httpsnippet/LICENSE new file mode 100755 index 0000000000..fbab00b10a --- /dev/null +++ b/packages/insomnia-httpsnippet/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2015 Mashape (https://www.mashape.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/insomnia-httpsnippet/README.md b/packages/insomnia-httpsnippet/README.md new file mode 100755 index 0000000000..b45396cf3b --- /dev/null +++ b/packages/insomnia-httpsnippet/README.md @@ -0,0 +1,218 @@ +# HTTP Snippet [![version][npm-version]][npm-url] [![License][npm-license]][license-url] + +> HTTP Request snippet generator for *many* languages & tools including: `cURL`, `HTTPie`, `Javascript`, `Node`, `C`, `Java`, `PHP`, `Objective-C`, `Swift`, `Python`, `Ruby`, `C#`, `Go`, `OCaml` and [more](https://github.com/Mashape/httpsnippet/wiki/Targets)! + +Relies on the popular [HAR](http://www.softwareishard.com/blog/har-12-spec/#request) format to import data and describe HTTP calls. + +See it in action on companion service: [APIembed](https://apiembed.com/) + +[![Build Status][travis-image]][travis-url] +[![Downloads][npm-downloads]][npm-url] +[![Code Climate][codeclimate-quality]][codeclimate-url] +[![Coverage Status][codeclimate-coverage]][codeclimate-url] +[![Dependencies][david-image]][david-url] +[![Gitter][gitter-image]][gitter-url] + +## Install + +```shell +# to use in cli +npm install --global httpsnippet + +# to use as a module +npm install --save httpsnippet +``` + +## Usage + +``` + + Usage: httpsnippet [options] + + Options: + + -h, --help output usage information + -V, --version output the version number + -t, --target target output + -c, --client [client] target client library + -o, --output write output to directory + +``` + +###### Example + +process single file: [`example.json`](test/fixtures/requests/full.json) in [HAR Request Object](http://www.softwareishard.com/blog/har-12-spec/#request) format, or full [HAR](http://www.softwareishard.com/blog/har-12-spec/#log) log format: + +```shell +httpsnippet example.json --target node --client unirest --output ./snippets +``` + +```shell +$ tree snippets +snippets/ +└── example.js +``` + +process multiple files: + +```shell +httpsnippet ./*.json --target node --client request --output ./snippets +``` + +```shell +$ tree snippets/ +snippets/ +├── endpoint-1.js +├── endpoint-2.js +└── endpoint-3.js +``` + +## API + +### HTTPSnippet(source) + +#### source + +*Required* +Type: `object` + +Name of [conversion target](https://github.com/Mashape/httpsnippet/wiki/Targets) + +```js +var HTTPSnippet = require('httpsnippet'); + +var snippet = new HTTPSnippet({ + method: 'GET', + url: 'http://mockbin.com/request' +}); +``` + +### convert(target [, options]) + +#### target + +*Required* +Type: `string` + +Name of [conversion target](https://github.com/Mashape/httpsnippet/wiki/Targets) + +#### options + +Type: `object` + +Target options, *see [wiki](https://github.com/Mashape/httpsnippet/wiki/Targets) for details* + +```js +var HTTPSnippet = require('httpsnippet'); + +var snippet = new HTTPSnippet({ + method: 'GET', + url: 'http://mockbin.com/request' +}); + +// generate Node.js: Native output +console.log(snippet.convert('node')); + +// generate Node.js: Native output, indent with tabs +console.log(snippet.convert('node', { + indent: '\t' +})); +``` + +### convert(target [, client, options]) + +#### target + +*Required* +Type: `string` + +Name of [conversion target](https://github.com/Mashape/httpsnippet/wiki/Targets) + +#### client + +Type: `string` + +Name of conversion target [client library](https://github.com/Mashape/httpsnippet/wiki/Targets) + +#### options + +Type: `object` + +Target options, *see [wiki](https://github.com/Mashape/httpsnippet/wiki/Targets) for details* + +```js +var HTTPSnippet = require('httpsnippet'); + +var snippet = new HTTPSnippet({ + method: 'GET', + url: 'http://mockbin.com/request' +}); + +// generate Shell: cURL output +console.log(snippet.convert('shell', 'curl', { + indent: '\t' +})); + +// generate Node.js: Unirest output +console.log(snippet.convert('node', 'unirest')); +``` + +## Documentation + +At the heart of this module is the [HAR Format](http://www.softwareishard.com/blog/har-12-spec/#request) as the HTTP request description format, please review some of the sample JSON HAR Request objects in [test fixtures](/test/fixtures/requests), or read the [HAR Docs](http://www.softwareishard.com/blog/har-12-spec/#request) for more details. + +For detailed information on each target, please review the [wiki](https://github.com/Mashape/httpsnippet/wiki). + +## Bugs and feature requests + +Have a bug or a feature request? Please first read the [issue guidelines](CONTRIBUTING.md#using-the-issue-tracker) and search for existing and closed issues. If your problem or idea is not addressed yet, [please open a new issue](/issues). + +## Contributing + +Please read through our [contributing guidelines](CONTRIBUTING.md). Included are directions for opening issues, coding standards, and notes on development. + +For a info on creating new conversion targets, please review this [guideline](https://github.com/Mashape/httpsnippet/wiki/Creating-Targets) + +More over, if your pull request contains JavaScript patches or features, you must include relevant unit tests. + +Editor preferences are available in the [editor config](.editorconfig) for easy use in common text editors. Read more and download plugins at . + +## Versioning + +For transparency into our release cycle and in striving to maintain backward compatibility, this project is maintained under the Semantic Versioning guidelines. Sometimes we screw up, but we'll adhere to these rules whenever possible. + +Releases will be numbered with the following format: + +`..` + +And constructed with the following guidelines: + +- Breaking backward compatibility **bumps the major** while resetting minor and patch +- New additions without breaking backward compatibility **bumps the minor** while resetting the patch +- Bug fixes and misc changes **bumps only the patch** + +For more information on SemVer, please visit . + +## License + +[MIT](LICENSE) © [Mashape](https://www.mashape.com) + +[license-url]: https://github.com/Mashape/httpsnippet/blob/master/LICENSE + +[travis-url]: https://travis-ci.org/Mashape/httpsnippet +[travis-image]: https://img.shields.io/travis/Mashape/httpsnippet.svg?style=flat-square + +[npm-url]: https://www.npmjs.com/package/httpsnippet +[npm-license]: https://img.shields.io/npm/l/httpsnippet.svg?style=flat-square +[npm-version]: https://img.shields.io/npm/v/httpsnippet.svg?style=flat-square +[npm-downloads]: https://img.shields.io/npm/dm/httpsnippet.svg?style=flat-square + +[codeclimate-url]: https://codeclimate.com/github/Mashape/httpsnippet +[codeclimate-quality]: https://img.shields.io/codeclimate/github/Mashape/httpsnippet.svg?style=flat-square +[codeclimate-coverage]: https://img.shields.io/codeclimate/coverage/github/Mashape/httpsnippet.svg?style=flat-square + +[david-url]: https://david-dm.org/Mashape/httpsnippet +[david-image]: https://img.shields.io/david/Mashape/httpsnippet.svg?style=flat-square + +[gitter-url]: https://gitter.im/Mashape/httpsnippet +[gitter-image]: https://img.shields.io/badge/Gitter-Join%20Chat-blue.svg?style=flat-square diff --git a/packages/insomnia-httpsnippet/bin/httpsnippet b/packages/insomnia-httpsnippet/bin/httpsnippet new file mode 100755 index 0000000000..fa2383a610 --- /dev/null +++ b/packages/insomnia-httpsnippet/bin/httpsnippet @@ -0,0 +1,80 @@ +#!/usr/bin/env node + +'use strict' + +var chalk = require('chalk') +var cmd = require('commander') +var fs = require('fs') +var readFile = require('fs-readfile-promise') +var writeFile = require('fs-writefile-promise') +var HTTPSnippet = require('..') +var path = require('path') +var pkg = require('../package.json') + +cmd + .version(pkg.version) + .usage('[options] ') + .option('-t, --target ', 'target output') + .option('-c, --client [client]', 'target client library') + .option('-o, --output ', 'write output to directory') + .parse(process.argv) + +if (!cmd.args.length || !cmd.target) { + cmd.help() +} + +if (cmd.output) { + var dir = path.resolve(cmd.output) + + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir) + } +} + +cmd.args.forEach(function (fileName) { + var file = path.basename(fileName) + + readFile(fileName) + .then(JSON.parse) + + .catch(function (e) { + console.error('%s %s failed to read JSON: %s', chalk.red('✖'), chalk.cyan.bold(file), chalk.red(e.message)) + }) + + .then(function (data) { + return new HTTPSnippet(data) + }) + + .catch(function (e) { + e.errors.forEach(function (err) { + console.error('%s %s failed validation: (%s: %s) %s', chalk.red('✖'), chalk.cyan.bold(file), chalk.cyan.italic(err.field), chalk.magenta.italic(err.value), chalk.red(err.message)) + }) + }) + + .then(function (snippet) { + return snippet.convert(cmd.target, cmd.client) + }) + + .then(function (output) { + // print + if (!cmd.output) { + return console.log('%s %s > %s [%s] :\n%s', chalk.green('✓'), chalk.cyan.bold(file), chalk.yellow(cmd.target), chalk.yellow(cmd.client ? cmd.client : 'default'), output) + } + + // write to file + var name = path.basename(file, path.extname(file)) + + var filename = path.format({ + dir: dir, + base: name + HTTPSnippet.extname(cmd.target) + }) + + return writeFile(filename, output + '\n', function () { + console.log('%s %s > %s', chalk.green('✓'), chalk.cyan.bold(file), filename) + }) + }) + + .catch(function (e) { + console.error('%s %s fail: %s', chalk.red('✖'), chalk.cyan.bold(file), chalk.red(e.message)) + }) +}) diff --git a/packages/insomnia-httpsnippet/package-lock.json b/packages/insomnia-httpsnippet/package-lock.json new file mode 100644 index 0000000000..0572cf31ec --- /dev/null +++ b/packages/insomnia-httpsnippet/package-lock.json @@ -0,0 +1,4071 @@ +{ + "name": "insomnia-httpsnippet", + "version": "1.16.5", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "abbrev": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", + "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", + "dev": true + }, + "acorn": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.5.3.tgz", + "integrity": "sha512-jd5MkIUlbbmb07nXH0DT3y7rDVtkzDi4XZOUVWAer8ajmF/DTSSbl5oNFyDOl/OXA33Bl79+ypHhl2pN20VeOQ==", + "dev": true + }, + "acorn-to-esprima": { + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/acorn-to-esprima/-/acorn-to-esprima-2.0.8.tgz", + "integrity": "sha1-AD8MZC65ITL0F9NwjxStqCrfLrE=", + "dev": true + }, + "align-text": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", + "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", + "dev": true, + "requires": { + "kind-of": "3.2.2", + "longest": "1.0.1", + "repeat-string": "1.6.1" + } + }, + "alter": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/alter/-/alter-0.2.0.tgz", + "integrity": "sha1-x1iICGF1cgNKrmJICvJrHU0cs80=", + "dev": true, + "requires": { + "stable": "0.1.6" + } + }, + "amdefine": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", + "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", + "dev": true + }, + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "1.0.3" + } + }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "dev": true, + "requires": { + "array-uniq": "1.0.3" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=", + "dev": true + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", + "dev": true + }, + "asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", + "dev": true + }, + "asn1": { + "version": "0.1.11", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.1.11.tgz", + "integrity": "sha1-VZvhg3bQik7E2+gId9J4GGObLfc=", + "dev": true, + "optional": true + }, + "assert-plus": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.1.5.tgz", + "integrity": "sha1-7nQAlBMALYTOxyGcasgRgS5yMWA=", + "dev": true, + "optional": true + }, + "ast-traverse": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/ast-traverse/-/ast-traverse-0.1.1.tgz", + "integrity": "sha1-ac8rg4bxnc2hux4F1o/jWdiJfeY=", + "dev": true + }, + "ast-types": { + "version": "0.9.6", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.9.6.tgz", + "integrity": "sha1-ECyenpAF0+fjgpvwxPok7oYu6bk=", + "dev": true + }, + "async": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/async/-/async-0.7.0.tgz", + "integrity": "sha1-RCng5i9d4KVPN0WMSfC4l+tSraU=", + "dev": true + }, + "aws-sign2": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.5.0.tgz", + "integrity": "sha1-xXED96F/wDfwLXwuZLYC6iI/fWM=", + "dev": true, + "optional": true + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + }, + "dependencies": { + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + } + } + }, + "babel-core": { + "version": "5.8.38", + "resolved": "https://registry.npmjs.org/babel-core/-/babel-core-5.8.38.tgz", + "integrity": "sha1-H8ruedfmG3ULALjlT238nQr4ZVg=", + "dev": true, + "requires": { + "babel-plugin-constant-folding": "1.0.1", + "babel-plugin-dead-code-elimination": "1.0.2", + "babel-plugin-eval": "1.0.1", + "babel-plugin-inline-environment-variables": "1.0.1", + "babel-plugin-jscript": "1.0.4", + "babel-plugin-member-expression-literals": "1.0.1", + "babel-plugin-property-literals": "1.0.1", + "babel-plugin-proto-to-assign": "1.0.4", + "babel-plugin-react-constant-elements": "1.0.3", + "babel-plugin-react-display-name": "1.0.3", + "babel-plugin-remove-console": "1.0.1", + "babel-plugin-remove-debugger": "1.0.1", + "babel-plugin-runtime": "1.0.7", + "babel-plugin-undeclared-variables-check": "1.0.2", + "babel-plugin-undefined-to-void": "1.1.6", + "babylon": "5.8.38", + "bluebird": "2.11.0", + "chalk": "1.1.3", + "convert-source-map": "1.5.1", + "core-js": "1.2.7", + "debug": "2.6.9", + "detect-indent": "3.0.1", + "esutils": "2.0.2", + "fs-readdir-recursive": "0.1.2", + "globals": "6.4.1", + "home-or-tmp": "1.0.0", + "is-integer": "1.0.7", + "js-tokens": "1.0.1", + "json5": "0.4.0", + "lodash": "3.10.1", + "minimatch": "2.0.10", + "output-file-sync": "1.1.2", + "path-exists": "1.0.0", + "path-is-absolute": "1.0.1", + "private": "0.1.8", + "regenerator": "0.8.40", + "regexpu": "1.3.0", + "repeating": "1.1.3", + "resolve": "1.1.7", + "shebang-regex": "1.0.0", + "slash": "1.0.0", + "source-map": "0.5.7", + "source-map-support": "0.2.10", + "to-fast-properties": "1.0.3", + "trim-right": "1.0.1", + "try-resolve": "1.0.1" + }, + "dependencies": { + "bluebird": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", + "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=", + "dev": true + }, + "globals": { + "version": "6.4.1", + "resolved": "https://registry.npmjs.org/globals/-/globals-6.4.1.tgz", + "integrity": "sha1-hJgDKzttHMge68X3lpDY/in6v08=", + "dev": true + }, + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true + }, + "minimatch": { + "version": "2.0.10", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", + "integrity": "sha1-jQh8OcazjAAbl/ynzm0OHoCvusc=", + "dev": true, + "requires": { + "brace-expansion": "1.1.11" + } + }, + "path-exists": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-1.0.0.tgz", + "integrity": "sha1-1aiZjrce83p0w06w2eum6HjuoIE=", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "babel-messages": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/babel-messages/-/babel-messages-6.23.0.tgz", + "integrity": "sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0" + } + }, + "babel-plugin-constant-folding": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-constant-folding/-/babel-plugin-constant-folding-1.0.1.tgz", + "integrity": "sha1-g2HTZMmORJw2kr26Ue/whEKQqo4=", + "dev": true + }, + "babel-plugin-dead-code-elimination": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/babel-plugin-dead-code-elimination/-/babel-plugin-dead-code-elimination-1.0.2.tgz", + "integrity": "sha1-X3xFEnTc18zNv7s+C4XdKBIfD2U=", + "dev": true + }, + "babel-plugin-eval": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-eval/-/babel-plugin-eval-1.0.1.tgz", + "integrity": "sha1-ovrtJc5r5preS/7CY/cBaRlZUNo=", + "dev": true + }, + "babel-plugin-inline-environment-variables": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-inline-environment-variables/-/babel-plugin-inline-environment-variables-1.0.1.tgz", + "integrity": "sha1-H1jOkSB61qgmqL9kX6/mj/X+P/4=", + "dev": true + }, + "babel-plugin-jscript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/babel-plugin-jscript/-/babel-plugin-jscript-1.0.4.tgz", + "integrity": "sha1-jzQsOCduh6R9X6CovT1etsytj8w=", + "dev": true + }, + "babel-plugin-member-expression-literals": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-member-expression-literals/-/babel-plugin-member-expression-literals-1.0.1.tgz", + "integrity": "sha1-zF7bD6qNyScXDnTW0cAkQAIWJNM=", + "dev": true + }, + "babel-plugin-property-literals": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-property-literals/-/babel-plugin-property-literals-1.0.1.tgz", + "integrity": "sha1-AlIwGQAZKYCxwRjv6kjOk6q4MzY=", + "dev": true + }, + "babel-plugin-proto-to-assign": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/babel-plugin-proto-to-assign/-/babel-plugin-proto-to-assign-1.0.4.tgz", + "integrity": "sha1-xJ56/QL1d7xNoF6i3wAiUM980SM=", + "dev": true, + "requires": { + "lodash": "3.10.1" + }, + "dependencies": { + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true + } + } + }, + "babel-plugin-react-constant-elements": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/babel-plugin-react-constant-elements/-/babel-plugin-react-constant-elements-1.0.3.tgz", + "integrity": "sha1-lGc26DeEKcvDSdz/YvUcFDs041o=", + "dev": true + }, + "babel-plugin-react-display-name": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/babel-plugin-react-display-name/-/babel-plugin-react-display-name-1.0.3.tgz", + "integrity": "sha1-dU/jiSboQkpOexWrbqYTne4FFPw=", + "dev": true + }, + "babel-plugin-remove-console": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-remove-console/-/babel-plugin-remove-console-1.0.1.tgz", + "integrity": "sha1-2PJFVsOgUAXUKqqv0neH9T/wE6c=", + "dev": true + }, + "babel-plugin-remove-debugger": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-plugin-remove-debugger/-/babel-plugin-remove-debugger-1.0.1.tgz", + "integrity": "sha1-/S6jzWGkKK0fO5yJiC/0KT6MFMc=", + "dev": true + }, + "babel-plugin-runtime": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/babel-plugin-runtime/-/babel-plugin-runtime-1.0.7.tgz", + "integrity": "sha1-v3x9lm3Vbs1cF/ocslPJrLflSq8=", + "dev": true + }, + "babel-plugin-undeclared-variables-check": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/babel-plugin-undeclared-variables-check/-/babel-plugin-undeclared-variables-check-1.0.2.tgz", + "integrity": "sha1-XPGqU52BP/ZOmWQSkK9iCWX2Xe4=", + "dev": true, + "requires": { + "leven": "1.0.2" + } + }, + "babel-plugin-undefined-to-void": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/babel-plugin-undefined-to-void/-/babel-plugin-undefined-to-void-1.1.6.tgz", + "integrity": "sha1-f1eO+LeN+uYAM4XYQXph7aBuL4E=", + "dev": true + }, + "babel-runtime": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", + "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, + "requires": { + "core-js": "2.5.3", + "regenerator-runtime": "0.11.1" + }, + "dependencies": { + "core-js": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.3.tgz", + "integrity": "sha1-isw4NFgk8W2DZbfJtCWRaOjtYD4=", + "dev": true + } + } + }, + "babel-traverse": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz", + "integrity": "sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=", + "dev": true, + "requires": { + "babel-code-frame": "6.26.0", + "babel-messages": "6.23.0", + "babel-runtime": "6.26.0", + "babel-types": "6.26.0", + "babylon": "6.18.0", + "debug": "2.6.9", + "globals": "9.18.0", + "invariant": "2.2.4", + "lodash": "4.17.5" + }, + "dependencies": { + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", + "dev": true + }, + "globals": { + "version": "9.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", + "integrity": "sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==", + "dev": true + } + } + }, + "babel-types": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz", + "integrity": "sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=", + "dev": true, + "requires": { + "babel-runtime": "6.26.0", + "esutils": "2.0.2", + "lodash": "4.17.5", + "to-fast-properties": "1.0.3" + } + }, + "babylon": { + "version": "5.8.38", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-5.8.38.tgz", + "integrity": "sha1-7JsSCxG/bM1Bc6GL8hfmC3mFn/0=", + "dev": true + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "bluebird": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", + "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", + "dev": true + }, + "boom": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/boom/-/boom-0.4.2.tgz", + "integrity": "sha1-emNune1O/O+xnO9JR6PGffrukRs=", + "dev": true, + "requires": { + "hoek": "0.9.1" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, + "breakable": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/breakable/-/breakable-1.0.0.tgz", + "integrity": "sha1-eEp5eRWjjq0nutRWtVcstLuqeME=", + "dev": true + }, + "buffer-from": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.0.0.tgz", + "integrity": "sha512-83apNb8KK0Se60UE1+4Ukbe3HbfELJ6UlI4ldtOGs7So4KD26orJM8hIY9lxdzP+UpItH1Yh/Y8GUvNFWFFRxA==", + "dev": true + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + }, + "camelcase": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=", + "dev": true + }, + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "dev": true, + "requires": { + "align-text": "0.1.4", + "lazy-cache": "1.0.4" + } + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "2.2.1", + "escape-string-regexp": "1.0.5", + "has-ansi": "2.0.0", + "strip-ansi": "3.0.1", + "supports-color": "2.0.0" + } + }, + "circular-json": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.3.3.tgz", + "integrity": "sha512-UZK3NBx2Mca+b5LsG7bY183pHWt5Y1xts4P3Pz7ENTwGVnJOUWbRb3ocjvX7hx9tq/yTAdclXm9sZ38gNuem4A==", + "dev": true + }, + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true, + "requires": { + "restore-cursor": "1.0.1" + } + }, + "cli-width": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-1.1.1.tgz", + "integrity": "sha1-pNKT72frt7iNSk1CwMzwDE0eNm0=", + "dev": true + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "dev": true, + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "wrap-ansi": "2.1.0" + } + }, + "clone": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", + "integrity": "sha1-2jCcwmPfFZlMaIypAheco8fNfH4=", + "dev": true + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "dev": true + }, + "codeclimate-test-reporter": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/codeclimate-test-reporter/-/codeclimate-test-reporter-0.1.1.tgz", + "integrity": "sha1-gSk25ThJrykLBYV1UlKxmOgUAqM=", + "dev": true, + "requires": { + "async": "0.7.0", + "lcov-parse": "0.0.6", + "request": "2.34.0" + } + }, + "combined-stream": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-0.0.7.tgz", + "integrity": "sha1-ATfmV7qlp1QcV6w3rF/AfXO03B8=", + "dev": true, + "optional": true, + "requires": { + "delayed-stream": "0.0.5" + } + }, + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==" + }, + "commoner": { + "version": "0.10.8", + "resolved": "https://registry.npmjs.org/commoner/-/commoner-0.10.8.tgz", + "integrity": "sha1-NPw2cs0kOT6LtH5wyqApOBH08sU=", + "dev": true, + "requires": { + "commander": "2.15.1", + "detective": "4.7.1", + "glob": "5.0.15", + "graceful-fs": "4.1.11", + "iconv-lite": "0.4.19", + "mkdirp": "0.5.1", + "private": "0.1.8", + "q": "1.5.1", + "recast": "0.11.23" + }, + "dependencies": { + "esprima": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", + "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", + "dev": true + }, + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "recast": { + "version": "0.11.23", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.11.23.tgz", + "integrity": "sha1-RR/TAEqx5N+bTktmN2sqIZEkYtM=", + "dev": true, + "requires": { + "ast-types": "0.9.6", + "esprima": "3.1.3", + "private": "0.1.8", + "source-map": "0.5.7" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "requires": { + "buffer-from": "1.0.0", + "inherits": "2.0.3", + "readable-stream": "2.3.5", + "typedarray": "0.0.6" + } + }, + "config-chain": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/config-chain/-/config-chain-1.1.11.tgz", + "integrity": "sha1-q6CXR9++TD5w52am5BWG4YWfxvI=", + "dev": true, + "requires": { + "ini": "1.3.5", + "proto-list": "1.2.4" + } + }, + "convert-source-map": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.5.1.tgz", + "integrity": "sha1-uCeAl7m8IpNl3lxiz1/K7YtVmeU=", + "dev": true + }, + "core-js": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=", + "dev": true + }, + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + }, + "cryptiles": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-0.2.2.tgz", + "integrity": "sha1-7ZH/HxetE9N0gohZT4pIoNJvMlw=", + "dev": true, + "optional": true, + "requires": { + "boom": "0.4.2" + } + }, + "ctype": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/ctype/-/ctype-0.5.3.tgz", + "integrity": "sha1-gsGMJGH3QRTvFsE1IkrQuRRMoS8=", + "dev": true, + "optional": true + }, + "d": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", + "integrity": "sha1-dUu1v+VUUdpppYuU1F9MWwRi1Y8=", + "dev": true, + "requires": { + "es5-ext": "0.10.41" + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "debug-log": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/debug-log/-/debug-log-1.0.1.tgz", + "integrity": "sha1-IwdjLUwEOCuN+KMvcLiVBG1SdF8=", + "dev": true + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "dev": true + }, + "deep-extend": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", + "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", + "dev": true + }, + "deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "defaults": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.3.tgz", + "integrity": "sha1-xlYFHpgX2f8I7YgUd/P+QBnz730=", + "dev": true, + "requires": { + "clone": "1.0.4" + } + }, + "defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", + "dev": true + }, + "defs": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/defs/-/defs-1.1.1.tgz", + "integrity": "sha1-siYJ8sehG6ej2xFoBcE5scr/qdI=", + "dev": true, + "requires": { + "alter": "0.2.0", + "ast-traverse": "0.1.1", + "breakable": "1.0.0", + "esprima-fb": "15001.1001.0-dev-harmony-fb", + "simple-fmt": "0.1.0", + "simple-is": "0.2.0", + "stringmap": "0.2.2", + "stringset": "0.2.1", + "tryor": "0.1.2", + "yargs": "3.27.0" + }, + "dependencies": { + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + } + }, + "esprima-fb": { + "version": "15001.1001.0-dev-harmony-fb", + "resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-15001.1001.0-dev-harmony-fb.tgz", + "integrity": "sha1-Q761fsJujPI3092LM+QlM1d/Jlk=", + "dev": true + }, + "window-size": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", + "integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=", + "dev": true + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true + }, + "yargs": { + "version": "3.27.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.27.0.tgz", + "integrity": "sha1-ISBUaTFuk5Ex1Z8toMbX+YIh6kA=", + "dev": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "os-locale": "1.4.0", + "window-size": "0.1.4", + "y18n": "3.2.1" + } + } + } + }, + "deglob": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/deglob/-/deglob-1.1.2.tgz", + "integrity": "sha1-dtV3wl/j9zKUEqK1nq3qV6xQDj8=", + "dev": true, + "requires": { + "find-root": "1.1.0", + "glob": "7.1.2", + "ignore": "3.3.7", + "pkg-config": "1.1.1", + "run-parallel": "1.1.8", + "uniq": "1.0.1", + "xtend": "4.0.1" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "dev": true, + "requires": { + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.1", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.2" + } + }, + "delayed-stream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-0.0.5.tgz", + "integrity": "sha1-1LH0OpPoKW3+AmlPRoC8N6MTxz8=", + "dev": true, + "optional": true + }, + "detect-indent": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-3.0.1.tgz", + "integrity": "sha1-ncXl3bzu+DJXZLlFGwK8bVQIT3U=", + "dev": true, + "requires": { + "get-stdin": "4.0.1", + "minimist": "1.2.0", + "repeating": "1.1.3" + } + }, + "detective": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/detective/-/detective-4.7.1.tgz", + "integrity": "sha512-H6PmeeUcZloWtdt4DAkFyzFL94arpHr3NOwwmVILFiy+9Qd4JTxxXrzfyGk/lmct2qVGBwTSwSXagqu2BxmWig==", + "dev": true, + "requires": { + "acorn": "5.5.3", + "defined": "1.0.0" + } + }, + "dezalgo": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.3.tgz", + "integrity": "sha1-f3Qt4Gb8dIvI24IFad3c5Jvw1FY=", + "dev": true, + "requires": { + "asap": "2.0.6", + "wrappy": "1.0.2" + } + }, + "diff": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-1.4.0.tgz", + "integrity": "sha1-fyjS657nsVqX79ic5j3P2qPMur8=", + "dev": true + }, + "disparity": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/disparity/-/disparity-2.0.0.tgz", + "integrity": "sha1-V92stHMkrl9Y0swNqIbbTOnutxg=", + "dev": true, + "requires": { + "ansi-styles": "2.2.1", + "diff": "1.4.0" + } + }, + "doctrine": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz", + "integrity": "sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=", + "dev": true, + "requires": { + "esutils": "1.1.6", + "isarray": "0.0.1" + }, + "dependencies": { + "esutils": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz", + "integrity": "sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + } + } + }, + "dotenv": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-2.0.0.tgz", + "integrity": "sha1-vXWcNXqqcDZeAclrewvsCKbg2Uk=", + "dev": true + }, + "duplexer": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", + "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=" + }, + "echint": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/echint/-/echint-1.5.3.tgz", + "integrity": "sha1-5bq3lDmOpgjTq3QEsweL2yoiyJw=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "commander": "2.15.1", + "debug-log": "1.0.1", + "dezalgo": "1.0.3", + "dotenv": "2.0.0", + "glob": "7.1.2", + "lintspaces": "0.4.1", + "pkg-config": "1.1.1", + "xtend": "4.0.1", + "yargs": "4.8.1" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, + "editorconfig": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.13.2.tgz", + "integrity": "sha1-jleSbZ7mmrbLmZ8CfCFxRnrM6zU=", + "dev": true, + "requires": { + "bluebird": "3.5.1", + "commander": "2.15.1", + "lru-cache": "3.2.0", + "sigmund": "1.0.1" + } + }, + "error-ex": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", + "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "dev": true, + "requires": { + "is-arrayish": "0.2.1" + } + }, + "es5-ext": { + "version": "0.10.41", + "resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.41.tgz", + "integrity": "sha512-MYK02wXfwTMie5TEJWPolgOsXEmz7wKCQaGzgmRjZOoV6VLG8I5dSv2bn6AOClXhK64gnSQTQ9W9MKvx87J4gw==", + "dev": true, + "requires": { + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1", + "next-tick": "1.0.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.41", + "es6-symbol": "3.1.1" + } + }, + "es6-map": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-map/-/es6-map-0.1.5.tgz", + "integrity": "sha1-kTbgUD3MBqMBaQ8LsU/042TpSfA=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.41", + "es6-iterator": "2.0.3", + "es6-set": "0.1.5", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } + }, + "es6-set": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.5.tgz", + "integrity": "sha1-0rPsXU2ADO2BjbU40ol02wpzzLE=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.41", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1", + "event-emitter": "0.3.5" + } + }, + "es6-symbol": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.1.tgz", + "integrity": "sha1-vwDvT9q2uhtG7Le2KbTH7VcVzHc=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.41" + } + }, + "es6-weak-map": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.2.tgz", + "integrity": "sha1-XjqzIlH/0VOKH45f+hNXdy+S2W8=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.41", + "es6-iterator": "2.0.3", + "es6-symbol": "3.1.1" + } + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "escodegen": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", + "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", + "dev": true, + "requires": { + "esprima": "2.7.3", + "estraverse": "1.9.3", + "esutils": "2.0.2", + "optionator": "0.8.2", + "source-map": "0.2.0" + } + }, + "escope": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/escope/-/escope-3.6.0.tgz", + "integrity": "sha1-4Bl16BJ4GhY6ba392AOY3GTIicM=", + "dev": true, + "requires": { + "es6-map": "0.1.5", + "es6-weak-map": "2.0.2", + "esrecurse": "4.2.1", + "estraverse": "4.2.0" + }, + "dependencies": { + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + } + } + }, + "esformatter": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/esformatter/-/esformatter-0.8.2.tgz", + "integrity": "sha1-e6mIKqPtMIOfivds3fTxLaM3084=", + "dev": true, + "requires": { + "debug": "0.7.4", + "disparity": "2.0.0", + "espree": "2.2.5", + "glob": "5.0.15", + "minimist": "1.2.0", + "mout": "1.1.0", + "npm-run": "2.0.0", + "resolve": "1.1.7", + "rocambole": "0.7.0", + "rocambole-indent": "2.0.4", + "rocambole-linebreak": "1.0.2", + "rocambole-node": "1.0.0", + "rocambole-token": "1.2.1", + "rocambole-whitespace": "1.0.0", + "stdin": "0.0.1", + "strip-json-comments": "0.1.3", + "supports-color": "1.3.1", + "user-home": "2.0.0" + }, + "dependencies": { + "debug": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-0.7.4.tgz", + "integrity": "sha1-BuHqgILCyxTjmAbiLi9vdX+Srzk=", + "dev": true + }, + "espree": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/espree/-/espree-2.2.5.tgz", + "integrity": "sha1-32kbkxCIlAKuspzAZnCMVmkLhUs=", + "dev": true + }, + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "strip-json-comments": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-0.1.3.tgz", + "integrity": "sha1-Fkxk43Coo8wAyeAbU55WmCPw7lQ=", + "dev": true + }, + "supports-color": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.3.1.tgz", + "integrity": "sha1-FXWN8J2P87SswwdTn6vicJXhBC0=", + "dev": true + } + } + }, + "esformatter-eol-last": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esformatter-eol-last/-/esformatter-eol-last-1.0.0.tgz", + "integrity": "sha1-RaeP9GIrHUnkT1a0mQV2amMpDAc=", + "dev": true, + "requires": { + "string.prototype.endswith": "0.2.0" + } + }, + "esformatter-ignore": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/esformatter-ignore/-/esformatter-ignore-0.1.3.tgz", + "integrity": "sha1-BNO4db+knd4ATMWN9va7w8BWfx4=", + "dev": true + }, + "esformatter-jsx": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/esformatter-jsx/-/esformatter-jsx-2.3.11.tgz", + "integrity": "sha1-QRxE7TJHVK+VquXe2FbVp+78td8=", + "dev": true, + "requires": { + "babel-core": "5.8.38", + "esformatter-ignore": "0.1.3", + "extend": "2.0.1", + "fresh-falafel": "1.2.0", + "js-beautify": "1.7.5" + } + }, + "esformatter-literal-notation": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/esformatter-literal-notation/-/esformatter-literal-notation-1.0.1.tgz", + "integrity": "sha1-cQ57QgF1/j9+WvrVu60ykQOELi8=", + "dev": true, + "requires": { + "rocambole": "0.3.6", + "rocambole-token": "1.2.1" + }, + "dependencies": { + "esprima": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", + "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", + "dev": true + }, + "rocambole": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/rocambole/-/rocambole-0.3.6.tgz", + "integrity": "sha1-Teu/WUMUS8e2AG2Vvo+swLdDUqc=", + "dev": true, + "requires": { + "esprima": "1.0.4" + } + } + } + }, + "esformatter-parser": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/esformatter-parser/-/esformatter-parser-1.0.0.tgz", + "integrity": "sha1-CFQHLQSHU57TnK442KVDLBfsEdM=", + "dev": true, + "requires": { + "acorn-to-esprima": "2.0.8", + "babel-traverse": "6.26.0", + "babylon": "6.18.0", + "rocambole": "0.7.0" + }, + "dependencies": { + "babylon": { + "version": "6.18.0", + "resolved": "https://registry.npmjs.org/babylon/-/babylon-6.18.0.tgz", + "integrity": "sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==", + "dev": true + } + } + }, + "esformatter-quotes": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/esformatter-quotes/-/esformatter-quotes-1.1.0.tgz", + "integrity": "sha1-4ixsRFx/MGBB2BybnlH8psv6yoI=", + "dev": true + }, + "esformatter-semicolon-first": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/esformatter-semicolon-first/-/esformatter-semicolon-first-1.2.0.tgz", + "integrity": "sha1-47US0dTgcxDqvKv1cnfqfIpW4kI=", + "dev": true, + "requires": { + "esformatter-parser": "1.0.0", + "rocambole": "0.7.0", + "rocambole-linebreak": "1.0.2", + "rocambole-token": "1.2.1" + } + }, + "esformatter-spaced-lined-comment": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/esformatter-spaced-lined-comment/-/esformatter-spaced-lined-comment-2.0.1.tgz", + "integrity": "sha1-3F80B/k8KV4eVkRr00RWDaXm3Kw=", + "dev": true + }, + "eslint": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-1.9.0.tgz", + "integrity": "sha1-p1qvB+KGUHcu0OcNqizggwebZRQ=", + "dev": true, + "requires": { + "chalk": "1.1.3", + "concat-stream": "1.6.2", + "debug": "2.6.9", + "doctrine": "0.7.2", + "escape-string-regexp": "1.0.5", + "escope": "3.6.0", + "espree": "2.2.5", + "estraverse": "4.2.0", + "estraverse-fb": "1.3.2", + "esutils": "2.0.2", + "file-entry-cache": "1.3.1", + "glob": "5.0.15", + "globals": "8.18.0", + "handlebars": "4.0.11", + "inquirer": "0.11.4", + "is-my-json-valid": "2.17.2", + "is-resolvable": "1.1.0", + "js-yaml": "3.11.0", + "json-stable-stringify": "1.0.1", + "lodash.clonedeep": "3.0.2", + "lodash.merge": "3.3.2", + "lodash.omit": "3.1.0", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "object-assign": "4.1.1", + "optionator": "0.6.0", + "path-is-absolute": "1.0.1", + "path-is-inside": "1.0.2", + "shelljs": "0.5.3", + "strip-json-comments": "1.0.4", + "text-table": "0.2.0", + "to-double-quotes": "2.0.0", + "to-single-quotes": "2.0.1", + "user-home": "2.0.0", + "xml-escape": "1.0.0" + }, + "dependencies": { + "espree": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/espree/-/espree-2.2.5.tgz", + "integrity": "sha1-32kbkxCIlAKuspzAZnCMVmkLhUs=", + "dev": true + }, + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + }, + "fast-levenshtein": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.0.7.tgz", + "integrity": "sha1-AXjc3uAjuSkFGTrwlZ6KdjnP3Lk=", + "dev": true + }, + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "levn": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.2.5.tgz", + "integrity": "sha1-uo0znQykphDjo/FFucr0iAcVUFQ=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2", + "type-check": "0.3.2" + } + }, + "optionator": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.6.0.tgz", + "integrity": "sha1-tj7Lvw4xX61LyYJ7Rdx7pFKE/LY=", + "dev": true, + "requires": { + "deep-is": "0.1.3", + "fast-levenshtein": "1.0.7", + "levn": "0.2.5", + "prelude-ls": "1.1.2", + "type-check": "0.3.2", + "wordwrap": "0.0.3" + } + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + } + } + }, + "eslint-config-standard": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-4.4.0.tgz", + "integrity": "sha1-wSl0nhmZ4M+GEHeyddnFHc2XzXU=", + "dev": true + }, + "eslint-config-standard-react": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/eslint-config-standard-react/-/eslint-config-standard-react-1.2.1.tgz", + "integrity": "sha1-7QRf2yKzoP4LsL1EnPO/vq7etbM=", + "dev": true + }, + "eslint-plugin-react": { + "version": "3.16.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-3.16.1.tgz", + "integrity": "sha1-Ji2Wt318SkKvgJpzwOUnpYYSKTw=", + "dev": true + }, + "eslint-plugin-standard": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-1.3.3.tgz", + "integrity": "sha1-owhUUVI0MedvQJxwy4+U4yvw7H8=", + "dev": true + }, + "esprima": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", + "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "dev": true + }, + "esrecurse": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", + "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "dev": true, + "requires": { + "estraverse": "4.2.0" + }, + "dependencies": { + "estraverse": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", + "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", + "dev": true + } + } + }, + "estraverse": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", + "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", + "dev": true + }, + "estraverse-fb": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/estraverse-fb/-/estraverse-fb-1.3.2.tgz", + "integrity": "sha1-0yOky15awzHOoDNBOpJT4WQ+B8Q=", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "event-emitter": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", + "integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=", + "dev": true, + "requires": { + "d": "1.0.0", + "es5-ext": "0.10.41" + } + }, + "event-stream": { + "version": "3.3.4", + "resolved": "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", + "requires": { + "duplexer": "0.1.1", + "from": "0.1.7", + "map-stream": "0.1.0", + "pause-stream": "0.0.11", + "split": "0.3.3", + "stream-combiner": "0.0.4", + "through": "2.3.8" + } + }, + "exit-hook": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", + "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", + "dev": true + }, + "extend": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend/-/extend-2.0.1.tgz", + "integrity": "sha1-HugBBonnOV/5RIJByYZSvHWagmA=", + "dev": true + }, + "fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "figures": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", + "integrity": "sha1-y+Hjr/zxzUS4DK3+0o3Hk6lwHS4=", + "dev": true, + "requires": { + "escape-string-regexp": "1.0.5", + "object-assign": "4.1.1" + } + }, + "file-entry-cache": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-1.3.1.tgz", + "integrity": "sha1-RMYepgeuS+nBQC9B9EJwy/4zT/g=", + "dev": true, + "requires": { + "flat-cache": "1.3.0", + "object-assign": "4.1.1" + } + }, + "find-root": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", + "integrity": "sha512-NKfW6bec6GfKc0SGx1e07QZY9PE99u0Bft/0rzSD5k3sO/vwkVUpDUKVm5Gpp5Ue3YfShPFTX2070tDs5kB9Ng==", + "dev": true + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "dev": true, + "requires": { + "path-exists": "2.1.0", + "pinkie-promise": "2.0.1" + } + }, + "flat-cache": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-1.3.0.tgz", + "integrity": "sha1-0wMLMrOBVPTjt+nHCfSQ9++XxIE=", + "dev": true, + "requires": { + "circular-json": "0.3.3", + "del": "2.2.2", + "graceful-fs": "4.1.11", + "write": "0.2.1" + } + }, + "foreach": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", + "dev": true + }, + "forever-agent": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.5.2.tgz", + "integrity": "sha1-bQ4JxJIflKJ/Y9O0nF/v8epMUTA=", + "dev": true + }, + "form-data": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-1.0.1.tgz", + "integrity": "sha1-rjFduaSQf6BlUCMEpm13M0de43w=", + "requires": { + "async": "2.6.0", + "combined-stream": "1.0.6", + "mime-types": "2.1.18" + }, + "dependencies": { + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "requires": { + "lodash": "4.17.5" + } + }, + "combined-stream": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", + "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=", + "requires": { + "delayed-stream": "1.0.0" + } + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + } + } + }, + "fresh-falafel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fresh-falafel/-/fresh-falafel-1.2.0.tgz", + "integrity": "sha1-WWbe6V+zXSopsS0vJRaLFyJeS2w=", + "dev": true, + "requires": { + "acorn": "1.2.2", + "foreach": "2.0.5", + "isarray": "0.0.1", + "object-keys": "1.0.11" + }, + "dependencies": { + "acorn": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-1.2.2.tgz", + "integrity": "sha1-yM4n3grMdtiW0rH6099YjZ6C8BQ=", + "dev": true + }, + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + } + } + }, + "from": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", + "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=" + }, + "fs-readdir-recursive": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-0.1.2.tgz", + "integrity": "sha1-MVtPuMHKW4xH3v7zGdBz2tNWgFk=", + "dev": true + }, + "fs-readfile-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fs-readfile-promise/-/fs-readfile-promise-2.0.1.tgz", + "integrity": "sha1-gAI4I5gfn//+AWCei+Zo9prknnA=", + "requires": { + "graceful-fs": "4.1.11" + } + }, + "fs-writefile-promise": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/fs-writefile-promise/-/fs-writefile-promise-1.0.3.tgz", + "integrity": "sha1-4C+bWP/CVe2CKtx6ARFPRF1I0GM=", + "requires": { + "mkdirp-promise": "1.1.0", + "pinkie-promise": "1.0.0" + }, + "dependencies": { + "pinkie": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-1.0.0.tgz", + "integrity": "sha1-Wkfyi6EBXQIBvae/DzWOR77Ix+Q=" + }, + "pinkie-promise": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-1.0.0.tgz", + "integrity": "sha1-0dpn9UglY7t89X8oauKCLs+/NnA=", + "requires": { + "pinkie": "1.0.0" + } + } + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "generate-function": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", + "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=" + }, + "generate-object-property": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", + "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", + "requires": { + "is-property": "1.0.2" + } + }, + "get-caller-file": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", + "integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=", + "dev": true + }, + "get-stdin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", + "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", + "dev": true + }, + "glob": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz", + "integrity": "sha1-DwiGD2oVUSey+t1PnOJLGqtuTSI=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "globals": { + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-8.18.0.tgz", + "integrity": "sha1-k9SmK9ysOM+vr8R9awNHaMsP/LQ=", + "dev": true + }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "dev": true, + "requires": { + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=" + }, + "growl": { + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", + "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "dev": true + }, + "handlebars": { + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", + "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", + "dev": true, + "requires": { + "async": "1.5.2", + "optimist": "0.6.1", + "source-map": "0.4.4", + "uglify-js": "2.8.29" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } + } + } + }, + "har-validator": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.1.3.tgz", + "integrity": "sha1-aP9JyFz7wrNPtC9kgKl5a2RB3PM=", + "requires": { + "chalk": "1.1.3", + "commander": "2.15.1", + "is-my-json-valid": "2.17.2" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "dev": true + }, + "hawk": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hawk/-/hawk-1.0.0.tgz", + "integrity": "sha1-uQuxaYByhUEdp//LjdJZhQLTtS0=", + "dev": true, + "optional": true, + "requires": { + "boom": "0.4.2", + "cryptiles": "0.2.2", + "hoek": "0.9.1", + "sntp": "0.2.4" + } + }, + "hoek": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-0.9.1.tgz", + "integrity": "sha1-PTIkYrrfB3Fup+uFuviAec3c5QU=", + "dev": true + }, + "home-or-tmp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/home-or-tmp/-/home-or-tmp-1.0.0.tgz", + "integrity": "sha1-S58eQIAMPlDGwn94FnavzOcfOYU=", + "dev": true, + "requires": { + "os-tmpdir": "1.0.2", + "user-home": "1.1.1" + }, + "dependencies": { + "user-home": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-1.1.1.tgz", + "integrity": "sha1-K1viOjK2Onyd640PKNSFcko98ZA=", + "dev": true + } + } + }, + "hosted-git-info": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", + "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==", + "dev": true + }, + "http-signature": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-0.10.1.tgz", + "integrity": "sha1-T72sEyVZqoMjEh5UB3nAoBKyfmY=", + "dev": true, + "optional": true, + "requires": { + "asn1": "0.1.11", + "assert-plus": "0.1.5", + "ctype": "0.5.3" + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", + "dev": true + }, + "ignore": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.7.tgz", + "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "dev": true + }, + "inquirer": { + "version": "0.11.4", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.11.4.tgz", + "integrity": "sha1-geM3ToNhvq/y2XAWIG01nQsy+k0=", + "dev": true, + "requires": { + "ansi-escapes": "1.4.0", + "ansi-regex": "2.1.1", + "chalk": "1.1.3", + "cli-cursor": "1.0.2", + "cli-width": "1.1.1", + "figures": "1.7.0", + "lodash": "3.10.1", + "readline2": "1.0.1", + "run-async": "0.1.0", + "rx-lite": "3.1.2", + "string-width": "1.0.2", + "strip-ansi": "3.0.1", + "through": "2.3.8" + }, + "dependencies": { + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true + } + } + }, + "invariant": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", + "integrity": "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA==", + "dev": true, + "requires": { + "loose-envify": "1.3.1" + } + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", + "dev": true + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, + "is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "is-builtin-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", + "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "dev": true, + "requires": { + "builtin-modules": "1.1.1" + } + }, + "is-finite": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-finite/-/is-finite-1.0.2.tgz", + "integrity": "sha1-zGZ3aVYCvlUO8R6LSqYwU0K20Ko=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "dev": true, + "requires": { + "number-is-nan": "1.0.1" + } + }, + "is-integer": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-integer/-/is-integer-1.0.7.tgz", + "integrity": "sha1-a96Bqs3feLZZtmKdYpytxRqIbVw=", + "dev": true, + "requires": { + "is-finite": "1.0.2" + } + }, + "is-my-ip-valid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz", + "integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==" + }, + "is-my-json-valid": { + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz", + "integrity": "sha512-IBhBslgngMQN8DDSppmgDv7RNrlFotuuDsKcrCP3+HbFaVivIBU7u9oiiErw8sH4ynx3+gOGQ3q2otkgiSi6kg==", + "requires": { + "generate-function": "2.0.0", + "generate-object-property": "1.2.0", + "is-my-ip-valid": "1.0.0", + "jsonpointer": "4.0.1", + "xtend": "4.0.1" + } + }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=", + "dev": true + }, + "is-path-in-cwd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz", + "integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==", + "dev": true, + "requires": { + "is-path-inside": "1.0.1" + } + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "dev": true, + "requires": { + "path-is-inside": "1.0.2" + } + }, + "is-property": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", + "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=" + }, + "is-resolvable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz", + "integrity": "sha512-qgDYXFSR5WvEfuS5dMj6oTMEbrrSaM0CrFk2Yiq/gXnBvD9pMa2jGXxyhGLfvhZpuMZe18CJpFxAt3CRs42NMg==", + "dev": true + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "istanbul": { + "version": "0.4.5", + "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", + "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", + "dev": true, + "requires": { + "abbrev": "1.0.9", + "async": "1.5.2", + "escodegen": "1.8.1", + "esprima": "2.7.3", + "glob": "5.0.15", + "handlebars": "4.0.11", + "js-yaml": "3.11.0", + "mkdirp": "0.5.1", + "nopt": "3.0.6", + "once": "1.4.0", + "resolve": "1.1.7", + "supports-color": "3.2.3", + "which": "1.3.0", + "wordwrap": "1.0.0" + }, + "dependencies": { + "async": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", + "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "dev": true + }, + "glob": { + "version": "5.0.15", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", + "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "dev": true, + "requires": { + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "dev": true, + "requires": { + "has-flag": "1.0.0" + } + } + } + }, + "jade": { + "version": "0.26.3", + "resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz", + "integrity": "sha1-jxDXl32NefL2/4YqgbBRPMslaGw=", + "dev": true, + "requires": { + "commander": "0.6.1", + "mkdirp": "0.3.0" + }, + "dependencies": { + "commander": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz", + "integrity": "sha1-+mihT2qUXVTbvlDYzbMyDp47GgY=", + "dev": true + }, + "mkdirp": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz", + "integrity": "sha1-G79asbqCevI1dRQ0kEJkVfSB/h4=", + "dev": true + } + } + }, + "js-beautify": { + "version": "1.7.5", + "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.7.5.tgz", + "integrity": "sha512-9OhfAqGOrD7hoQBLJMTA+BKuKmoEtTJXzZ7WDF/9gvjtey1koVLuZqIY6c51aPDjbNdNtIXAkiWKVhziawE9Og==", + "dev": true, + "requires": { + "config-chain": "1.1.11", + "editorconfig": "0.13.2", + "mkdirp": "0.5.1", + "nopt": "3.0.6" + } + }, + "js-tokens": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-1.0.1.tgz", + "integrity": "sha1-zENaXIuUrRWst5gxQPyAGCyJrq4=", + "dev": true + }, + "js-yaml": { + "version": "3.11.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.11.0.tgz", + "integrity": "sha512-saJstZWv7oNeOyBh3+Dx1qWzhW0+e6/8eDzo7p5rDFqxntSztloLtuKu+Ejhtq82jsilwOIZYsCz+lIjthg1Hw==", + "dev": true, + "requires": { + "argparse": "1.0.10", + "esprima": "4.0.0" + }, + "dependencies": { + "esprima": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", + "dev": true + } + } + }, + "jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "dev": true + }, + "json-stable-stringify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", + "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", + "dev": true, + "requires": { + "jsonify": "0.0.0" + } + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "json5": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-0.4.0.tgz", + "integrity": "sha1-BUNS5MTIDIbAkjh31EneF2pzLI0=", + "dev": true + }, + "jsonify": { + "version": "0.0.0", + "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", + "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", + "dev": true + }, + "jsonpointer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", + "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=" + }, + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } + }, + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "1.0.0" + } + }, + "lcov-parse": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/lcov-parse/-/lcov-parse-0.0.6.tgz", + "integrity": "sha1-gZ5dqL8HkfnT857qXtGGgYfxEXU=", + "dev": true + }, + "leven": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/leven/-/leven-1.0.2.tgz", + "integrity": "sha1-kUS27ryl8dBoAWnxpncNzqYLdcM=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2", + "type-check": "0.3.2" + } + }, + "lintspaces": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/lintspaces/-/lintspaces-0.4.1.tgz", + "integrity": "sha1-omZD63yUZIe65HYjBpskwDsJiHU=", + "dev": true, + "requires": { + "editorconfig": "0.13.2", + "merge": "1.1.2", + "rc": "1.1.6" + } + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "parse-json": "2.2.0", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "strip-bom": "2.0.0" + } + }, + "lodash": { + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==" + }, + "lodash._arraycopy": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._arraycopy/-/lodash._arraycopy-3.0.0.tgz", + "integrity": "sha1-due3wfH7klRzdIeKVi7Qaj5Q9uE=", + "dev": true + }, + "lodash._arrayeach": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._arrayeach/-/lodash._arrayeach-3.0.0.tgz", + "integrity": "sha1-urFWsqkNPxu9XGU0AzSeXlkz754=", + "dev": true + }, + "lodash._arraymap": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._arraymap/-/lodash._arraymap-3.0.0.tgz", + "integrity": "sha1-Go/Q9MDfS2HeoHbXF83Jfwo8PmY=", + "dev": true + }, + "lodash._baseassign": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", + "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash.keys": "3.1.2" + } + }, + "lodash._baseclone": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lodash._baseclone/-/lodash._baseclone-3.3.0.tgz", + "integrity": "sha1-MDUZv2OT/n5C802LYw73eU41Qrc=", + "dev": true, + "requires": { + "lodash._arraycopy": "3.0.0", + "lodash._arrayeach": "3.0.0", + "lodash._baseassign": "3.2.0", + "lodash._basefor": "3.0.3", + "lodash.isarray": "3.0.4", + "lodash.keys": "3.1.2" + } + }, + "lodash._basecopy": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", + "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", + "dev": true + }, + "lodash._basedifference": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash._basedifference/-/lodash._basedifference-3.0.3.tgz", + "integrity": "sha1-8sIEKWwqeOArOJCBtu3KyTPPYpw=", + "dev": true, + "requires": { + "lodash._baseindexof": "3.1.0", + "lodash._cacheindexof": "3.0.2", + "lodash._createcache": "3.1.2" + } + }, + "lodash._baseflatten": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/lodash._baseflatten/-/lodash._baseflatten-3.1.4.tgz", + "integrity": "sha1-B3D/gBMa9uNPO1EXlqe6UhTmX/c=", + "dev": true, + "requires": { + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "lodash._basefor": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash._basefor/-/lodash._basefor-3.0.3.tgz", + "integrity": "sha1-dVC06SGO8J+tJDQ7YSAhx5tMIMI=", + "dev": true + }, + "lodash._baseindexof": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz", + "integrity": "sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw=", + "dev": true + }, + "lodash._bindcallback": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz", + "integrity": "sha1-5THCdkTPi1epnhftlbNcdIeJOS4=", + "dev": true + }, + "lodash._cacheindexof": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz", + "integrity": "sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI=", + "dev": true + }, + "lodash._createassigner": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lodash._createassigner/-/lodash._createassigner-3.1.1.tgz", + "integrity": "sha1-g4pbri/aymOsIt7o4Z+k5taXCxE=", + "dev": true, + "requires": { + "lodash._bindcallback": "3.0.1", + "lodash._isiterateecall": "3.0.9", + "lodash.restparam": "3.6.1" + } + }, + "lodash._createcache": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash._createcache/-/lodash._createcache-3.1.2.tgz", + "integrity": "sha1-VtagZAF2JeeevKa4AY4XRAvc8JM=", + "dev": true, + "requires": { + "lodash._getnative": "3.9.1" + } + }, + "lodash._getnative": { + "version": "3.9.1", + "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", + "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", + "dev": true + }, + "lodash._isiterateecall": { + "version": "3.0.9", + "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", + "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", + "dev": true + }, + "lodash._pickbyarray": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/lodash._pickbyarray/-/lodash._pickbyarray-3.0.2.tgz", + "integrity": "sha1-H4mNlgfrVgsOFnOEt3x8bRCKpMU=", + "dev": true + }, + "lodash._pickbycallback": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash._pickbycallback/-/lodash._pickbycallback-3.0.0.tgz", + "integrity": "sha1-/2G5oBens699MObFPeKK+hm4dQo=", + "dev": true, + "requires": { + "lodash._basefor": "3.0.3", + "lodash.keysin": "3.0.8" + } + }, + "lodash.assign": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", + "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=", + "dev": true + }, + "lodash.clonedeep": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-3.0.2.tgz", + "integrity": "sha1-oKHkDYKl6on/WxR7hETtY9koJ9s=", + "dev": true, + "requires": { + "lodash._baseclone": "3.3.0", + "lodash._bindcallback": "3.0.1" + } + }, + "lodash.isarguments": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", + "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", + "dev": true + }, + "lodash.isarray": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", + "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", + "dev": true + }, + "lodash.isplainobject": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-3.2.0.tgz", + "integrity": "sha1-moI4rhayAEMpYM1zRlEtASP79MU=", + "dev": true, + "requires": { + "lodash._basefor": "3.0.3", + "lodash.isarguments": "3.1.0", + "lodash.keysin": "3.0.8" + } + }, + "lodash.istypedarray": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz", + "integrity": "sha1-yaR3SYYHUB2OhJTSg7h8OSgc72I=", + "dev": true + }, + "lodash.keys": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", + "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", + "dev": true, + "requires": { + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "lodash.keysin": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/lodash.keysin/-/lodash.keysin-3.0.8.tgz", + "integrity": "sha1-IsRJPrvtsUJ5YqVLRFssinZ/tH8=", + "dev": true, + "requires": { + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4" + } + }, + "lodash.merge": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-3.3.2.tgz", + "integrity": "sha1-DZDZPtY3sYeEN7s+IWASYNev6ZQ=", + "dev": true, + "requires": { + "lodash._arraycopy": "3.0.0", + "lodash._arrayeach": "3.0.0", + "lodash._createassigner": "3.1.1", + "lodash._getnative": "3.9.1", + "lodash.isarguments": "3.1.0", + "lodash.isarray": "3.0.4", + "lodash.isplainobject": "3.2.0", + "lodash.istypedarray": "3.0.6", + "lodash.keys": "3.1.2", + "lodash.keysin": "3.0.8", + "lodash.toplainobject": "3.0.0" + } + }, + "lodash.omit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/lodash.omit/-/lodash.omit-3.1.0.tgz", + "integrity": "sha1-iX/jguZBPZrJfGH3jtHgV6AK+fM=", + "dev": true, + "requires": { + "lodash._arraymap": "3.0.0", + "lodash._basedifference": "3.0.3", + "lodash._baseflatten": "3.1.4", + "lodash._bindcallback": "3.0.1", + "lodash._pickbyarray": "3.0.2", + "lodash._pickbycallback": "3.0.0", + "lodash.keysin": "3.0.8", + "lodash.restparam": "3.6.1" + } + }, + "lodash.restparam": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/lodash.restparam/-/lodash.restparam-3.6.1.tgz", + "integrity": "sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU=", + "dev": true + }, + "lodash.toplainobject": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/lodash.toplainobject/-/lodash.toplainobject-3.0.0.tgz", + "integrity": "sha1-KHkK2ULSk9eKpmOgfs9/UsoEGY0=", + "dev": true, + "requires": { + "lodash._basecopy": "3.0.1", + "lodash.keysin": "3.0.8" + } + }, + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true + }, + "loose-envify": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.3.1.tgz", + "integrity": "sha1-0aitM/qc4OcT1l/dCsi3SNR4yEg=", + "dev": true, + "requires": { + "js-tokens": "3.0.2" + }, + "dependencies": { + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true + } + } + }, + "lru-cache": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-3.2.0.tgz", + "integrity": "sha1-cXibO39Tmb7IVl3aOKow0qCX7+4=", + "dev": true, + "requires": { + "pseudomap": "1.0.2" + } + }, + "map-stream": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz", + "integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=" + }, + "merge": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/merge/-/merge-1.1.2.tgz", + "integrity": "sha1-Fq3OfE/Va6S9W52rlGkrHJ9e98g=", + "dev": true + }, + "mime": { + "version": "1.2.11", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.2.11.tgz", + "integrity": "sha1-WCA+7Ybjpe8XrtK32evUfwpg3RA=", + "dev": true + }, + "mime-db": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz", + "integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==" + }, + "mime-types": { + "version": "2.1.18", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.18.tgz", + "integrity": "sha512-lc/aahn+t4/SWV/qcmumYjymLsWfN3ELhpmVuUFjgsORruuZPVSwAQryq+HHGvO/SI2KVX26bx+En+zhM8g8hQ==", + "requires": { + "mime-db": "1.33.0" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "1.1.11" + } + }, + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + }, + "dependencies": { + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + } + } + }, + "mkdirp-promise": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mkdirp-promise/-/mkdirp-promise-1.1.0.tgz", + "integrity": "sha1-LISJPtZ24NmPsY+5piEv0bK5qBk=" + }, + "mocha": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-2.5.3.tgz", + "integrity": "sha1-FhvlvetJZ3HrmzV0UFC2IrWu/Fg=", + "dev": true, + "requires": { + "commander": "2.3.0", + "debug": "2.2.0", + "diff": "1.4.0", + "escape-string-regexp": "1.0.2", + "glob": "3.2.11", + "growl": "1.9.2", + "jade": "0.26.3", + "mkdirp": "0.5.1", + "supports-color": "1.2.0", + "to-iso-string": "0.0.2" + }, + "dependencies": { + "commander": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.3.0.tgz", + "integrity": "sha1-/UMOiJgy7DU7ms0d4hfBHLPu+HM=", + "dev": true + }, + "debug": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", + "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", + "dev": true, + "requires": { + "ms": "0.7.1" + } + }, + "escape-string-regexp": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.2.tgz", + "integrity": "sha1-Tbwv5nTnGUnK8/smlc5/LcHZqNE=", + "dev": true + }, + "glob": { + "version": "3.2.11", + "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", + "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", + "dev": true, + "requires": { + "inherits": "2.0.3", + "minimatch": "0.3.0" + } + }, + "lru-cache": { + "version": "2.7.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", + "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", + "dev": true + }, + "minimatch": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", + "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", + "dev": true, + "requires": { + "lru-cache": "2.7.3", + "sigmund": "1.0.1" + } + }, + "ms": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", + "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "dev": true + }, + "supports-color": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-1.2.0.tgz", + "integrity": "sha1-/x7R5hFp0Gs88tWI4YixjYhH4X4=", + "dev": true + } + } + }, + "mout": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/mout/-/mout-1.1.0.tgz", + "integrity": "sha512-XsP0vf4As6BfqglxZqbqQ8SR6KQot2AgxvR0gG+WtUkf90vUXchMOZQtPf/Hml1rEffJupqL/tIrU6EYhsUQjw==", + "dev": true + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "multiline": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/multiline/-/multiline-1.0.2.tgz", + "integrity": "sha1-abHyX/B00oKJBPJE3dBrfZbvbJM=", + "dev": true, + "requires": { + "strip-indent": "1.0.1" + } + }, + "mute-stream": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.5.tgz", + "integrity": "sha1-j7+rsKmKJT0xhDMfno3rc3L6xsA=", + "dev": true + }, + "next-tick": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz", + "integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=", + "dev": true + }, + "node-uuid": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", + "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=", + "dev": true + }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "dev": true, + "requires": { + "abbrev": "1.0.9" + } + }, + "normalize-package-data": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", + "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "dev": true, + "requires": { + "hosted-git-info": "2.6.0", + "is-builtin-module": "1.0.0", + "semver": "5.5.0", + "validate-npm-package-license": "3.0.3" + } + }, + "npm-path": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/npm-path/-/npm-path-1.1.0.tgz", + "integrity": "sha1-BHSuAEGcMn1UcBt88s0F3Ii+EUA=", + "dev": true, + "requires": { + "which": "1.3.0" + } + }, + "npm-run": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/npm-run/-/npm-run-2.0.0.tgz", + "integrity": "sha1-KN/ArV4uRv4ISOK9WN3wAue3PBU=", + "dev": true, + "requires": { + "minimist": "1.2.0", + "npm-path": "1.1.0", + "npm-which": "2.0.0", + "serializerr": "1.0.3", + "spawn-sync": "1.0.15", + "sync-exec": "0.5.0" + } + }, + "npm-which": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/npm-which/-/npm-which-2.0.0.tgz", + "integrity": "sha1-DEaYIWC3gwk2YdHQG9RJbS/qu6w=", + "dev": true, + "requires": { + "commander": "2.15.1", + "npm-path": "1.1.0", + "which": "1.3.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "oauth-sign": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.3.0.tgz", + "integrity": "sha1-y1QPk7srIqfVlBaRoojWDo6pOG4=", + "dev": true, + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "object-keys": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz", + "integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=", + "dev": true + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1.0.2" + } + }, + "onetime": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", + "dev": true, + "requires": { + "minimist": "0.0.10", + "wordwrap": "0.0.3" + }, + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + } + } + }, + "optionator": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", + "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "dev": true, + "requires": { + "deep-is": "0.1.3", + "fast-levenshtein": "2.0.6", + "levn": "0.3.0", + "prelude-ls": "1.1.2", + "type-check": "0.3.2", + "wordwrap": "1.0.0" + } + }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", + "dev": true + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "dev": true, + "requires": { + "lcid": "1.0.0" + } + }, + "os-shim": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/os-shim/-/os-shim-0.1.3.tgz", + "integrity": "sha1-a2LDeRz3kJ6jXtRuF2WLtBfLORc=", + "dev": true + }, + "os-tmpdir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true + }, + "output-file-sync": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/output-file-sync/-/output-file-sync-1.1.2.tgz", + "integrity": "sha1-0KM+7+YaIF+suQCS6CZZjVJFznY=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "mkdirp": "0.5.1", + "object-assign": "4.1.1" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "1.3.1" + } + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "dev": true, + "requires": { + "pinkie-promise": "2.0.1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } + }, + "pause-stream": { + "version": "0.0.11", + "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", + "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", + "requires": { + "through": "2.3.8" + } + }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "2.0.4" + } + }, + "pkg-config": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/pkg-config/-/pkg-config-1.1.1.tgz", + "integrity": "sha1-VX7yLXPaPIg3EHdmxS6tq94pj+Q=", + "dev": true, + "requires": { + "debug-log": "1.0.1", + "find-root": "1.1.0", + "xtend": "4.0.1" + } + }, + "prelude-ls": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", + "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", + "dev": true + }, + "private": { + "version": "0.1.8", + "resolved": "https://registry.npmjs.org/private/-/private-0.1.8.tgz", + "integrity": "sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg==", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "proto-list": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/proto-list/-/proto-list-1.2.4.tgz", + "integrity": "sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=", + "dev": true + }, + "protochain": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/protochain/-/protochain-1.0.5.tgz", + "integrity": "sha1-mRxAfpneJkqt+PgVBLXn+ve/omA=", + "dev": true + }, + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true, + "optional": true + }, + "q": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", + "integrity": "sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=", + "dev": true + }, + "qs": { + "version": "0.6.6", + "resolved": "https://registry.npmjs.org/qs/-/qs-0.6.6.tgz", + "integrity": "sha1-bgFQmP9RlouKPIGQAdXyyJvEsQc=", + "dev": true + }, + "rc": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/rc/-/rc-1.1.6.tgz", + "integrity": "sha1-Q2UbdrauU7XIAvEVH6P8OwWZack=", + "dev": true, + "requires": { + "deep-extend": "0.4.2", + "ini": "1.3.5", + "minimist": "1.2.0", + "strip-json-comments": "1.0.4" + } + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "dev": true, + "requires": { + "load-json-file": "1.1.0", + "normalize-package-data": "2.4.0", + "path-type": "1.1.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "dev": true, + "requires": { + "find-up": "1.1.2", + "read-pkg": "1.1.0" + } + }, + "readable-stream": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.5.tgz", + "integrity": "sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==", + "dev": true, + "requires": { + "core-util-is": "1.0.2", + "inherits": "2.0.3", + "isarray": "1.0.0", + "process-nextick-args": "2.0.0", + "safe-buffer": "5.1.1", + "string_decoder": "1.0.3", + "util-deprecate": "1.0.2" + } + }, + "readline2": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/readline2/-/readline2-1.0.1.tgz", + "integrity": "sha1-QQWWCP/BVHV7cV2ZidGZ/783LjU=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "mute-stream": "0.0.5" + } + }, + "recast": { + "version": "0.10.33", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.10.33.tgz", + "integrity": "sha1-lCgI96oBbx+nFCxGHX5XBKqo1pc=", + "dev": true, + "requires": { + "ast-types": "0.8.12", + "esprima-fb": "15001.1001.0-dev-harmony-fb", + "private": "0.1.8", + "source-map": "0.5.7" + }, + "dependencies": { + "ast-types": { + "version": "0.8.12", + "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.8.12.tgz", + "integrity": "sha1-oNkOQ1G7iHcWyD/WN+v4GK9K38w=", + "dev": true + }, + "esprima-fb": { + "version": "15001.1001.0-dev-harmony-fb", + "resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-15001.1001.0-dev-harmony-fb.tgz", + "integrity": "sha1-Q761fsJujPI3092LM+QlM1d/Jlk=", + "dev": true + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true + } + } + }, + "regenerate": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.3.3.tgz", + "integrity": "sha512-jVpo1GadrDAK59t/0jRx5VxYWQEDkkEKi6+HjE3joFVLfDOh9Xrdh0dF1eSq+BI/SwvTQ44gSscJ8N5zYL61sg==", + "dev": true + }, + "regenerator": { + "version": "0.8.40", + "resolved": "https://registry.npmjs.org/regenerator/-/regenerator-0.8.40.tgz", + "integrity": "sha1-oORXxY69uuV1yfjNdRJ+k3VkNdg=", + "dev": true, + "requires": { + "commoner": "0.10.8", + "defs": "1.1.1", + "esprima-fb": "15001.1001.0-dev-harmony-fb", + "private": "0.1.8", + "recast": "0.10.33", + "through": "2.3.8" + }, + "dependencies": { + "esprima-fb": { + "version": "15001.1001.0-dev-harmony-fb", + "resolved": "https://registry.npmjs.org/esprima-fb/-/esprima-fb-15001.1001.0-dev-harmony-fb.tgz", + "integrity": "sha1-Q761fsJujPI3092LM+QlM1d/Jlk=", + "dev": true + } + } + }, + "regenerator-runtime": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true + }, + "regexpu": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/regexpu/-/regexpu-1.3.0.tgz", + "integrity": "sha1-5TTcmRqeWEYFDJjebX3UpVyeoW0=", + "dev": true, + "requires": { + "esprima": "2.7.3", + "recast": "0.10.33", + "regenerate": "1.3.3", + "regjsgen": "0.2.0", + "regjsparser": "0.1.5" + } + }, + "regjsgen": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.2.0.tgz", + "integrity": "sha1-bAFq3qxVT3WCP+N6wFuS1aTtsfc=", + "dev": true + }, + "regjsparser": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.1.5.tgz", + "integrity": "sha1-fuj4Tcb6eS0/0K4ijSS9lJ6tIFw=", + "dev": true, + "requires": { + "jsesc": "0.5.0" + } + }, + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true + }, + "repeating": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz", + "integrity": "sha1-PUEUIYh3U3SU+X93+Xhfq4EPpKw=", + "dev": true, + "requires": { + "is-finite": "1.0.2" + } + }, + "request": { + "version": "2.34.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.34.0.tgz", + "integrity": "sha1-tdi5UmrdSi1GKfTUFxJFc5lkRa4=", + "dev": true, + "requires": { + "aws-sign2": "0.5.0", + "forever-agent": "0.5.2", + "form-data": "0.1.4", + "hawk": "1.0.0", + "http-signature": "0.10.1", + "json-stringify-safe": "5.0.1", + "mime": "1.2.11", + "node-uuid": "1.4.8", + "oauth-sign": "0.3.0", + "qs": "0.6.6", + "tough-cookie": "2.3.4", + "tunnel-agent": "0.3.0" + }, + "dependencies": { + "async": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", + "dev": true, + "optional": true + }, + "form-data": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-0.1.4.tgz", + "integrity": "sha1-kavXiKupcCsaq/qLwBAxoqyeOxI=", + "dev": true, + "optional": true, + "requires": { + "async": "0.9.2", + "combined-stream": "0.0.7", + "mime": "1.2.11" + } + } + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", + "dev": true + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", + "dev": true + }, + "resolve": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "dev": true + }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true, + "requires": { + "exit-hook": "1.1.1", + "onetime": "1.1.0" + } + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "requires": { + "align-text": "0.1.4" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "dev": true, + "requires": { + "glob": "7.1.2" + }, + "dependencies": { + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } + } + } + }, + "rocambole": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/rocambole/-/rocambole-0.7.0.tgz", + "integrity": "sha1-9seVBVF9xCtvuECEK4uVOw+WhYU=", + "dev": true, + "requires": { + "esprima": "2.7.3" + } + }, + "rocambole-indent": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/rocambole-indent/-/rocambole-indent-2.0.4.tgz", + "integrity": "sha1-oYokl3ygQAuGHapGMehh3LUtCFw=", + "dev": true, + "requires": { + "debug": "2.6.9", + "mout": "0.11.1", + "rocambole-token": "1.2.1" + }, + "dependencies": { + "mout": { + "version": "0.11.1", + "resolved": "https://registry.npmjs.org/mout/-/mout-0.11.1.tgz", + "integrity": "sha1-ujYR318OWx/7/QEWa48C0fX6K5k=", + "dev": true + } + } + }, + "rocambole-linebreak": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/rocambole-linebreak/-/rocambole-linebreak-1.0.2.tgz", + "integrity": "sha1-A2IVFbQ7RyHJflocG8paA2Y2jy8=", + "dev": true, + "requires": { + "debug": "2.6.9", + "rocambole-token": "1.2.1", + "semver": "4.3.6" + }, + "dependencies": { + "semver": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-4.3.6.tgz", + "integrity": "sha1-MAvG4OhjdPe6YQaLWx7NV/xlMto=", + "dev": true + } + } + }, + "rocambole-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/rocambole-node/-/rocambole-node-1.0.0.tgz", + "integrity": "sha1-21tJ3nQHsAgN1RSHLyjjk9D3/z8=", + "dev": true + }, + "rocambole-token": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/rocambole-token/-/rocambole-token-1.2.1.tgz", + "integrity": "sha1-x4XfdCjcPLJ614lwR71SOMwHDTU=", + "dev": true + }, + "rocambole-whitespace": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/rocambole-whitespace/-/rocambole-whitespace-1.0.0.tgz", + "integrity": "sha1-YzMJSSVrKZQfWbGQRZ+ZnGsdO/k=", + "dev": true, + "requires": { + "debug": "2.6.9", + "repeat-string": "1.6.1", + "rocambole-token": "1.2.1" + } + }, + "run-async": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-0.1.0.tgz", + "integrity": "sha1-yK1KXhEGYeQCp9IbUw4AnyX444k=", + "dev": true, + "requires": { + "once": "1.4.0" + } + }, + "run-parallel": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.8.tgz", + "integrity": "sha512-e5t1NVhr5VWmD9V9U4KjjSGkf5w6CcTPgw11A3CfIvkkQxlAKzX3usPUp1NUQTmpOOjU+f9QRICU3tMbKwn9ZQ==", + "dev": true + }, + "rx-lite": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-3.1.2.tgz", + "integrity": "sha1-Gc5QLKVyZl87ZHsQk5+X/RYV8QI=", + "dev": true + }, + "safe-buffer": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", + "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", + "dev": true + }, + "semver": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", + "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", + "dev": true + }, + "serializerr": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/serializerr/-/serializerr-1.0.3.tgz", + "integrity": "sha1-EtTFqhw/+49tHcXzlaqUVVacP5E=", + "dev": true, + "requires": { + "protochain": "1.0.5" + } + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", + "dev": true + }, + "shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true + }, + "shelljs": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.5.3.tgz", + "integrity": "sha1-xUmCuZbHbvDB5rWfvcWCX1txMRM=", + "dev": true + }, + "should": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/should/-/should-7.1.1.tgz", + "integrity": "sha1-ZGTEi298Hh8YrASDV4+i3VXCxuA=", + "dev": true, + "requires": { + "should-equal": "0.5.0", + "should-format": "0.3.1", + "should-type": "0.2.0" + } + }, + "should-equal": { + "version": "0.5.0", + "resolved": "http://registry.npmjs.org/should-equal/-/should-equal-0.5.0.tgz", + "integrity": "sha1-x5fxNfMGf+tp6+zbMGscP+IbPm8=", + "dev": true, + "requires": { + "should-type": "0.2.0" + } + }, + "should-format": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/should-format/-/should-format-0.3.1.tgz", + "integrity": "sha1-LLt4JGFnCs5CkrKx7EaNuM+Z4zA=", + "dev": true, + "requires": { + "should-type": "0.2.0" + } + }, + "should-type": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/should-type/-/should-type-0.2.0.tgz", + "integrity": "sha1-ZwfvlVKdmJ3MCY/gdTqx+RNrt/Y=", + "dev": true + }, + "sigmund": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", + "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", + "dev": true + }, + "simple-fmt": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/simple-fmt/-/simple-fmt-0.1.0.tgz", + "integrity": "sha1-GRv1ZqWeZTBILLJatTtKjchcOms=", + "dev": true + }, + "simple-is": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/simple-is/-/simple-is-0.2.0.tgz", + "integrity": "sha1-Krt1qt453rXMgVzhDmGRFkhQuvA=", + "dev": true + }, + "slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", + "dev": true + }, + "sntp": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/sntp/-/sntp-0.2.4.tgz", + "integrity": "sha1-+4hfGLDzqtGJ+CSGJTa87ux1CQA=", + "dev": true, + "optional": true, + "requires": { + "hoek": "0.9.1" + } + }, + "source-map": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", + "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "dev": true, + "optional": true, + "requires": { + "amdefine": "1.0.1" + } + }, + "source-map-support": { + "version": "0.2.10", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.2.10.tgz", + "integrity": "sha1-6lo5AKHByyUJagrozFwrSxDe09w=", + "dev": true, + "requires": { + "source-map": "0.1.32" + }, + "dependencies": { + "source-map": { + "version": "0.1.32", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.32.tgz", + "integrity": "sha1-yLbBZ3l7pHQKjqMyUhYv8IWRsmY=", + "dev": true, + "requires": { + "amdefine": "1.0.1" + } + } + } + }, + "spawn-sync": { + "version": "1.0.15", + "resolved": "https://registry.npmjs.org/spawn-sync/-/spawn-sync-1.0.15.tgz", + "integrity": "sha1-sAeZVX63+wyDdsKdROih6mfldHY=", + "dev": true, + "requires": { + "concat-stream": "1.6.2", + "os-shim": "0.1.3" + } + }, + "spdx-correct": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", + "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "dev": true, + "requires": { + "spdx-expression-parse": "3.0.0", + "spdx-license-ids": "3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", + "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, + "requires": { + "spdx-exceptions": "2.1.0", + "spdx-license-ids": "3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", + "dev": true + }, + "split": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz", + "integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=", + "requires": { + "through": "2.3.8" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "stable": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.6.tgz", + "integrity": "sha1-kQ9dKu17Ugxud3SZwfMuE5/eyxA=", + "dev": true + }, + "standard": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/standard/-/standard-5.4.1.tgz", + "integrity": "sha1-LwE5ErJ5Tdswu6qJ3BP7OpkMxys=", + "dev": true, + "requires": { + "eslint-config-standard": "4.4.0", + "eslint-config-standard-react": "1.2.1", + "eslint-plugin-react": "3.16.1", + "eslint-plugin-standard": "1.3.3", + "standard-engine": "2.2.5", + "standard-format": "1.6.10" + } + }, + "standard-engine": { + "version": "2.2.5", + "resolved": "https://registry.npmjs.org/standard-engine/-/standard-engine-2.2.5.tgz", + "integrity": "sha1-ornUQZ9kiiIbjReCP7dFQG83w04=", + "dev": true, + "requires": { + "defaults": "1.0.3", + "deglob": "1.1.2", + "dezalgo": "1.0.3", + "eslint": "1.9.0", + "find-root": "0.1.2", + "get-stdin": "4.0.1", + "minimist": "1.2.0", + "multiline": "1.0.2", + "pkg-config": "1.1.1", + "xtend": "4.0.1" + }, + "dependencies": { + "find-root": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/find-root/-/find-root-0.1.2.tgz", + "integrity": "sha1-mNImfP8ZFsyvJ0OzoO6oHXnX3NE=", + "dev": true + } + } + }, + "standard-format": { + "version": "1.6.10", + "resolved": "https://registry.npmjs.org/standard-format/-/standard-format-1.6.10.tgz", + "integrity": "sha1-sYPI+DfI05OHmPPQlD5dgHoboD8=", + "dev": true, + "requires": { + "deglob": "1.1.2", + "esformatter": "0.8.2", + "esformatter-eol-last": "1.0.0", + "esformatter-jsx": "2.3.11", + "esformatter-literal-notation": "1.0.1", + "esformatter-quotes": "1.1.0", + "esformatter-semicolon-first": "1.2.0", + "esformatter-spaced-lined-comment": "2.0.1", + "minimist": "1.2.0", + "stdin": "0.0.1" + } + }, + "stdin": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/stdin/-/stdin-0.0.1.tgz", + "integrity": "sha1-0wQZgarsPf28d6GzjWNy449ftx4=", + "dev": true + }, + "stream-combiner": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz", + "integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=", + "requires": { + "duplexer": "0.1.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "dev": true, + "requires": { + "code-point-at": "1.1.0", + "is-fullwidth-code-point": "1.0.0", + "strip-ansi": "3.0.1" + } + }, + "string.prototype.endswith": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/string.prototype.endswith/-/string.prototype.endswith-0.2.0.tgz", + "integrity": "sha1-oZwg3uUamHd+mkfhDwm+OTubunU=", + "dev": true + }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, + "stringmap": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/stringmap/-/stringmap-0.2.2.tgz", + "integrity": "sha1-VWwTeyWPlCuHdvWy71gqoGnX0bE=", + "dev": true + }, + "stringset": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/stringset/-/stringset-0.2.1.tgz", + "integrity": "sha1-7yWcTjSTRDd/zRyRPdLoSMnAQrU=", + "dev": true + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "2.1.1" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "dev": true, + "requires": { + "is-utf8": "0.2.1" + } + }, + "strip-indent": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", + "integrity": "sha1-DHlipq3vp7vUrDZkYKY4VSrhoKI=", + "dev": true, + "requires": { + "get-stdin": "4.0.1" + } + }, + "strip-json-comments": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", + "integrity": "sha1-HhX7ysl9Pumb8tc7TGVrCCu6+5E=", + "dev": true + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + }, + "sync-exec": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/sync-exec/-/sync-exec-0.5.0.tgz", + "integrity": "sha1-P3JY5KW6FyRTgZCfpqb2z1BuFmE=", + "dev": true + }, + "text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + }, + "to-double-quotes": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-double-quotes/-/to-double-quotes-2.0.0.tgz", + "integrity": "sha1-qvIx1vqUiUn4GTAburRITYWI5Kc=", + "dev": true + }, + "to-fast-properties": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-1.0.3.tgz", + "integrity": "sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=", + "dev": true + }, + "to-iso-string": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/to-iso-string/-/to-iso-string-0.0.2.tgz", + "integrity": "sha1-TcGeZk38y+Jb2NtQiwDG2hWCVdE=", + "dev": true + }, + "to-single-quotes": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/to-single-quotes/-/to-single-quotes-2.0.1.tgz", + "integrity": "sha1-fMKRUfD18sQZRvEZ9ZMv5VQXASU=", + "dev": true + }, + "tough-cookie": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", + "dev": true, + "optional": true, + "requires": { + "punycode": "1.4.1" + } + }, + "trim-right": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", + "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", + "dev": true + }, + "try-resolve": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/try-resolve/-/try-resolve-1.0.1.tgz", + "integrity": "sha1-z95vq9ctY+V5fPqrhzq76OcA6RI=", + "dev": true + }, + "tryor": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/tryor/-/tryor-0.1.2.tgz", + "integrity": "sha1-gUXkynyv9ArN48z5Rui4u3W0Fys=", + "dev": true + }, + "tunnel-agent": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.3.0.tgz", + "integrity": "sha1-rWgbaPUyGtKCfEz7G31d8s/pQu4=", + "dev": true, + "optional": true + }, + "type-check": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", + "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", + "dev": true, + "requires": { + "prelude-ls": "1.1.2" + } + }, + "typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", + "dev": true, + "optional": true, + "requires": { + "source-map": "0.5.7", + "uglify-to-browserify": "1.0.2", + "yargs": "3.10.0" + }, + "dependencies": { + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", + "dev": true, + "optional": true + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "dev": true, + "optional": true, + "requires": { + "center-align": "0.1.3", + "right-align": "0.1.3", + "wordwrap": "0.0.2" + } + }, + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true, + "optional": true + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true, + "optional": true + }, + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true, + "optional": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "optional": true, + "requires": { + "camelcase": "1.2.1", + "cliui": "2.1.0", + "decamelize": "1.2.0", + "window-size": "0.1.0" + } + } + } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "uniq": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", + "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", + "dev": true + }, + "user-home": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", + "integrity": "sha1-nHC/2Babwdy/SGBODwS4tJzenp8=", + "dev": true, + "requires": { + "os-homedir": "1.0.2" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "validate-npm-package-license": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", + "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", + "dev": true, + "requires": { + "spdx-correct": "3.0.0", + "spdx-expression-parse": "3.0.0" + } + }, + "which": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", + "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "dev": true, + "requires": { + "isexe": "2.0.0" + } + }, + "which-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=", + "dev": true + }, + "window-size": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.2.0.tgz", + "integrity": "sha1-tDFbtCFKPXBY6+7okuE/ok2YsHU=", + "dev": true + }, + "wordwrap": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", + "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "dev": true + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "dev": true, + "requires": { + "string-width": "1.0.2", + "strip-ansi": "3.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "write": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/write/-/write-0.2.1.tgz", + "integrity": "sha1-X8A4KOJkzqP+kUVUdvejxWbLB1c=", + "dev": true, + "requires": { + "mkdirp": "0.5.1" + } + }, + "xml-escape": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/xml-escape/-/xml-escape-1.0.0.tgz", + "integrity": "sha1-AJY9aXsq3wwYXE4E5zF0upsojrI=", + "dev": true + }, + "xtend": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", + "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + }, + "y18n": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", + "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", + "dev": true + }, + "yargs": { + "version": "4.8.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-4.8.1.tgz", + "integrity": "sha1-wMQpJMpKqmsObaFznfshZDn53cA=", + "dev": true, + "requires": { + "cliui": "3.2.0", + "decamelize": "1.2.0", + "get-caller-file": "1.0.2", + "lodash.assign": "4.2.0", + "os-locale": "1.4.0", + "read-pkg-up": "1.0.1", + "require-directory": "2.1.1", + "require-main-filename": "1.0.1", + "set-blocking": "2.0.0", + "string-width": "1.0.2", + "which-module": "1.0.0", + "window-size": "0.2.0", + "y18n": "3.2.1", + "yargs-parser": "2.4.1" + } + }, + "yargs-parser": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-2.4.1.tgz", + "integrity": "sha1-hVaN488VD/SfpRgl8DqMiA3cxcQ=", + "dev": true, + "requires": { + "camelcase": "3.0.0", + "lodash.assign": "4.2.0" + } + } + } +} diff --git a/packages/insomnia-httpsnippet/package.json b/packages/insomnia-httpsnippet/package.json new file mode 100755 index 0000000000..68508abadb --- /dev/null +++ b/packages/insomnia-httpsnippet/package.json @@ -0,0 +1,89 @@ +{ + "version": "1.16.5", + "name": "insomnia-httpsnippet", + "description": "HTTP Request snippet generator for *most* languages", + "author": "Gregory Schier ", + "homepage": "https://github.com/getinsomnia/httpsnippet", + "license": "MIT", + "main": "src/index.js", + "bin": "bin/httpsnippet", + "keywords": [ + "api", + "csharp", + "curl", + "go", + "har", + "http", + "httpie", + "java", + "javascript", + "jquery", + "objc", + "objective-c", + "ocaml", + "php", + "python", + "request", + "requests", + "ruby", + "shell", + "snippet", + "swift", + "swift", + "unirest", + "xhr", + "xmlhttprequest" + ], + "engines": { + "node": ">=0.10" + }, + "files": [ + "bin", + "src" + ], + "repository": "Mashape/httpsnippet", + "bugs": { + "url": "https://github.com/Mashape/httpsnippet/issues" + }, + "scripts": { + "quick": "mocha --no-timeouts --fgrep 'Request Validation' --invert", + "pretest": "standard && echint", + "__test": "mocha --no-timeouts", + "posttest": "npm run coverage", + "coverage": "istanbul cover --dir coverage _mocha -- --fgrep 'Request Validation' --invert -R dot", + "codeclimate": "codeclimate < coverage/lcov.info" + }, + "standard": { + "ignore": [ + "**/test/fixtures/**" + ] + }, + "echint": { + "ignore": [ + "coverage/**", + "CONTRIBUTING.md", + "test/fixtures/**" + ] + }, + "devDependencies": { + "codeclimate-test-reporter": "0.1.1", + "echint": "^1.5.0", + "glob": "^6.0.1", + "istanbul": "^0.4.0", + "mocha": "^2.3.4", + "require-directory": "^2.1.1", + "should": "^7.1.1", + "standard": "^5.4.1" + }, + "dependencies": { + "chalk": "^1.1.1", + "commander": "^2.9.0", + "debug": "^2.2.0", + "event-stream": "^3.3.2", + "form-data": "^1.0.0-rc3", + "fs-readfile-promise": "^2.0.1", + "fs-writefile-promise": "^1.0.3", + "har-validator": "^2.0.2", + "pinkie-promise": "^2.0.0" + } +} diff --git a/packages/insomnia-httpsnippet/src/helpers/code-builder.js b/packages/insomnia-httpsnippet/src/helpers/code-builder.js new file mode 100755 index 0000000000..335ea34c04 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/helpers/code-builder.js @@ -0,0 +1,103 @@ +'use strict' + +var util = require('util') + +/** + * Helper object to format and aggragate lines of code. + * Lines are aggregated in a `code` array, and need to be joined to obtain a proper code snippet. + * + * @class + * + * @param {string} indentation Desired indentation character for aggregated lines of code + * @param {string} join Desired character to join each line of code + */ +var CodeBuilder = function (indentation, join) { + this.code = [] + this.indentation = indentation + this.lineJoin = join || '\n' +} + +/** + * Add given indentation level to given string and format the string (variadic) + * @param {number} [indentationLevel=0] - Desired level of indentation for this line + * @param {string} line - Line of code. Can contain formatting placeholders + * @param {...anyobject} - Parameter to bind to `line`'s formatting placeholders + * @return {string} + * + * @example + * var builder = CodeBuilder('\t') + * + * builder.buildLine('console.log("hello world")') + * // returns: 'console.log("hello world")' + * + * builder.buildLine(2, 'console.log("hello world")') + * // returns: 'console.log("\t\thello world")' + * + * builder.buildLine(2, 'console.log("%s %s")', 'hello', 'world') + * // returns: 'console.log("\t\thello world")' + */ +CodeBuilder.prototype.buildLine = function (indentationLevel, line) { + var lineIndentation = '' + var slice = 2 + if (Object.prototype.toString.call(indentationLevel) === '[object String]') { + slice = 1 + line = indentationLevel + indentationLevel = 0 + } else if (indentationLevel === null) { + return null + } + + while (indentationLevel) { + lineIndentation += this.indentation + indentationLevel-- + } + + var format = Array.prototype.slice.call(arguments, slice, arguments.length) + format.unshift(lineIndentation + line) + + return util.format.apply(this, format) +} + +/** + * Invoke buildLine() and add the line at the top of current lines + * @param {number} [indentationLevel=0] Desired level of indentation for this line + * @param {string} line Line of code + * @return {this} + */ +CodeBuilder.prototype.unshift = function () { + this.code.unshift(this.buildLine.apply(this, arguments)) + + return this +} + +/** + * Invoke buildLine() and add the line at the bottom of current lines + * @param {number} [indentationLevel=0] Desired level of indentation for this line + * @param {string} line Line of code + * @return {this} + */ +CodeBuilder.prototype.push = function () { + this.code.push(this.buildLine.apply(this, arguments)) + + return this +} + +/** + * Add an empty line at the end of current lines + * @return {this} + */ +CodeBuilder.prototype.blank = function () { + this.code.push(null) + + return this +} + +/** + * Concatenate all current lines using the given lineJoin + * @return {string} + */ +CodeBuilder.prototype.join = function () { + return this.code.join(this.lineJoin) +} + +module.exports = CodeBuilder diff --git a/packages/insomnia-httpsnippet/src/helpers/reducer.js b/packages/insomnia-httpsnippet/src/helpers/reducer.js new file mode 100755 index 0000000000..2b961059cf --- /dev/null +++ b/packages/insomnia-httpsnippet/src/helpers/reducer.js @@ -0,0 +1,23 @@ +'use strict' + +module.exports = function (obj, pair) { + if (obj[pair.name] === undefined) { + obj[pair.name] = pair.value + return obj + } + + if (Array.isArray(obj[pair.name])) { + obj[pair.name].push(pair.value) + return obj + } + + // convert to array + var arr = [ + obj[pair.name], + pair.value + ] + + obj[pair.name] = arr + + return obj +} diff --git a/packages/insomnia-httpsnippet/src/helpers/shell.js b/packages/insomnia-httpsnippet/src/helpers/shell.js new file mode 100755 index 0000000000..12b155b1a4 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/helpers/shell.js @@ -0,0 +1,25 @@ +'use strict' + +var util = require('util') + +module.exports = { + /** + * Use 'strong quoting' using single quotes so that we only need + * to deal with nested single quote characters. + * http://wiki.bash-hackers.org/syntax/quoting#strong_quoting + */ + quote: function (value) { + var safe = /^[a-z0-9-_/.@%^=:]+$/i + + // Unless `value` is a simple shell-safe string, quote it. + if (!safe.test(value)) { + return util.format('\'%s\'', value.replace(/'/g, "\'\\'\'")) + } + + return value + }, + + escape: function (value) { + return value.replace(/\r/g, '\\r').replace(/\n/g, '\\n') + } +} diff --git a/packages/insomnia-httpsnippet/src/index.js b/packages/insomnia-httpsnippet/src/index.js new file mode 100755 index 0000000000..0c6cf1bd65 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/index.js @@ -0,0 +1,248 @@ +'use strict' + +var debug = require('debug')('httpsnippet') +var es = require('event-stream') +var MultiPartForm = require('form-data') +var qs = require('querystring') +var reducer = require('./helpers/reducer') +var targets = require('./targets') +var url = require('url') +var util = require('util') +var validate = require('har-validator/lib/async') + +// constructor +var HTTPSnippet = function (data) { + var entries + var self = this + var input = util._extend({}, data) + + // prep the main container + self.requests = [] + + // is it har? + if (input.log && input.log.entries) { + entries = input.log.entries + } else { + entries = [{ + request: input + }] + } + + entries.forEach(function (entry) { + // add optional properties to make validation successful + entry.request.httpVersion = entry.request.httpVersion || 'HTTP/1.1' + entry.request.queryString = entry.request.queryString || [] + entry.request.headers = entry.request.headers || [] + entry.request.cookies = entry.request.cookies || [] + entry.request.postData = entry.request.postData || {} + entry.request.postData.mimeType = entry.request.postData.mimeType || 'application/octet-stream' + + entry.request.bodySize = 0 + entry.request.headersSize = 0 + entry.request.postData.size = 0 + + validate.request(entry.request, function (err, valid) { + if (!valid) { + throw err + } + + self.requests.push(self.prepare(entry.request)) + }) + }) +} + +HTTPSnippet.prototype.prepare = function (request) { + // construct utility properties + request.queryObj = {} + request.headersObj = {} + request.cookiesObj = {} + request.allHeaders = {} + request.postData.jsonObj = false + request.postData.paramsObj = false + + // construct query objects + if (request.queryString && request.queryString.length) { + debug('queryString found, constructing queryString pair map') + + request.queryObj = request.queryString.reduce(reducer, {}) + } + + // construct headers objects + if (request.headers && request.headers.length) { + // loweCase header keys + request.headersObj = request.headers.reduceRight(function (headers, header) { + headers[header.name.toLowerCase()] = header.value + return headers + }, {}) + } + + // construct headers objects + if (request.cookies && request.cookies.length) { + request.cookiesObj = request.cookies.reduceRight(function (cookies, cookie) { + cookies[cookie.name] = cookie.value + return cookies + }, {}) + } + + // construct Cookie header + var cookies = request.cookies.map(function (cookie) { + return encodeURIComponent(cookie.name) + '=' + encodeURIComponent(cookie.value) + }) + + if (cookies.length) { + request.allHeaders.cookie = cookies.join('; ') + } + + switch (request.postData.mimeType) { + case 'multipart/mixed': + case 'multipart/related': + case 'multipart/form-data': + case 'multipart/alternative': + // reset values + request.postData.text = '' + request.postData.mimeType = 'multipart/form-data' + + if (request.postData.params) { + var form = new MultiPartForm() + + // easter egg + form._boundary = '---011000010111000001101001' + + request.postData.params.forEach(function (param) { + form.append(param.name, param.value || '', { + filename: param.fileName || null, + contentType: param.contentType || null + }) + }) + + form.pipe(es.map(function (data, cb) { + request.postData.text += data + })) + + request.postData.boundary = form.getBoundary() + request.headersObj['content-type'] = 'multipart/form-data; boundary=' + form.getBoundary() + } + break + + case 'application/x-www-form-urlencoded': + if (!request.postData.params) { + request.postData.text = '' + } else { + request.postData.paramsObj = request.postData.params.reduce(reducer, {}) + + // always overwrite + request.postData.text = qs.stringify(request.postData.paramsObj) + } + break + + case 'text/json': + case 'text/x-json': + case 'application/json': + case 'application/x-json': + request.postData.mimeType = 'application/json' + + if (request.postData.text) { + try { + request.postData.jsonObj = JSON.parse(request.postData.text) + } catch (e) { + debug(e) + + // force back to text/plain + // if headers have proper content-type value, then this should also work + request.postData.mimeType = 'text/plain' + } + } + break + } + + // create allHeaders object + request.allHeaders = util._extend(request.allHeaders, request.headersObj) + + // deconstruct the uri + request.uriObj = url.parse(request.url, true, true) + + // merge all possible queryString values + request.queryObj = util._extend(request.queryObj, request.uriObj.query) + + // reset uriObj values for a clean url + request.uriObj.query = null + request.uriObj.search = null + request.uriObj.path = request.uriObj.pathname + + // keep the base url clean of queryString + request.url = url.format(request.uriObj) + + // update the uri object + request.uriObj.query = request.queryObj + request.uriObj.search = qs.stringify(request.queryObj) + + if (request.uriObj.search) { + request.uriObj.path = request.uriObj.pathname + '?' + request.uriObj.search + } + + // construct a full url + request.fullUrl = url.format(request.uriObj) + + return request +} + +HTTPSnippet.prototype.convert = function (target, client, opts) { + if (!opts && client) { + opts = client + } + + var func = this._matchTarget(target, client) + + if (func) { + var results = this.requests.map(function (request) { + return func(request, opts) + }) + + return results.length === 1 ? results[0] : results + } + + return false +} + +HTTPSnippet.prototype._matchTarget = function (target, client) { + // does it exist? + if (!targets.hasOwnProperty(target)) { + return false + } + + // shorthand + if (typeof client === 'string' && typeof targets[target][client] === 'function') { + return targets[target][client] + } + + // default target + return targets[target][targets[target].info.default] +} + +// exports +module.exports = HTTPSnippet + +module.exports.availableTargets = function () { + return Object.keys(targets).map(function (key) { + var target = util._extend({}, targets[key].info) + var clients = Object.keys(targets[key]) + + .filter(function (prop) { + return !~['info', 'index'].indexOf(prop) + }) + + .map(function (client) { + return targets[key][client].info + }) + + if (clients.length) { + target.clients = clients + } + + return target + }) +} + +module.exports.extname = function (target) { + return targets[target] ? targets[target].info.extname : '' +} diff --git a/packages/insomnia-httpsnippet/src/targets/c/index.js b/packages/insomnia-httpsnippet/src/targets/c/index.js new file mode 100755 index 0000000000..0a62726518 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/c/index.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = { + info: { + key: 'c', + title: 'C', + extname: '.c', + default: 'libcurl' + }, + + libcurl: require('./libcurl') +} diff --git a/packages/insomnia-httpsnippet/src/targets/c/libcurl.js b/packages/insomnia-httpsnippet/src/targets/c/libcurl.js new file mode 100755 index 0000000000..aad328e28f --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/c/libcurl.js @@ -0,0 +1,50 @@ +'use strict' + +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var code = new CodeBuilder() + + code.push('CURL *hnd = curl_easy_init();') + .blank() + .push('curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "%s");', source.method.toUpperCase()) + .push('curl_easy_setopt(hnd, CURLOPT_URL, "%s");', source.fullUrl) + + // Add headers, including the cookies + var headers = Object.keys(source.headersObj) + + // construct headers + if (headers.length) { + code.blank() + .push('struct curl_slist *headers = NULL;') + + headers.forEach(function (key) { + code.push('headers = curl_slist_append(headers, "%s: %s");', key, source.headersObj[key]) + }) + + code.push('curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);') + } + + // construct cookies + if (source.allHeaders.cookie) { + code.blank() + .push('curl_easy_setopt(hnd, CURLOPT_COOKIE, "%s");', source.allHeaders.cookie) + } + + if (source.postData.text) { + code.blank() + .push('curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, %s);', JSON.stringify(source.postData.text)) + } + + code.blank() + .push('CURLcode ret = curl_easy_perform(hnd);') + + return code.join() +} + +module.exports.info = { + key: 'libcurl', + title: 'Libcurl', + link: 'http://curl.haxx.se/libcurl/', + description: 'Simple REST and HTTP API Client for C' +} diff --git a/packages/insomnia-httpsnippet/src/targets/csharp/index.js b/packages/insomnia-httpsnippet/src/targets/csharp/index.js new file mode 100755 index 0000000000..226dd69f42 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/csharp/index.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = { + info: { + key: 'csharp', + title: 'C#', + extname: '.cs', + default: 'restsharp' + }, + + restsharp: require('./restsharp') +} diff --git a/packages/insomnia-httpsnippet/src/targets/csharp/restsharp.js b/packages/insomnia-httpsnippet/src/targets/csharp/restsharp.js new file mode 100755 index 0000000000..0b8fc27355 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/csharp/restsharp.js @@ -0,0 +1,46 @@ +'use strict' + +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var code = new CodeBuilder() + var methods = [ 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS' ] + + if (methods.indexOf(source.method.toUpperCase()) === -1) { + return 'Method not supported' + } else { + code.push('var client = new RestClient("%s");', source.fullUrl) + code.push('var request = new RestRequest(Method.%s);', source.method.toUpperCase()) + } + + // Add headers, including the cookies + var headers = Object.keys(source.headersObj) + + // construct headers + if (headers.length) { + headers.forEach(function (key) { + code.push('request.AddHeader("%s", "%s");', key, source.headersObj[key]) + }) + } + + // construct cookies + if (source.cookies.length) { + source.cookies.forEach(function (cookie) { + code.push('request.AddCookie("%s", "%s");', cookie.name, cookie.value) + }) + } + + if (source.postData.text) { + code.push('request.AddParameter("%s", %s, ParameterType.RequestBody);', source.allHeaders['content-type'], JSON.stringify(source.postData.text)) + } + + code.push('IRestResponse response = client.Execute(request);') + return code.join() +} + +module.exports.info = { + key: 'restsharp', + title: 'RestSharp', + link: 'http://restsharp.org/', + description: 'Simple REST and HTTP API Client for .NET' +} diff --git a/packages/insomnia-httpsnippet/src/targets/go/index.js b/packages/insomnia-httpsnippet/src/targets/go/index.js new file mode 100755 index 0000000000..64630875a4 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/go/index.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = { + info: { + key: 'go', + title: 'Go', + extname: '.go', + default: 'native' + }, + + native: require('./native') +} diff --git a/packages/insomnia-httpsnippet/src/targets/go/native.js b/packages/insomnia-httpsnippet/src/targets/go/native.js new file mode 100755 index 0000000000..7ba90e0f00 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/go/native.js @@ -0,0 +1,138 @@ +/** + * @description + * HTTP code snippet generator for native Go. + * + * @author + * @montanaflynn + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + // Let's Go! + var code = new CodeBuilder('\t') + + // Define Options + var opts = util._extend({ + showBoilerplate: true, + checkErrors: false, + printBody: true, + timeout: -1 + }, options) + + var errorPlaceholder = opts.checkErrors ? 'err' : '_' + + var indent = opts.showBoilerplate ? 1 : 0 + + var errorCheck = function () { + if (opts.checkErrors) { + code.push(indent, 'if err != nil {') + .push(indent + 1, 'panic(err)') + .push(indent, '}') + } + } + + // Create boilerplate + if (opts.showBoilerplate) { + code.push('package main') + .blank() + .push('import (') + .push(indent, '"fmt"') + + if (opts.timeout > 0) { + code.push(indent, '"time"') + } + + if (source.postData.text) { + code.push(indent, '"strings"') + } + + code.push(indent, '"net/http"') + + if (opts.printBody) { + code.push(indent, '"io/ioutil"') + } + + code.push(')') + .blank() + .push('func main() {') + .blank() + } + + // Create client + var client + if (opts.timeout > 0) { + client = 'client' + code.push(indent, 'client := http.Client{') + .push(indent + 1, 'Timeout: time.Duration(%s * time.Second),', opts.timeout) + .push(indent, '}') + .blank() + } else { + client = 'http.DefaultClient' + } + + code.push(indent, 'url := "%s"', source.fullUrl) + .blank() + + // If we have body content or not create the var and reader or nil + if (source.postData.text) { + code.push(indent, 'payload := strings.NewReader(%s)', JSON.stringify(source.postData.text)) + .blank() + .push(indent, 'req, %s := http.NewRequest("%s", url, payload)', errorPlaceholder, source.method) + .blank() + } else { + code.push(indent, 'req, %s := http.NewRequest("%s", url, nil)', errorPlaceholder, source.method) + .blank() + } + + errorCheck() + + // Add headers + if (Object.keys(source.allHeaders).length) { + Object.keys(source.allHeaders).forEach(function (key) { + code.push(indent, 'req.Header.Add("%s", "%s")', key, source.allHeaders[key]) + }) + + code.blank() + } + + // Make request + code.push(indent, 'res, %s := %s.Do(req)', errorPlaceholder, client) + errorCheck() + + // Get Body + if (opts.printBody) { + code.blank() + .push(indent, 'defer res.Body.Close()') + .push(indent, 'body, %s := ioutil.ReadAll(res.Body)', errorPlaceholder) + errorCheck() + } + + // Print it + code.blank() + .push(indent, 'fmt.Println(res)') + + if (opts.printBody) { + code.push(indent, 'fmt.Println(string(body))') + } + + // End main block + if (opts.showBoilerplate) { + code.blank() + .push('}') + } + + return code.join() +} + +module.exports.info = { + key: 'native', + title: 'NewRequest', + link: 'http://golang.org/pkg/net/http/#NewRequest', + description: 'Golang HTTP client request' +} diff --git a/packages/insomnia-httpsnippet/src/targets/index.js b/packages/insomnia-httpsnippet/src/targets/index.js new file mode 100755 index 0000000000..228c828ee6 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/index.js @@ -0,0 +1,17 @@ +'use strict' + +module.exports = { + c: require('./c'), + csharp: require('./csharp'), + go: require('./go'), + java: require('./java'), + javascript: require('./javascript'), + node: require('./node'), + objc: require('./objc'), + ocaml: require('./ocaml'), + php: require('./php'), + python: require('./python'), + ruby: require('./ruby'), + shell: require('./shell'), + swift: require('./swift') +} diff --git a/packages/insomnia-httpsnippet/src/targets/java/index.js b/packages/insomnia-httpsnippet/src/targets/java/index.js new file mode 100755 index 0000000000..2d13eefa10 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/java/index.js @@ -0,0 +1,13 @@ +'use strict' + +module.exports = { + info: { + key: 'java', + title: 'Java', + extname: '.java', + default: 'unirest' + }, + + okhttp: require('./okhttp'), + unirest: require('./unirest') +} diff --git a/packages/insomnia-httpsnippet/src/targets/java/okhttp.js b/packages/insomnia-httpsnippet/src/targets/java/okhttp.js new file mode 100755 index 0000000000..829d76a4b2 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/java/okhttp.js @@ -0,0 +1,79 @@ +/** + * @description + * HTTP code snippet generator for Java using OkHttp. + * + * @author + * @shashiranjan84 + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ' + }, options) + + var code = new CodeBuilder(opts.indent) + + var methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD'] + + var methodsWithBody = ['POST', 'PUT', 'DELETE', 'PATCH'] + + code.push('OkHttpClient client = new OkHttpClient();') + .blank() + + if (source.postData.text) { + if (source.postData.boundary) { + code.push('MediaType mediaType = MediaType.parse("%s; boundary=%s");', source.postData.mimeType, source.postData.boundary) + } else { + code.push('MediaType mediaType = MediaType.parse("%s");', source.postData.mimeType) + } + code.push('RequestBody body = RequestBody.create(mediaType, %s);', JSON.stringify(source.postData.text)) + } + + code.push('Request request = new Request.Builder()') + code.push(1, '.url("%s")', source.fullUrl) + if (methods.indexOf(source.method.toUpperCase()) === -1) { + if (source.postData.text) { + code.push(1, '.method("%s", body)', source.method.toUpperCase()) + } else { + code.push(1, '.method("%s", null)', source.method.toUpperCase()) + } + } else if (methodsWithBody.indexOf(source.method.toUpperCase()) >= 0) { + if (source.postData.text) { + code.push(1, '.%s(body)', source.method.toLowerCase()) + } else { + code.push(1, '.%s(null)', source.method.toLowerCase()) + } + } else { + code.push(1, '.%s()', source.method.toLowerCase()) + } + + // Add headers, including the cookies + var headers = Object.keys(source.allHeaders) + + // construct headers + if (headers.length) { + headers.forEach(function (key) { + code.push(1, '.addHeader("%s", "%s")', key, source.allHeaders[key]) + }) + } + + code.push(1, '.build();') + .blank() + .push('Response response = client.newCall(request).execute();') + + return code.join() +} + +module.exports.info = { + key: 'okhttp', + title: 'OkHttp', + link: 'http://square.github.io/okhttp/', + description: 'An HTTP Request Client Library' +} diff --git a/packages/insomnia-httpsnippet/src/targets/java/unirest.js b/packages/insomnia-httpsnippet/src/targets/java/unirest.js new file mode 100755 index 0000000000..4d686520d1 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/java/unirest.js @@ -0,0 +1,55 @@ +/** + * @description + * HTTP code snippet generator for Java using Unirest. + * + * @author + * @shashiranjan84 + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ' + }, options) + + var code = new CodeBuilder(opts.indent) + + var methods = [ 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS' ] + + if (methods.indexOf(source.method.toUpperCase()) === -1) { + code.push('HttpResponse response = Unirest.customMethod("%s","%s")', source.method.toUpperCase(), source.fullUrl) + } else { + code.push('HttpResponse response = Unirest.%s("%s")', source.method.toLowerCase(), source.fullUrl) + } + + // Add headers, including the cookies + var headers = Object.keys(source.allHeaders) + + // construct headers + if (headers.length) { + headers.forEach(function (key) { + code.push(1, '.header("%s", "%s")', key, source.allHeaders[key]) + }) + } + + if (source.postData.text) { + code.push(1, '.body(%s)', JSON.stringify(source.postData.text)) + } + + code.push(1, '.asString();') + + return code.join() +} + +module.exports.info = { + key: 'unirest', + title: 'Unirest', + link: 'http://unirest.io/java.html', + description: 'Lightweight HTTP Request Client Library' +} diff --git a/packages/insomnia-httpsnippet/src/targets/javascript/index.js b/packages/insomnia-httpsnippet/src/targets/javascript/index.js new file mode 100755 index 0000000000..f04c6003e9 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/javascript/index.js @@ -0,0 +1,13 @@ +'use strict' + +module.exports = { + info: { + key: 'javascript', + title: 'JavaScript', + extname: '.js', + default: 'xhr' + }, + + jquery: require('./jquery'), + xhr: require('./xhr') +} diff --git a/packages/insomnia-httpsnippet/src/targets/javascript/jquery.js b/packages/insomnia-httpsnippet/src/targets/javascript/jquery.js new file mode 100755 index 0000000000..4365ae588b --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/javascript/jquery.js @@ -0,0 +1,80 @@ +/** + * @description + * HTTP code snippet generator for native XMLHttpRequest + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ' + }, options) + + var code = new CodeBuilder(opts.indent) + + var settings = { + async: true, + crossDomain: true, + url: source.fullUrl, + method: source.method, + headers: source.allHeaders + } + + switch (source.postData.mimeType) { + case 'application/x-www-form-urlencoded': + settings.data = source.postData.paramsObj ? source.postData.paramsObj : source.postData.text + break + + case 'application/json': + settings.processData = false + settings.data = source.postData.text + break + + case 'multipart/form-data': + code.push('var form = new FormData();') + + source.postData.params.forEach(function (param) { + code.push('form.append(%s, %s);', JSON.stringify(param.name), JSON.stringify(param.value || param.fileName || '')) + }) + + settings.processData = false + settings.contentType = false + settings.mimeType = 'multipart/form-data' + settings.data = '[form]' + + // remove the contentType header + if (~settings.headers['content-type'].indexOf('boundary')) { + delete settings.headers['content-type'] + } + code.blank() + break + + default: + if (source.postData.text) { + settings.data = source.postData.text + } + } + + code.push('var settings = ' + JSON.stringify(settings, null, opts.indent).replace('"[form]"', 'form')) + .blank() + .push('$.ajax(settings).done(function (response) {') + .push(1, 'console.log(response);') + .push('});') + + return code.join() +} + +module.exports.info = { + key: 'jquery', + title: 'jQuery', + link: 'http://api.jquery.com/jquery.ajax/', + description: 'Perform an asynchronous HTTP (Ajax) requests with jQuery' +} diff --git a/packages/insomnia-httpsnippet/src/targets/javascript/xhr.js b/packages/insomnia-httpsnippet/src/targets/javascript/xhr.js new file mode 100755 index 0000000000..3f7e69b71a --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/javascript/xhr.js @@ -0,0 +1,80 @@ +/** + * @description + * HTTP code snippet generator for native XMLHttpRequest + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ', + cors: true + }, options) + + var code = new CodeBuilder(opts.indent) + + switch (source.postData.mimeType) { + case 'application/json': + code.push('var data = JSON.stringify(%s);', JSON.stringify(source.postData.jsonObj, null, opts.indent)) + .push(null) + break + + case 'multipart/form-data': + code.push('var data = new FormData();') + + source.postData.params.forEach(function (param) { + code.push('data.append(%s, %s);', JSON.stringify(param.name), JSON.stringify(param.value || param.fileName || '')) + }) + + // remove the contentType header + if (source.allHeaders['content-type'].indexOf('boundary')) { + delete source.allHeaders['content-type'] + } + + code.blank() + break + + default: + code.push('var data = %s;', JSON.stringify(source.postData.text || null)) + .blank() + } + + code.push('var xhr = new XMLHttpRequest();') + + if (opts.cors) { + code.push('xhr.withCredentials = true;') + } + + code.blank() + .push('xhr.addEventListener("readystatechange", function () {') + .push(1, 'if (this.readyState === this.DONE) {') + .push(2, 'console.log(this.responseText);') + .push(1, '}') + .push('});') + .blank() + .push('xhr.open(%s, %s);', JSON.stringify(source.method), JSON.stringify(source.fullUrl)) + + Object.keys(source.allHeaders).forEach(function (key) { + code.push('xhr.setRequestHeader(%s, %s);', JSON.stringify(key), JSON.stringify(source.allHeaders[key])) + }) + + code.blank() + .push('xhr.send(data);') + + return code.join() +} + +module.exports.info = { + key: 'xhr', + title: 'XMLHttpRequest', + link: 'https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest', + description: 'W3C Standard API that provides scripted client functionality' +} diff --git a/packages/insomnia-httpsnippet/src/targets/node/index.js b/packages/insomnia-httpsnippet/src/targets/node/index.js new file mode 100755 index 0000000000..1e4d9e3522 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/node/index.js @@ -0,0 +1,14 @@ +'use strict' + +module.exports = { + info: { + key: 'node', + title: 'Node.js', + extname: '.js', + default: 'native' + }, + + native: require('./native'), + request: require('./request'), + unirest: require('./unirest') +} diff --git a/packages/insomnia-httpsnippet/src/targets/node/native.js b/packages/insomnia-httpsnippet/src/targets/node/native.js new file mode 100755 index 0000000000..3d0f18923d --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/node/native.js @@ -0,0 +1,84 @@ +/** + * @description + * HTTP code snippet generator for native Node.js. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ' + }, options) + + var code = new CodeBuilder(opts.indent) + + var reqOpts = { + method: source.method, + hostname: source.uriObj.hostname, + port: source.uriObj.port, + path: source.uriObj.path, + headers: source.allHeaders + } + + code.push('var http = require("%s");', source.uriObj.protocol.replace(':', '')) + + code.blank() + .push('var options = %s;', JSON.stringify(reqOpts, null, opts.indent)) + .blank() + .push('var req = http.request(options, function (res) {') + .push(1, 'var chunks = [];') + .blank() + .push(1, 'res.on("data", function (chunk) {') + .push(2, 'chunks.push(chunk);') + .push(1, '});') + .blank() + .push(1, 'res.on("end", function () {') + .push(2, 'var body = Buffer.concat(chunks);') + .push(2, 'console.log(body.toString());') + .push(1, '});') + .push('});') + .blank() + + switch (source.postData.mimeType) { + case 'application/x-www-form-urlencoded': + if (source.postData.paramsObj) { + code.unshift('var qs = require("querystring");') + code.push('req.write(qs.stringify(%s));', util.inspect(source.postData.paramsObj, { + depth: null + })) + } + break + + case 'application/json': + if (source.postData.jsonObj) { + code.push('req.write(JSON.stringify(%s));', util.inspect(source.postData.jsonObj, { + depth: null + })) + } + break + + default: + if (source.postData.text) { + code.push('req.write(%s);', JSON.stringify(source.postData.text, null, opts.indent)) + } + } + + code.push('req.end();') + + return code.join() +} + +module.exports.info = { + key: 'native', + title: 'HTTP', + link: 'http://nodejs.org/api/http.html#http_http_request_options_callback', + description: 'Node.js native HTTP interface' +} diff --git a/packages/insomnia-httpsnippet/src/targets/node/request.js b/packages/insomnia-httpsnippet/src/targets/node/request.js new file mode 100755 index 0000000000..ea0330784c --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/node/request.js @@ -0,0 +1,125 @@ +/** + * @description + * HTTP code snippet generator for Node.js using Request. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ' + }, options) + + var includeFS = false + var code = new CodeBuilder(opts.indent) + + code.push('var request = require("request");') + .blank() + + var reqOpts = { + method: source.method, + url: source.url + } + + if (Object.keys(source.queryObj).length) { + reqOpts.qs = source.queryObj + } + + if (Object.keys(source.headersObj).length) { + reqOpts.headers = source.headersObj + } + + switch (source.postData.mimeType) { + case 'application/x-www-form-urlencoded': + reqOpts.form = source.postData.paramsObj + break + + case 'application/json': + if (source.postData.jsonObj) { + reqOpts.body = source.postData.jsonObj + reqOpts.json = true + } + break + + case 'multipart/form-data': + reqOpts.formData = {} + + source.postData.params.forEach(function (param) { + var attachement = {} + + if (!param.fileName && !param.fileName && !param.contentType) { + reqOpts.formData[param.name] = param.value + return + } + + if (param.fileName && !param.value) { + includeFS = true + + attachement.value = 'fs.createReadStream("' + param.fileName + '")' + } else if (param.value) { + attachement.value = param.value + } + + if (param.fileName) { + attachement.options = { + filename: param.fileName, + contentType: param.contentType ? param.contentType : null + } + } + + reqOpts.formData[param.name] = attachement + }) + break + + default: + if (source.postData.text) { + reqOpts.body = source.postData.text + } + } + + // construct cookies argument + if (source.cookies.length) { + reqOpts.jar = 'JAR' + + code.push('var jar = request.jar();') + + var url = source.url + + source.cookies.forEach(function (cookie) { + code.push('jar.setCookie(request.cookie("%s=%s"), "%s");', encodeURIComponent(cookie.name), encodeURIComponent(cookie.value), url) + }) + code.blank() + } + + if (includeFS) { + code.unshift('var fs = require("fs");') + } + + code.push('var options = %s;', util.inspect(reqOpts, { depth: null })) + .blank() + + code.push(util.format('request(options, %s', 'function (error, response, body) {')) + + .push(1, 'if (error) throw new Error(error);') + .blank() + .push(1, 'console.log(body);') + .push('});') + .blank() + + return code.join().replace('"JAR"', 'jar').replace(/"fs\.createReadStream\(\\\"(.+)\\\"\)\"/, 'fs.createReadStream("$1")') +} + +module.exports.info = { + key: 'request', + title: 'Request', + link: 'https://github.com/request/request', + description: 'Simplified HTTP request client' +} diff --git a/packages/insomnia-httpsnippet/src/targets/node/unirest.js b/packages/insomnia-httpsnippet/src/targets/node/unirest.js new file mode 100755 index 0000000000..daa4bf8941 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/node/unirest.js @@ -0,0 +1,116 @@ +/** + * @description + * HTTP code snippet generator for Node.js using Unirest. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ' + }, options) + + var includeFS = false + var code = new CodeBuilder(opts.indent) + + code.push('var unirest = require("unirest");') + .blank() + .push('var req = unirest("%s", "%s");', source.method, source.url) + .blank() + + if (source.cookies.length) { + code.push('var CookieJar = unirest.jar();') + + source.cookies.forEach(function (cookie) { + code.push('CookieJar.add("%s=%s","%s");', encodeURIComponent(cookie.name), encodeURIComponent(cookie.value), source.url) + }) + + code.push('req.jar(CookieJar);') + .blank() + } + + if (Object.keys(source.queryObj).length) { + code.push('req.query(%s);', JSON.stringify(source.queryObj, null, opts.indent)) + .blank() + } + + if (Object.keys(source.headersObj).length) { + code.push('req.headers(%s);', JSON.stringify(source.headersObj, null, opts.indent)) + .blank() + } + + switch (source.postData.mimeType) { + case 'application/x-www-form-urlencoded': + if (source.postData.paramsObj) { + code.push('req.form(%s);', JSON.stringify(source.postData.paramsObj, null, opts.indent)) + } + break + + case 'application/json': + if (source.postData.jsonObj) { + code.push('req.type("json");') + .push('req.send(%s);', JSON.stringify(source.postData.jsonObj, null, opts.indent)) + } + break + + case 'multipart/form-data': + var multipart = [] + + source.postData.params.forEach(function (param) { + var part = {} + + if (param.fileName && !param.value) { + includeFS = true + + part.body = 'fs.createReadStream("' + param.fileName + '")' + } else if (param.value) { + part.body = param.value + } + + if (part.body) { + if (param.contentType) { + part['content-type'] = param.contentType + } + + multipart.push(part) + } + }) + + code.push('req.multipart(%s);', JSON.stringify(multipart, null, opts.indent)) + break + + default: + if (source.postData.text) { + code.push(opts.indent + 'req.send(%s);', JSON.stringify(source.postData.text, null, opts.indent)) + } + } + + if (includeFS) { + code.unshift('var fs = require("fs");') + } + + code.blank() + .push('req.end(function (res) {') + .push(1, 'if (res.error) throw new Error(res.error);') + .blank() + .push(1, 'console.log(res.body);') + .push('});') + .blank() + + return code.join().replace(/"fs\.createReadStream\(\\\"(.+)\\\"\)\"/, 'fs.createReadStream("$1")') +} + +module.exports.info = { + key: 'unirest', + title: 'Unirest', + link: 'http://unirest.io/nodejs.html', + description: 'Lightweight HTTP Request Client Library' +} diff --git a/packages/insomnia-httpsnippet/src/targets/objc/helpers.js b/packages/insomnia-httpsnippet/src/targets/objc/helpers.js new file mode 100755 index 0000000000..0b80f84c5a --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/objc/helpers.js @@ -0,0 +1,70 @@ +'use strict' + +var util = require('util') + +module.exports = { + /** + * Create an string of given length filled with blank spaces + * + * @param {number} length Length of the array to return + * @return {string} + */ + blankString: function (length) { + return Array.apply(null, new Array(length)).map(String.prototype.valueOf, ' ').join('') + }, + + /** + * Create a string corresponding to a valid declaration and initialization of an Objective-C object literal. + * + * @param {string} nsClass Class of the litteral + * @param {string} name Desired name of the instance + * @param {Object} parameters Key-value object of parameters to translate to an Objective-C object litearal + * @param {boolean} indent If true, will declare the litteral by indenting each new key/value pair. + * @return {string} A valid Objective-C declaration and initialization of an Objective-C object litteral. + * + * @example + * nsDeclaration('NSDictionary', 'params', {a: 'b', c: 'd'}, true) + * // returns: + * NSDictionary *params = @{ @"a": @"b", + * @"c": @"d" }; + * + * nsDeclaration('NSDictionary', 'params', {a: 'b', c: 'd'}) + * // returns: + * NSDictionary *params = @{ @"a": @"b", @"c": @"d" }; + */ + nsDeclaration: function (nsClass, name, parameters, indent) { + var opening = nsClass + ' *' + name + ' = ' + var literal = this.literalRepresentation(parameters, indent ? opening.length : undefined) + return opening + literal + ';' + }, + + /** + * Create a valid Objective-C string of a literal value according to its type. + * + * @param {*} value Any JavaScript literal + * @return {string} + */ + literalRepresentation: function (value, indentation) { + var join = indentation === undefined ? ', ' : ',\n ' + this.blankString(indentation) + + switch (Object.prototype.toString.call(value)) { + case '[object Number]': + return '@' + value + case '[object Array]': + var values_representation = value.map(function (v) { + return this.literalRepresentation(v) + }.bind(this)) + return '@[ ' + values_representation.join(join) + ' ]' + case '[object Object]': + var keyValuePairs = [] + for (var k in value) { + keyValuePairs.push(util.format('@"%s": %s', k, this.literalRepresentation(value[k]))) + } + return '@{ ' + keyValuePairs.join(join) + ' }' + case '[object Boolean]': + return value ? '@YES' : '@NO' + default: + return '@"' + value.toString().replace(/"/g, '\\"') + '"' + } + } +} diff --git a/packages/insomnia-httpsnippet/src/targets/objc/index.js b/packages/insomnia-httpsnippet/src/targets/objc/index.js new file mode 100755 index 0000000000..4f7d2550f3 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/objc/index.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = { + info: { + key: 'objc', + title: 'Objective-C', + extname: '.m', + default: 'nsurlsession' + }, + + nsurlsession: require('./nsurlsession') +} diff --git a/packages/insomnia-httpsnippet/src/targets/objc/nsurlsession.js b/packages/insomnia-httpsnippet/src/targets/objc/nsurlsession.js new file mode 100755 index 0000000000..1d68c271e8 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/objc/nsurlsession.js @@ -0,0 +1,136 @@ +/** + * @description + * HTTP code snippet generator for Objective-C using NSURLSession. + * + * @author + * @thibaultCha + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var helpers = require('./helpers') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ', + pretty: true, + timeout: '10' + }, options) + + var code = new CodeBuilder(opts.indent) + // Markers for headers to be created as litteral objects and later be set on the NSURLRequest if exist + var req = { + hasHeaders: false, + hasBody: false + } + + // We just want to make sure people understand that is the only dependency + code.push('#import ') + + if (Object.keys(source.allHeaders).length) { + req.hasHeaders = true + code.blank() + .push(helpers.nsDeclaration('NSDictionary', 'headers', source.allHeaders, opts.pretty)) + } + + if (source.postData.text || source.postData.jsonObj || source.postData.params) { + req.hasBody = true + + switch (source.postData.mimeType) { + case 'application/x-www-form-urlencoded': + // By appending parameters one by one in the resulting snippet, + // we make it easier for the user to edit it according to his or her needs after pasting. + // The user can just add/remove lines adding/removing body parameters. + code.blank() + .push('NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"%s=%s" dataUsingEncoding:NSUTF8StringEncoding]];', + source.postData.params[0].name, source.postData.params[0].value) + for (var i = 1, len = source.postData.params.length; i < len; i++) { + code.push('[postData appendData:[@"&%s=%s" dataUsingEncoding:NSUTF8StringEncoding]];', + source.postData.params[i].name, source.postData.params[i].value) + } + break + + case 'application/json': + if (source.postData.jsonObj) { + code.push(helpers.nsDeclaration('NSDictionary', 'parameters', source.postData.jsonObj, opts.pretty)) + .blank() + .push('NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];') + } + break + + case 'multipart/form-data': + // By appending multipart parameters one by one in the resulting snippet, + // we make it easier for the user to edit it according to his or her needs after pasting. + // The user can just edit the parameters NSDictionary or put this part of a snippet in a multipart builder method. + code.push(helpers.nsDeclaration('NSArray', 'parameters', source.postData.params, opts.pretty)) + .push('NSString *boundary = @"%s";', source.postData.boundary) + .blank() + .push('NSError *error;') + .push('NSMutableString *body = [NSMutableString string];') + .push('for (NSDictionary *param in parameters) {') + .push(1, '[body appendFormat:@"--%@\\r\\n", boundary];') + .push(1, 'if (param[@"fileName"]) {') + .push(2, '[body appendFormat:@"Content-Disposition:form-data; name=\\"%@\\"; filename=\\"%@\\"\\r\\n", param[@"name"], param[@"fileName"]];') + .push(2, '[body appendFormat:@"Content-Type: %@\\r\\n\\r\\n", param[@"contentType"]];') + .push(2, '[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];') + .push(2, 'if (error) {') + .push(3, 'NSLog(@"%@", error);') + .push(2, '}') + .push(1, '} else {') + .push(2, '[body appendFormat:@"Content-Disposition:form-data; name=\\"%@\\"\\r\\n\\r\\n", param[@"name"]];') + .push(2, '[body appendFormat:@"%@", param[@"value"]];') + .push(1, '}') + .push('}') + .push('[body appendFormat:@"\\r\\n--%@--\\r\\n", boundary];') + .push('NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];') + break + + default: + code.blank() + .push('NSData *postData = [[NSData alloc] initWithData:[@"' + source.postData.text + '" dataUsingEncoding:NSUTF8StringEncoding]];') + } + } + + code.blank() + .push('NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"' + source.fullUrl + '"]') + // NSURLRequestUseProtocolCachePolicy is the default policy, let's just always set it to avoid confusion. + .push(' cachePolicy:NSURLRequestUseProtocolCachePolicy') + .push(' timeoutInterval:' + parseInt(opts.timeout, 10).toFixed(1) + '];') + .push('[request setHTTPMethod:@"' + source.method + '"];') + + if (req.hasHeaders) { + code.push('[request setAllHTTPHeaderFields:headers];') + } + + if (req.hasBody) { + code.push('[request setHTTPBody:postData];') + } + + code.blank() + // Retrieving the shared session will be less verbose than creating a new one. + .push('NSURLSession *session = [NSURLSession sharedSession];') + .push('NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request') + .push(' completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {') + .push(1, ' if (error) {') + .push(2, ' NSLog(@"%@", error);') + .push(1, ' } else {') + // Casting the NSURLResponse to NSHTTPURLResponse so the user can see the status . + .push(2, ' NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;') + .push(2, ' NSLog(@"%@", httpResponse);') + .push(1, ' }') + .push(' }];') + .push('[dataTask resume];') + + return code.join() +} + +module.exports.info = { + key: 'nsurlsession', + title: 'NSURLSession', + link: 'https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSURLSession_class/index.html', + description: 'Foundation\'s NSURLSession request' +} diff --git a/packages/insomnia-httpsnippet/src/targets/ocaml/cohttp.js b/packages/insomnia-httpsnippet/src/targets/ocaml/cohttp.js new file mode 100755 index 0000000000..ae89592f9e --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/ocaml/cohttp.js @@ -0,0 +1,72 @@ +/** + * @description + * HTTP code snippet generator for OCaml using CoHTTP. + * + * @author + * @SGrondin + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ' + }, options) + + var methods = ['get', 'post', 'head', 'delete', 'patch', 'put', 'options'] + var code = new CodeBuilder(opts.indent) + + code.push('open Cohttp_lwt_unix') + .push('open Cohttp') + .push('open Lwt') + .blank() + .push('let uri = Uri.of_string "%s" in', source.fullUrl) + + // Add headers, including the cookies + var headers = Object.keys(source.allHeaders) + + if (headers.length === 1) { + code.push('let headers = Header.add (Header.init ()) "%s" "%s" in', headers[0], source.allHeaders[headers[0]]) + } else if (headers.length > 1) { + code.push('let headers = Header.add_list (Header.init ()) [') + + headers.forEach(function (key) { + code.push(1, '("%s", "%s");', key, source.allHeaders[key]) + }) + + code.push('] in') + } + + // Add body + if (source.postData.text) { + // Just text + code.push('let body = Cohttp_lwt_body.of_string %s in', JSON.stringify(source.postData.text)) + } + + // Do the request + code.blank() + + code.push('Client.call %s%s%s uri', + headers.length ? '~headers ' : '', + source.postData.text ? '~body ' : '', + (methods.indexOf(source.method.toLowerCase()) >= 0 ? ('`' + source.method.toUpperCase()) : '(Code.method_of_string "' + source.method + '")') + ) + + // Catch result + code.push('>>= fun (res, body_stream) ->') + .push(1, '(* Do stuff with the result *)') + + return code.join() +} + +module.exports.info = { + key: 'cohttp', + title: 'CoHTTP', + link: 'https://github.com/mirage/ocaml-cohttp', + description: 'Cohttp is a very lightweight HTTP server using Lwt or Async for OCaml' +} diff --git a/packages/insomnia-httpsnippet/src/targets/ocaml/index.js b/packages/insomnia-httpsnippet/src/targets/ocaml/index.js new file mode 100755 index 0000000000..6fe00a8886 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/ocaml/index.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = { + info: { + key: 'ocaml', + title: 'OCaml', + extname: '.ml', + default: 'cohttp' + }, + + cohttp: require('./cohttp') +} diff --git a/packages/insomnia-httpsnippet/src/targets/php/curl.js b/packages/insomnia-httpsnippet/src/targets/php/curl.js new file mode 100755 index 0000000000..97aebc29dc --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/php/curl.js @@ -0,0 +1,138 @@ +/** + * @description + * HTTP code snippet generator for PHP using curl-ext. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + closingTag: false, + indent: ' ', + maxRedirects: 10, + namedErrors: false, + noTags: false, + shortTags: false, + timeout: 30 + }, options) + + var code = new CodeBuilder(opts.indent) + + if (!opts.noTags) { + code.push(opts.shortTags ? ' %s,', option.name, option.escape ? JSON.stringify(option.value) : option.value)) + } + }) + + // construct cookies + var cookies = source.cookies.map(function (cookie) { + return encodeURIComponent(cookie.name) + '=' + encodeURIComponent(cookie.value) + }) + + if (cookies.length) { + curlopts.push(util.format('CURLOPT_COOKIE => "%s",', cookies.join('; '))) + } + + // construct cookies + var headers = Object.keys(source.headersObj).sort().map(function (key) { + return util.format('"%s: %s"', key, source.headersObj[key]) + }) + + if (headers.length) { + curlopts.push('CURLOPT_HTTPHEADER => array(') + .push(1, headers.join(',\n' + opts.indent + opts.indent)) + .push('),') + } + + code.push(1, curlopts.join()) + .push('));') + .blank() + .push('$response = curl_exec($curl);') + .push('$err = curl_error($curl);') + .blank() + .push('curl_close($curl);') + .blank() + .push('if ($err) {') + + if (opts.namedErrors) { + code.push(1, 'echo array_flip(get_defined_constants(true)["curl"])[$err];') + } else { + code.push(1, 'echo "cURL Error #:" . $err;') + } + + code.push('} else {') + .push(1, 'echo $response;') + .push('}') + + if (!opts.noTags && opts.closingTag) { + code.blank() + .push('?>') + } + + return code.join() +} + +module.exports.info = { + key: 'curl', + title: 'cURL', + link: 'http://php.net/manual/en/book.curl.php', + description: 'PHP with ext-curl' +} diff --git a/packages/insomnia-httpsnippet/src/targets/php/helpers.js b/packages/insomnia-httpsnippet/src/targets/php/helpers.js new file mode 100755 index 0000000000..c6b2562edc --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/php/helpers.js @@ -0,0 +1,85 @@ +'use strict' + +var convert = function (obj, indent, last_indent) { + var i, result + + if (!last_indent) { + last_indent = '' + } + + switch (Object.prototype.toString.call(obj)) { + case '[object Null]': + result = 'null' + break + + case '[object Undefined]': + result = 'null' + break + + case '[object String]': + result = "'" + obj.replace(/\\/g, '\\\\').replace(/\'/g, "\'") + "'" + break + + case '[object Number]': + result = obj.toString() + break + + case '[object Array]': + result = [] + + obj.forEach(function (item) { + result.push(convert(item, indent + indent, indent)) + }) + + result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + last_indent + ')' + break + + case '[object Object]': + result = [] + for (i in obj) { + if (obj.hasOwnProperty(i)) { + result.push(convert(i, indent) + ' => ' + convert(obj[i], indent + indent, indent)) + } + } + result = 'array(\n' + indent + result.join(',\n' + indent) + '\n' + last_indent + ')' + break + + default: + result = 'null' + } + + return result +} + +module.exports = { + convert: convert, + methods: [ + 'ACL', + 'BASELINE_CONTROL', + 'CHECKIN', + 'CHECKOUT', + 'CONNECT', + 'COPY', + 'DELETE', + 'GET', + 'HEAD', + 'LABEL', + 'LOCK', + 'MERGE', + 'MKACTIVITY', + 'MKCOL', + 'MKWORKSPACE', + 'MOVE', + 'OPTIONS', + 'POST', + 'PROPFIND', + 'PROPPATCH', + 'PUT', + 'REPORT', + 'TRACE', + 'UNCHECKOUT', + 'UNLOCK', + 'UPDATE', + 'VERSION_CONTROL' + ] +} diff --git a/packages/insomnia-httpsnippet/src/targets/php/http1.js b/packages/insomnia-httpsnippet/src/targets/php/http1.js new file mode 100755 index 0000000000..b4429a4747 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/php/http1.js @@ -0,0 +1,97 @@ +/** + * @description + * HTTP code snippet generator for PHP using curl-ext. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var helpers = require('./helpers') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + closingTag: false, + indent: ' ', + noTags: false, + shortTags: false + }, options) + + var code = new CodeBuilder(opts.indent) + + if (!opts.noTags) { + code.push(opts.shortTags ? 'setUrl(%s);', helpers.convert(source.url)) + + if (~helpers.methods.indexOf(source.method.toUpperCase())) { + code.push('$request->setMethod(HTTP_METH_%s);', source.method.toUpperCase()) + } else { + code.push('$request->setMethod(HttpRequest::HTTP_METH_%s);', source.method.toUpperCase()) + } + + code.blank() + + if (Object.keys(source.queryObj).length) { + code.push('$request->setQueryData(%s);', helpers.convert(source.queryObj, opts.indent)) + .blank() + } + + if (Object.keys(source.headersObj).length) { + code.push('$request->setHeaders(%s);', helpers.convert(source.headersObj, opts.indent)) + .blank() + } + + if (Object.keys(source.cookiesObj).length) { + code.push('$request->setCookies(%s);', helpers.convert(source.cookiesObj, opts.indent)) + .blank() + } + + switch (source.postData.mimeType) { + case 'application/x-www-form-urlencoded': + code.push('$request->setContentType(%s);', helpers.convert(source.postData.mimeType)) + .push('$request->setPostFields(%s);', helpers.convert(source.postData.paramsObj, opts.indent)) + .blank() + break + + default: + if (source.postData.text) { + code.push('$request->setBody(%s);', helpers.convert(source.postData.text)) + .blank() + } + } + + code.push('try {') + .push(1, '$response = $request->send();') + .blank() + .push(1, 'echo $response->getBody();') + .push('} catch (HttpException $ex) {') + .push(1, 'echo $ex;') + .push('}') + + if (!opts.noTags && opts.closingTag) { + code.blank() + .push('?>') + } + + return code.join() +} + +module.exports.info = { + key: 'http1', + title: 'HTTP v1', + link: 'http://php.net/manual/en/book.http.php', + description: 'PHP with pecl/http v1' +} diff --git a/packages/insomnia-httpsnippet/src/targets/php/http2.js b/packages/insomnia-httpsnippet/src/targets/php/http2.js new file mode 100755 index 0000000000..9b90617e7a --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/php/http2.js @@ -0,0 +1,129 @@ +/** + * @description + * HTTP code snippet generator for PHP using curl-ext. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var helpers = require('./helpers') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + closingTag: false, + indent: ' ', + noTags: false, + shortTags: false + }, options) + + var code = new CodeBuilder(opts.indent) + var hasBody = false + + if (!opts.noTags) { + code.push(opts.shortTags ? 'append(new http\\QueryString(%s));', helpers.convert(source.postData.paramsObj, opts.indent)) + .blank() + hasBody = true + break + + case 'multipart/form-data': + var files = [] + var fields = {} + + source.postData.params.forEach(function (param) { + if (param.fileName) { + files.push({ + name: param.name, + type: param.contentType, + file: param.fileName, + data: param.value + }) + } else if (param.value) { + fields[param.name] = param.value + } + }) + + code.push('$body = new http\\Message\\Body;') + .push('$body->addForm(%s, %s);', + Object.keys(fields).length ? helpers.convert(fields, opts.indent) : 'NULL', + files.length ? helpers.convert(files, opts.indent) : 'NULL' + ) + + // remove the contentType header + if (~source.headersObj['content-type'].indexOf('boundary')) { + delete source.headersObj['content-type'] + } + + code.blank() + + hasBody = true + break + + default: + if (source.postData.text) { + code.push('$body = new http\\Message\\Body;') + .push('$body->append(%s);', helpers.convert(source.postData.text)) + .blank() + hasBody = true + } + } + + code.push('$request->setRequestUrl(%s);', helpers.convert(source.url)) + .push('$request->setRequestMethod(%s);', helpers.convert(source.method)) + + if (hasBody) { + code.push('$request->setBody($body);') + .blank() + } + + if (Object.keys(source.queryObj).length) { + code.push('$request->setQuery(new http\\QueryString(%s));', helpers.convert(source.queryObj, opts.indent)) + .blank() + } + + if (Object.keys(source.headersObj).length) { + code.push('$request->setHeaders(%s);', helpers.convert(source.headersObj, opts.indent)) + .blank() + } + + if (Object.keys(source.cookiesObj).length) { + code.blank() + .push('$client->setCookies(%s);', helpers.convert(source.cookiesObj, opts.indent)) + .blank() + } + + code.push('$client->enqueue($request)->send();') + .push('$response = $client->getResponse();') + .blank() + .push('echo $response->getBody();') + + if (!opts.noTags && opts.closingTag) { + code.blank() + .push('?>') + } + + return code.join() +} + +module.exports.info = { + key: 'http2', + title: 'HTTP v2', + link: 'http://devel-m6w6.rhcloud.com/mdref/http', + description: 'PHP with pecl/http v2' +} diff --git a/packages/insomnia-httpsnippet/src/targets/php/index.js b/packages/insomnia-httpsnippet/src/targets/php/index.js new file mode 100755 index 0000000000..39f6bfa1a1 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/php/index.js @@ -0,0 +1,14 @@ +'use strict' + +module.exports = { + info: { + key: 'php', + title: 'PHP', + extname: '.php', + default: 'curl' + }, + + curl: require('./curl'), + http1: require('./http1'), + http2: require('./http2') +} diff --git a/packages/insomnia-httpsnippet/src/targets/python/index.js b/packages/insomnia-httpsnippet/src/targets/python/index.js new file mode 100755 index 0000000000..38f5ee7366 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/python/index.js @@ -0,0 +1,13 @@ +'use strict' + +module.exports = { + info: { + key: 'python', + title: 'Python', + extname: '.py', + default: 'python3' + }, + + python3: require('./python3'), + requests: require('./requests') +} diff --git a/packages/insomnia-httpsnippet/src/targets/python/python3.js b/packages/insomnia-httpsnippet/src/targets/python/python3.js new file mode 100755 index 0000000000..753a6571af --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/python/python3.js @@ -0,0 +1,92 @@ +/** + * @description + * HTTP code snippet generator for native Python3. + * + * @author + * @montanaflynn + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var code = new CodeBuilder() + // Start Request + code.push('import http.client') + .blank() + + // Check which protocol to be used for the client connection + var protocol = source.uriObj.protocol + if (protocol === 'https:') { + code.push('conn = http.client.HTTPSConnection("%s")', source.uriObj.host) + .blank() + } else { + code.push('conn = http.client.HTTPConnection("%s")', source.uriObj.host) + .blank() + } + + // Create payload string if it exists + var payload = JSON.stringify(source.postData.text) + if (payload) { + code.push('payload = %s', payload) + .blank() + } + + // Create Headers + var header + var headers = source.allHeaders + var headerCount = Object.keys(headers).length + if (headerCount === 1) { + for (header in headers) { + code.push('headers = { \'%s\': "%s" }', header, headers[header]) + .blank() + } + } else if (headerCount > 1) { + var count = 1 + + code.push('headers = {') + + for (header in headers) { + if (count++ !== headerCount) { + code.push(' \'%s\': "%s",', header, headers[header]) + } else { + code.push(' \'%s\': "%s"', header, headers[header]) + } + } + + code.push(' }') + .blank() + } + + // Make Request + var method = source.method + var path = source.uriObj.path + if (payload && headerCount) { + code.push('conn.request("%s", "%s", payload, headers)', method, path) + } else if (payload && !headerCount) { + code.push('conn.request("%s", "%s", payload)', method, path) + } else if (!payload && headerCount) { + code.push('conn.request("%s", "%s", headers=headers)', method, path) + } else { + code.push('conn.request("%s", "%s")', method, path) + } + + // Get Response + code.blank() + .push('res = conn.getresponse()') + .push('data = res.read()') + .blank() + .push('print(data.decode("utf-8"))') + + return code.join() +} + +module.exports.info = { + key: 'python3', + title: 'http.client', + link: 'https://docs.python.org/3/library/http.client.html', + description: 'Python3 HTTP Client' +} diff --git a/packages/insomnia-httpsnippet/src/targets/python/requests.js b/packages/insomnia-httpsnippet/src/targets/python/requests.js new file mode 100755 index 0000000000..299eff9d79 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/python/requests.js @@ -0,0 +1,104 @@ +/** + * @description + * HTTP code snippet generator for Python using Requests + * + * @author + * @montanaflynn + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + // Start snippet + var code = new CodeBuilder(' ') + + // Import requests + code.push('import requests') + .blank() + + // Set URL + code.push('url = "%s"', source.url) + .blank() + + // Construct query string + if (source.queryString.length) { + var qs = 'querystring = ' + JSON.stringify(source.queryObj) + + code.push(qs) + .blank() + } + + // Construct payload + var payload = JSON.stringify(source.postData.text) + + if (payload) { + code.push('payload = %s', payload) + } + + // Construct headers + var header + var headers = source.allHeaders + var headerCount = Object.keys(headers).length + + if (headerCount === 1) { + for (header in headers) { + code.push('headers = {\'%s\': \'%s\'}', header, headers[header]) + .blank() + } + } else if (headerCount > 1) { + var count = 1 + + code.push('headers = {') + + for (header in headers) { + if (count++ !== headerCount) { + code.push(1, '\'%s\': "%s",', header, headers[header]) + } else { + code.push(1, '\'%s\': "%s"', header, headers[header]) + } + } + + code.push(1, '}') + .blank() + } + + // Construct request + var method = source.method + var request = util.format('response = requests.request("%s", url', method) + + if (payload) { + request += ', data=payload' + } + + if (headerCount > 0) { + request += ', headers=headers' + } + + if (qs) { + request += ', params=querystring' + } + + request += ')' + + code.push(request) + .blank() + + // Print response + .push('print(response.text)') + + return code.join() +} + +module.exports.info = { + key: 'requests', + title: 'Requests', + link: 'http://docs.python-requests.org/en/latest/api/#requests.request', + description: 'Requests HTTP library' +} + +// response = requests.request("POST", url, data=payload, headers=headers, params=querystring) diff --git a/packages/insomnia-httpsnippet/src/targets/ruby/index.js b/packages/insomnia-httpsnippet/src/targets/ruby/index.js new file mode 100755 index 0000000000..1118a1b804 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/ruby/index.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = { + info: { + key: 'ruby', + title: 'Ruby', + extname: '.rb', + default: 'native' + }, + + native: require('./native') +} diff --git a/packages/insomnia-httpsnippet/src/targets/ruby/native.js b/packages/insomnia-httpsnippet/src/targets/ruby/native.js new file mode 100755 index 0000000000..86d49af2c5 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/ruby/native.js @@ -0,0 +1,61 @@ +'use strict' + +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var code = new CodeBuilder() + + code.push('require \'uri\'') + .push('require \'net/http\'') + .blank() + + // To support custom methods we check for the supported methods + // and if doesn't exist then we build a custom class for it + var method = source.method.toUpperCase() + var methods = ['GET', 'POST', 'HEAD', 'DELETE', 'PATCH', 'PUT', 'OPTIONS', 'COPY', 'LOCK', 'UNLOCK', 'MOVE', 'TRACE'] + var capMethod = method.charAt(0) + method.substring(1).toLowerCase() + if (methods.indexOf(method) < 0) { + code.push('class Net::HTTP::%s < Net::HTTPRequest', capMethod) + .push(' METHOD = \'%s\'', method.toUpperCase()) + .push(' REQUEST_HAS_BODY = \'%s\'', source.postData.text ? 'true' : 'false') + .push(' RESPONSE_HAS_BODY = true') + .push('end') + .blank() + } + + code.push('url = URI("%s")', source.fullUrl) + .blank() + .push('http = Net::HTTP.new(url.host, url.port)') + + if (source.uriObj.protocol === 'https:') { + code.push('http.use_ssl = true') + .push('http.verify_mode = OpenSSL::SSL::VERIFY_NONE') + } + + code.blank() + .push('request = Net::HTTP::%s.new(url)', capMethod) + + var headers = Object.keys(source.allHeaders) + if (headers.length) { + headers.forEach(function (key) { + code.push('request["%s"] = \'%s\'', key, source.allHeaders[key]) + }) + } + + if (source.postData.text) { + code.push('request.body = %s', JSON.stringify(source.postData.text)) + } + + code.blank() + .push('response = http.request(request)') + .push('puts response.read_body') + + return code.join() +} + +module.exports.info = { + key: 'native', + title: 'net::http', + link: 'http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html', + description: 'Ruby HTTP client' +} diff --git a/packages/insomnia-httpsnippet/src/targets/shell/curl.js b/packages/insomnia-httpsnippet/src/targets/shell/curl.js new file mode 100755 index 0000000000..e8fd516fb9 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/shell/curl.js @@ -0,0 +1,75 @@ +/** + * @description + * HTTP code snippet generator for the Shell using cURL. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var helpers = require('../../helpers/shell') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ', + short: false, + binary: false + }, options) + + var code = new CodeBuilder(opts.indent, opts.indent !== false ? ' \\\n' + opts.indent : ' ') + + code.push('curl %s %s', opts.short ? '-X' : '--request', source.method) + .push(util.format('%s%s', opts.short ? '' : '--url ', helpers.quote(source.fullUrl))) + + if (source.httpVersion === 'HTTP/1.0') { + code.push(opts.short ? '-0' : '--http1.0') + } + + // construct headers + Object.keys(source.headersObj).sort().forEach(function (key) { + var header = util.format('%s: %s', key, source.headersObj[key]) + code.push('%s %s', opts.short ? '-H' : '--header', helpers.quote(header)) + }) + + if (source.allHeaders.cookie) { + code.push('%s %s', opts.short ? '-b' : '--cookie', helpers.quote(source.allHeaders.cookie)) + } + + // construct post params + switch (source.postData.mimeType) { + case 'multipart/form-data': + source.postData.params.map(function (param) { + var post = util.format('%s=%s', param.name, param.value) + + if (param.fileName && !param.value) { + post = util.format('%s=@%s', param.name, param.fileName) + } + + code.push('%s %s', opts.short ? '-F' : '--form', helpers.quote(post)) + }) + break + + default: + // raw request body + if (source.postData.text) { + code.push( + '%s %s', opts.binary ? '--data-binary' : (opts.short ? '-d' : '--data'), + helpers.quote(source.postData.text) + ) + } + } + + return code.join() +} + +module.exports.info = { + key: 'curl', + title: 'cURL', + link: 'http://curl.haxx.se/', + description: 'cURL is a command line tool and library for transferring data with URL syntax' +} diff --git a/packages/insomnia-httpsnippet/src/targets/shell/httpie.js b/packages/insomnia-httpsnippet/src/targets/shell/httpie.js new file mode 100755 index 0000000000..b5aff91de0 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/shell/httpie.js @@ -0,0 +1,123 @@ +/** + * @description + * HTTP code snippet generator for the Shell using HTTPie. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var shell = require('../../helpers/shell') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + body: false, + cert: false, + headers: false, + indent: ' ', + pretty: false, + print: false, + queryParams: false, + short: false, + style: false, + timeout: false, + verbose: false, + verify: false + }, options) + + var code = new CodeBuilder(opts.indent, opts.indent !== false ? ' \\\n' + opts.indent : ' ') + + var raw = false + var flags = [] + + if (opts.headers) { + flags.push(opts.short ? '-h' : '--headers') + } + + if (opts.body) { + flags.push(opts.short ? '-b' : '--body') + } + + if (opts.verbose) { + flags.push(opts.short ? '-v' : '--verbose') + } + + if (opts.print) { + flags.push(util.format('%s=%s', opts.short ? '-p' : '--print', opts.print)) + } + + if (opts.verify) { + flags.push(util.format('--verify=%s', opts.verify)) + } + + if (opts.cert) { + flags.push(util.format('--cert=%s', opts.cert)) + } + + if (opts.pretty) { + flags.push(util.format('--pretty=%s', opts.pretty)) + } + + if (opts.style) { + flags.push(util.format('--style=%s', opts.pretty)) + } + + if (opts.timeout) { + flags.push(util.format('--timeout=%s', opts.timeout)) + } + + // construct query params + if (opts.queryParams) { + var queryStringKeys = Object.keys(source.queryObj) + + queryStringKeys.forEach(function (name) { + var value = source.queryObj[name] + + if (util.isArray(value)) { + value.forEach(function (val) { + code.push('%s==%s', name, shell.quote(val)) + }) + } else { + code.push('%s==%s', name, shell.quote(value)) + } + }) + } + + // construct headers + Object.keys(source.allHeaders).sort().forEach(function (key) { + code.push('%s:%s', key, shell.quote(source.allHeaders[key])) + }) + + if (source.postData.mimeType === 'application/x-www-form-urlencoded') { + // construct post params + if (source.postData.params && source.postData.params.length) { + flags.push(opts.short ? '-f' : '--form') + + source.postData.params.forEach(function (param) { + code.push('%s=%s', param.name, shell.quote(param.value)) + }) + } + } else { + raw = true + } + + code.unshift('http %s%s %s', flags.length ? flags.join(' ') + ' ' : '', source.method, shell.quote(opts.queryParams ? source.url : source.fullUrl)) + + if (raw && source.postData.text) { + code.unshift('echo %s | ', shell.quote(source.postData.text)) + } + + return code.join() +} + +module.exports.info = { + key: 'httpie', + title: 'HTTPie', + link: 'http://httpie.org/', + description: 'a CLI, cURL-like tool for humans' +} diff --git a/packages/insomnia-httpsnippet/src/targets/shell/index.js b/packages/insomnia-httpsnippet/src/targets/shell/index.js new file mode 100755 index 0000000000..0f5fc05f0c --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/shell/index.js @@ -0,0 +1,14 @@ +'use strict' + +module.exports = { + info: { + key: 'shell', + title: 'Shell', + extname: '.sh', + default: 'curl' + }, + + curl: require('./curl'), + httpie: require('./httpie'), + wget: require('./wget') +} diff --git a/packages/insomnia-httpsnippet/src/targets/shell/wget.js b/packages/insomnia-httpsnippet/src/targets/shell/wget.js new file mode 100755 index 0000000000..5bce77ab0c --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/shell/wget.js @@ -0,0 +1,54 @@ +/** + * @description + * HTTP code snippet generator for the Shell using Wget. + * + * @author + * @AhmadNassri + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var helpers = require('../../helpers/shell') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ', + short: false, + verbose: false + }, options) + + var code = new CodeBuilder(opts.indent, opts.indent !== false ? ' \\\n' + opts.indent : ' ') + + if (opts.verbose) { + code.push('wget %s', opts.short ? '-v' : '--verbose') + } else { + code.push('wget %s', opts.short ? '-q' : '--quiet') + } + + code.push('--method %s', helpers.quote(source.method)) + + Object.keys(source.allHeaders).forEach(function (key) { + var header = util.format('%s: %s', key, source.allHeaders[key]) + code.push('--header %s', helpers.quote(header)) + }) + + if (source.postData.text) { + code.push('--body-data ' + helpers.escape(helpers.quote(source.postData.text))) + } + + code.push(opts.short ? '-O' : '--output-document') + .push('- %s', helpers.quote(source.fullUrl)) + + return code.join() +} + +module.exports.info = { + key: 'wget', + title: 'Wget', + link: 'https://www.gnu.org/software/wget/', + description: 'a free software package for retrieving files using HTTP, HTTPS' +} diff --git a/packages/insomnia-httpsnippet/src/targets/swift/helpers.js b/packages/insomnia-httpsnippet/src/targets/swift/helpers.js new file mode 100755 index 0000000000..af74d8f36e --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/swift/helpers.js @@ -0,0 +1,80 @@ +'use strict' + +var util = require('util') + +/** + * Create an string of given length filled with blank spaces + * + * @param {number} length Length of the array to return + * @return {string} + */ +function buildString (length, str) { + return Array.apply(null, new Array(length)).map(String.prototype.valueOf, str).join('') +} + +/** + * Create a string corresponding to a Dictionary or Array literal representation with pretty option + * and indentation. + */ +function concatArray (arr, pretty, indentation, indentLevel) { + var currentIndent = buildString(indentLevel, indentation) + var closingBraceIndent = buildString(indentLevel - 1, indentation) + var join = pretty ? ',\n' + currentIndent : ', ' + + if (pretty) { + return '[\n' + currentIndent + arr.join(join) + '\n' + closingBraceIndent + ']' + } else { + return '[' + arr.join(join) + ']' + } +} + +module.exports = { + /** + * Create a string corresponding to a valid declaration and initialization of a Swift array or dictionary literal + * + * @param {string} name Desired name of the instance + * @param {Object} parameters Key-value object of parameters to translate to a Swift object litearal + * @param {Object} opts Target options + * @return {string} + */ + literalDeclaration: function (name, parameters, opts) { + return util.format('let %s = %s', name, this.literalRepresentation(parameters, opts)) + }, + + /** + * Create a valid Swift string of a literal value according to its type. + * + * @param {*} value Any JavaScript literal + * @param {Object} opts Target options + * @return {string} + */ + literalRepresentation: function (value, opts, indentLevel) { + indentLevel = indentLevel === undefined ? 1 : indentLevel + 1 + + switch (Object.prototype.toString.call(value)) { + case '[object Number]': + return value + case '[object Array]': + // Don't prettify arrays nto not take too much space + var pretty = false + var valuesRepresentation = value.map(function (v) { + // Switch to prettify if the value is a dictionary with multiple keys + if (Object.prototype.toString.call(v) === '[object Object]') { + pretty = Object.keys(v).length > 1 + } + return this.literalRepresentation(v, opts, indentLevel) + }.bind(this)) + return concatArray(valuesRepresentation, pretty, opts.indent, indentLevel) + case '[object Object]': + var keyValuePairs = [] + for (var k in value) { + keyValuePairs.push(util.format('"%s": %s', k, this.literalRepresentation(value[k], opts, indentLevel))) + } + return concatArray(keyValuePairs, opts.pretty && keyValuePairs.length > 1, opts.indent, indentLevel) + case '[object Boolean]': + return value.toString() + default: + return '"' + value.toString().replace(/"/g, '\\"') + '"' + } + } +} diff --git a/packages/insomnia-httpsnippet/src/targets/swift/index.js b/packages/insomnia-httpsnippet/src/targets/swift/index.js new file mode 100755 index 0000000000..fba4dfea20 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/swift/index.js @@ -0,0 +1,12 @@ +'use strict' + +module.exports = { + info: { + key: 'swift', + title: 'Swift', + extname: '.swift', + default: 'nsurlsession' + }, + + nsurlsession: require('./nsurlsession') +} diff --git a/packages/insomnia-httpsnippet/src/targets/swift/nsurlsession.js b/packages/insomnia-httpsnippet/src/targets/swift/nsurlsession.js new file mode 100755 index 0000000000..6bf6f78194 --- /dev/null +++ b/packages/insomnia-httpsnippet/src/targets/swift/nsurlsession.js @@ -0,0 +1,139 @@ +/** + * @description + * HTTP code snippet generator for Swift using NSURLSession. + * + * @author + * @thibaultCha + * + * for any questions or issues regarding the generated code snippet, please open an issue mentioning the author. + */ + +'use strict' + +var util = require('util') +var helpers = require('./helpers') +var CodeBuilder = require('../../helpers/code-builder') + +module.exports = function (source, options) { + var opts = util._extend({ + indent: ' ', + pretty: true, + timeout: '10' + }, options) + + var code = new CodeBuilder(opts.indent) + + // Markers for headers to be created as litteral objects and later be set on the NSURLRequest if exist + var req = { + hasHeaders: false, + hasBody: false + } + + // We just want to make sure people understand that is the only dependency + code.push('import Foundation') + + if (Object.keys(source.allHeaders).length) { + req.hasHeaders = true + code.blank() + .push(helpers.literalDeclaration('headers', source.allHeaders, opts)) + } + + if (source.postData.text || source.postData.jsonObj || source.postData.params) { + req.hasBody = true + + switch (source.postData.mimeType) { + case 'application/x-www-form-urlencoded': + // By appending parameters one by one in the resulting snippet, + // we make it easier for the user to edit it according to his or her needs after pasting. + // The user can just add/remove lines adding/removing body parameters. + code.blank() + .push('let postData = NSMutableData(data: "%s=%s".data(using: String.Encoding.utf8)!)', source.postData.params[0].name, source.postData.params[0].value) + for (var i = 1, len = source.postData.params.length; i < len; i++) { + code.push('postData.append("&%s=%s".data(using: String.Encoding.utf8)!)', source.postData.params[i].name, source.postData.params[i].value) + } + break + + case 'application/json': + if (source.postData.jsonObj) { + code.push(helpers.literalDeclaration('parameters', source.postData.jsonObj, opts), 'as [String : Any]') + .blank() + .push('let postData = JSONSerialization.data(withJSONObject: parameters, options: [])') + } + break + + case 'multipart/form-data': + /** + * By appending multipart parameters one by one in the resulting snippet, + * we make it easier for the user to edit it according to his or her needs after pasting. + * The user can just edit the parameters NSDictionary or put this part of a snippet in a multipart builder method. + */ + code.push(helpers.literalDeclaration('parameters', source.postData.params, opts)) + .blank() + .push('let boundary = "%s"', source.postData.boundary) + .blank() + .push('var body = ""') + .push('var error: NSError? = nil') + .push('for param in parameters {') + .push(1, 'let paramName = param["name"]!') + .push(1, 'body += "--\\(boundary)\\r\\n"') + .push(1, 'body += "Content-Disposition:form-data; name=\\"\\(paramName)\\""') + .push(1, 'if let filename = param["fileName"] {') + .push(2, 'let contentType = param["content-type"]!') + .push(2, 'let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)') + .push(2, 'if (error != nil) {') + .push(3, 'print(error)') + .push(2, '}') + .push(2, 'body += "; filename=\\"\\(filename)\\"\\r\\n"') + .push(2, 'body += "Content-Type: \\(contentType)\\r\\n\\r\\n"') + .push(2, 'body += fileContent') + .push(1, '} else if let paramValue = param["value"] {') + .push(2, 'body += "\\r\\n\\r\\n\\(paramValue)"') + .push(1, '}') + .push('}') + break + + default: + code.blank() + .push('let postData = NSData(data: "%s".data(using: String.Encoding.utf8)!)', source.postData.text) + } + } + + code.blank() + // NSURLRequestUseProtocolCachePolicy is the default policy, let's just always set it to avoid confusion. + .push('let request = NSMutableURLRequest(url: NSURL(string: "%s")! as URL,', source.fullUrl) + .push(' cachePolicy: .useProtocolCachePolicy,') + .push(' timeoutInterval: %s)', parseInt(opts.timeout, 10).toFixed(1)) + .push('request.httpMethod = "%s"', source.method) + + if (req.hasHeaders) { + code.push('request.allHTTPHeaderFields = headers') + } + + if (req.hasBody) { + code.push('request.httpBody = postData as Data') + } + + code.blank() + // Retrieving the shared session will be less verbose than creating a new one. + .push('let session = URLSession.shared') + .push('let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in') + .push(1, 'if (error != nil) {') + .push(2, 'print(error)') + .push(1, '} else {') + // Casting the NSURLResponse to NSHTTPURLResponse so the user can see the status . + .push(2, 'let httpResponse = response as? HTTPURLResponse') + .push(2, 'print(httpResponse)') + .push(1, '}') + .push('})') + .blank() + .push('dataTask.resume()') + + return code.join() +} + +module.exports.info = { + key: 'nsurlsession', + title: 'NSURLSession', + link: 'https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSURLSession_class/index.html', + description: 'Foundation\'s NSURLSession request' +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/available-targets.json b/packages/insomnia-httpsnippet/test/fixtures/available-targets.json new file mode 100755 index 0000000000..5d78841dca --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/available-targets.json @@ -0,0 +1,238 @@ +[ + { + "key": "shell", + "title": "Shell", + "extname": ".sh", + "default": "curl", + "clients": [ + { + "key": "curl", + "title": "cURL", + "link": "http://curl.haxx.se/", + "description": "cURL is a command line tool and library for transferring data with URL syntax" + }, + { + "key": "httpie", + "title": "HTTPie", + "link": "http://httpie.org/", + "description": "a CLI, cURL-like tool for humans" + }, + { + "key": "wget", + "title": "Wget", + "link": "https://www.gnu.org/software/wget/", + "description": "a free software package for retrieving files using HTTP, HTTPS" + } + ] + }, + { + "key": "node", + "title": "Node.js", + "extname": ".js", + "default": "native", + "clients": [ + { + "key": "native", + "title": "HTTP", + "link": "http://nodejs.org/api/http.html#http_http_request_options_callback", + "description": "Node.js native HTTP interface" + }, + { + "key": "request", + "title": "Request", + "link": "https://github.com/request/request", + "description": "Simplified HTTP request client" + }, + { + "key": "unirest", + "title": "Unirest", + "link": "http://unirest.io/nodejs.html", + "description": "Lightweight HTTP Request Client Library" + } + ] + }, + { + "key": "javascript", + "title": "JavaScript", + "extname": ".js", + "default": "xhr", + "clients": [ + { + "key": "jquery", + "title": "jQuery", + "link": "http://api.jquery.com/jquery.ajax/", + "description": "Perform an asynchronous HTTP (Ajax) requests with jQuery" + }, + { + "key": "xhr", + "title": "XMLHttpRequest", + "link": "https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest", + "description": "W3C Standard API that provides scripted client functionality" + } + ] + }, + { + "key": "ocaml", + "title": "OCaml", + "extname": ".ml", + "default": "cohttp", + "clients": [ + { + "key": "cohttp", + "title": "CoHTTP", + "link": "https://github.com/mirage/ocaml-cohttp", + "description": "Cohttp is a very lightweight HTTP server using Lwt or Async for OCaml" + } + ] + }, + { + "key": "php", + "title": "PHP", + "extname": ".php", + "default": "curl", + "clients": [ + { + "key": "curl", + "title": "cURL", + "link": "http://php.net/manual/en/book.curl.php", + "description": "PHP with ext-curl" + }, + { + "key": "http1", + "title": "HTTP v1", + "link": "http://php.net/manual/en/book.http.php", + "description": "PHP with pecl/http v1" + }, + { + "key": "http2", + "title": "HTTP v2", + "link": "http://devel-m6w6.rhcloud.com/mdref/http", + "description": "PHP with pecl/http v2" + } + ] + }, + { + "key": "python", + "title": "Python", + "extname": ".py", + "default": "python3", + "clients": [ + { + "key": "python3", + "title": "http.client", + "link": "https://docs.python.org/3/library/http.client.html", + "description": "Python3 HTTP Client" + }, + { + "key": "requests", + "title": "Requests", + "link": "http://docs.python-requests.org/en/latest/api/#requests.request", + "description": "Requests HTTP library" + } + ] + }, + { + "key": "objc", + "title": "Objective-C", + "extname": ".m", + "default": "nsurlsession", + "clients": [ + { + "key": "nsurlsession", + "title": "NSURLSession", + "link": "https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSURLSession_class/index.html", + "description": "Foundation's NSURLSession request" + } + ] + }, + { + "key": "swift", + "title": "Swift", + "extname": ".swift", + "default": "nsurlsession", + "clients": [ + { + "key": "nsurlsession", + "title": "NSURLSession", + "link": "https://developer.apple.com/library/mac/documentation/Foundation/Reference/NSURLSession_class/index.html", + "description": "Foundation's NSURLSession request" + } + ] + }, + { + "key": "go", + "title": "Go", + "extname": ".go", + "default": "native", + "clients": [ + { + "key": "native", + "title": "NewRequest", + "link": "http://golang.org/pkg/net/http/#NewRequest", + "description": "Golang HTTP client request" + } + ] + }, + { + "key": "java", + "title": "Java", + "extname": ".java", + "default": "unirest", + "clients": [ + { + "key": "okhttp", + "title": "OkHttp", + "link": "http://square.github.io/okhttp/", + "description": "An HTTP Request Client Library" + }, + { + "key": "unirest", + "title": "Unirest", + "link": "http://unirest.io/java.html", + "description": "Lightweight HTTP Request Client Library" + } + ] + }, + { + "key": "ruby", + "title": "Ruby", + "extname": ".rb", + "default": "native", + "clients": [ + { + "key": "native", + "title": "net::http", + "link": "http://ruby-doc.org/stdlib-2.2.1/libdoc/net/http/rdoc/Net/HTTP.html", + "description": "Ruby HTTP client" + } + ] + }, + { + "key": "csharp", + "title": "C#", + "extname": ".cs", + "default": "restsharp", + "clients": [ + { + "key": "restsharp", + "title": "RestSharp", + "link": "http://restsharp.org/", + "description": "Simple REST and HTTP API Client for .NET" + } + ] + }, + { + "key": "c", + "title": "C", + "extname": ".c", + "default": "libcurl", + "clients": [ + { + "key": "libcurl", + "title": "Libcurl", + "link": "http://curl.haxx.se/libcurl/", + "description": "Simple REST and HTTP API Client for C" + } + ] + } +] diff --git a/packages/insomnia-httpsnippet/test/fixtures/cli.json b/packages/insomnia-httpsnippet/test/fixtures/cli.json new file mode 100755 index 0000000000..70cbcd19cd --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/cli.json @@ -0,0 +1,25 @@ +[ + { + "run": "node %s", + "target":"node", + "clients": [ + "native" + ] + }, + + { + "run": "php %s", + "target": "php", + "clients": [ + "curl" + ] + }, + + { + "run": "python3 %s", + "target": "python", + "clients": [ + "python3" + ] + } +] diff --git a/packages/insomnia-httpsnippet/test/fixtures/curl/http1.json b/packages/insomnia-httpsnippet/test/fixtures/curl/http1.json new file mode 100755 index 0000000000..db0c3d8ced --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/curl/http1.json @@ -0,0 +1,5 @@ +{ + "method": "GET", + "url": "http://mockbin.com/request", + "httpVersion": "HTTP/1.0" +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/curl/index.js b/packages/insomnia-httpsnippet/test/fixtures/curl/index.js new file mode 100755 index 0000000000..0d8e0250ca --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/curl/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('require-directory')(module); diff --git a/packages/insomnia-httpsnippet/test/fixtures/files/hello.txt b/packages/insomnia-httpsnippet/test/fixtures/files/hello.txt new file mode 100755 index 0000000000..557db03de9 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/files/hello.txt @@ -0,0 +1 @@ +Hello World diff --git a/packages/insomnia-httpsnippet/test/fixtures/har.json b/packages/insomnia-httpsnippet/test/fixtures/har.json new file mode 100755 index 0000000000..a48c0715a8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/har.json @@ -0,0 +1,23 @@ +{ + "log": { + "version": "1.2", + "creator": { + "name": "HTTPSnippet", + "version": "1.0.0" + }, + "entries": [ + { + "request": { + "method": "GET", + "url": "http://mockbin.com/har" + } + }, + { + "request": { + "method": "POST", + "url": "http://mockbin.com/har" + } + } + ] + } +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/index.js b/packages/insomnia-httpsnippet/test/fixtures/index.js new file mode 100755 index 0000000000..da75cf83db --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/index.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = require('require-directory')(module, {exclude: /output/}) diff --git a/packages/insomnia-httpsnippet/test/fixtures/mimetypes.json b/packages/insomnia-httpsnippet/test/fixtures/mimetypes.json new file mode 100755 index 0000000000..eb292c8d23 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/mimetypes.json @@ -0,0 +1,74 @@ +{ + "multipart/mixed": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "multipart/mixed" + } + }, + + "multipart/related": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "multipart/related" + } + }, + + "multipart/form-data": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "multipart/form-data" + } + }, + + "multipart/alternative": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "multipart/alternative" + } + }, + + "application/x-www-form-urlencoded": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "application/x-www-form-urlencoded" + } + }, + + "text/json": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "text/json" + } + }, + + "text/x-json": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "text/x-json" + } + }, + + "application/x-json": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "application/x-json" + } + }, + + "invalid-json": { + "method": "POST", + "url": "http://mockbin.com/har", + "postData": { + "mimeType": "application/json", + "text": "foo/bar" + } + } +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/application-form-encoded.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/application-form-encoded.c new file mode 100755 index 0000000000..bf14b11340 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/application-form-encoded.c @@ -0,0 +1,12 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +struct curl_slist *headers = NULL; +headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded"); +curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); + +curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&hello=world"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/application-json.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/application-json.c new file mode 100755 index 0000000000..e1318a5782 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/application-json.c @@ -0,0 +1,12 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +struct curl_slist *headers = NULL; +headers = curl_slist_append(headers, "content-type: application/json"); +curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); + +curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/cookies.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/cookies.c new file mode 100755 index 0000000000..92fa7053d3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/cookies.c @@ -0,0 +1,8 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +curl_easy_setopt(hnd, CURLOPT_COOKIE, "foo=bar; bar=baz"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/custom-method.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/custom-method.c new file mode 100755 index 0000000000..12045a0b3e --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/custom-method.c @@ -0,0 +1,6 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "PROPFIND"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/full.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/full.c new file mode 100755 index 0000000000..4b47fb2d5f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/full.c @@ -0,0 +1,15 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"); + +struct curl_slist *headers = NULL; +headers = curl_slist_append(headers, "content-type: application/x-www-form-urlencoded"); +headers = curl_slist_append(headers, "accept: application/json"); +curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); + +curl_easy_setopt(hnd, CURLOPT_COOKIE, "foo=bar; bar=baz"); + +curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/headers.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/headers.c new file mode 100755 index 0000000000..3ae9a12995 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/headers.c @@ -0,0 +1,11 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +struct curl_slist *headers = NULL; +headers = curl_slist_append(headers, "x-foo: Bar"); +headers = curl_slist_append(headers, "accept: application/json"); +curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/https.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/https.c new file mode 100755 index 0000000000..d5e403be31 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/https.c @@ -0,0 +1,6 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); +curl_easy_setopt(hnd, CURLOPT_URL, "https://mockbin.com/har"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-data.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-data.c new file mode 100755 index 0000000000..80cccdb022 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-data.c @@ -0,0 +1,12 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +struct curl_slist *headers = NULL; +headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001"); +curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); + +curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----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"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-file.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-file.c new file mode 100755 index 0000000000..90e1252783 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-file.c @@ -0,0 +1,12 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +struct curl_slist *headers = NULL; +headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001"); +curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); + +curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----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"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-form-data.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-form-data.c new file mode 100755 index 0000000000..232a092fc9 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/multipart-form-data.c @@ -0,0 +1,12 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +struct curl_slist *headers = NULL; +headers = curl_slist_append(headers, "content-type: multipart/form-data; boundary=---011000010111000001101001"); +curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); + +curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/query.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/query.c new file mode 100755 index 0000000000..709188c904 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/query.c @@ -0,0 +1,6 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/short.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/short.c new file mode 100755 index 0000000000..c858ae76d6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/short.c @@ -0,0 +1,6 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "GET"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/text-plain.c b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/text-plain.c new file mode 100755 index 0000000000..5d8b1fd22f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/c/libcurl/text-plain.c @@ -0,0 +1,12 @@ +CURL *hnd = curl_easy_init(); + +curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); +curl_easy_setopt(hnd, CURLOPT_URL, "http://mockbin.com/har"); + +struct curl_slist *headers = NULL; +headers = curl_slist_append(headers, "content-type: text/plain"); +curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); + +curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "Hello World"); + +CURLcode ret = curl_easy_perform(hnd); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/application-form-encoded.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/application-form-encoded.cs new file mode 100755 index 0000000000..96f3f8b695 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/application-form-encoded.cs @@ -0,0 +1,5 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.POST); +request.AddHeader("content-type", "application/x-www-form-urlencoded"); +request.AddParameter("application/x-www-form-urlencoded", "foo=bar&hello=world", ParameterType.RequestBody); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/application-json.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/application-json.cs new file mode 100755 index 0000000000..30a977be98 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/application-json.cs @@ -0,0 +1,5 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.POST); +request.AddHeader("content-type", "application/json"); +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); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/cookies.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/cookies.cs new file mode 100755 index 0000000000..910b4f5801 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/cookies.cs @@ -0,0 +1,5 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.POST); +request.AddCookie("foo", "bar"); +request.AddCookie("bar", "baz"); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/custom-method.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/custom-method.cs new file mode 100755 index 0000000000..5e5237a54a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/custom-method.cs @@ -0,0 +1 @@ +Method not supported diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/full.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/full.cs new file mode 100755 index 0000000000..6ae958e6ce --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/full.cs @@ -0,0 +1,8 @@ +var client = new RestClient("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"); +var request = new RestRequest(Method.POST); +request.AddHeader("content-type", "application/x-www-form-urlencoded"); +request.AddHeader("accept", "application/json"); +request.AddCookie("foo", "bar"); +request.AddCookie("bar", "baz"); +request.AddParameter("application/x-www-form-urlencoded", "foo=bar", ParameterType.RequestBody); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/headers.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/headers.cs new file mode 100755 index 0000000000..df9ee86f5a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/headers.cs @@ -0,0 +1,5 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.GET); +request.AddHeader("x-foo", "Bar"); +request.AddHeader("accept", "application/json"); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/https.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/https.cs new file mode 100755 index 0000000000..8be49d72bd --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/https.cs @@ -0,0 +1,3 @@ +var client = new RestClient("https://mockbin.com/har"); +var request = new RestRequest(Method.GET); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-data.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-data.cs new file mode 100755 index 0000000000..9db5bec09d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-data.cs @@ -0,0 +1,5 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.POST); +request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001"); +request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----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", ParameterType.RequestBody); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-file.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-file.cs new file mode 100755 index 0000000000..d91e66b4c9 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-file.cs @@ -0,0 +1,5 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.POST); +request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001"); +request.AddParameter("multipart/form-data; boundary=---011000010111000001101001", "-----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", ParameterType.RequestBody); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-form-data.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-form-data.cs new file mode 100755 index 0000000000..1ad23e37ac --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/multipart-form-data.cs @@ -0,0 +1,5 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.POST); +request.AddHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001"); +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); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/query.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/query.cs new file mode 100755 index 0000000000..9384530752 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/query.cs @@ -0,0 +1,3 @@ +var client = new RestClient("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"); +var request = new RestRequest(Method.GET); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/short.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/short.cs new file mode 100755 index 0000000000..eb5c9f5109 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/short.cs @@ -0,0 +1,3 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.GET); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/text-plain.cs b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/text-plain.cs new file mode 100755 index 0000000000..958eb97d44 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/csharp/restsharp/text-plain.cs @@ -0,0 +1,5 @@ +var client = new RestClient("http://mockbin.com/har"); +var request = new RestRequest(Method.POST); +request.AddHeader("content-type", "text/plain"); +request.AddParameter("text/plain", "Hello World", ParameterType.RequestBody); +IRestResponse response = client.Execute(request); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/application-form-encoded.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/application-form-encoded.go new file mode 100755 index 0000000000..5344b4ea09 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/application-form-encoded.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + payload := strings.NewReader("foo=bar&hello=world") + + req, _ := http.NewRequest("POST", url, payload) + + req.Header.Add("content-type", "application/x-www-form-urlencoded") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/application-json.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/application-json.go new file mode 100755 index 0000000000..c9dba6a0bd --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/application-json.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + payload := strings.NewReader("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}") + + req, _ := http.NewRequest("POST", url, payload) + + req.Header.Add("content-type", "application/json") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/cookies.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/cookies.go new file mode 100755 index 0000000000..cd706384e7 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/cookies.go @@ -0,0 +1,25 @@ +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + req, _ := http.NewRequest("POST", url, nil) + + req.Header.Add("cookie", "foo=bar; bar=baz") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/custom-method.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/custom-method.go new file mode 100755 index 0000000000..00c86aeb8c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/custom-method.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + req, _ := http.NewRequest("PROPFIND", url, nil) + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/full.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/full.go new file mode 100755 index 0000000000..7166a6ab23 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/full.go @@ -0,0 +1,30 @@ +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value" + + payload := strings.NewReader("foo=bar") + + req, _ := http.NewRequest("POST", url, payload) + + req.Header.Add("cookie", "foo=bar; bar=baz") + req.Header.Add("accept", "application/json") + req.Header.Add("content-type", "application/x-www-form-urlencoded") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/headers.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/headers.go new file mode 100755 index 0000000000..0d09039ff2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/headers.go @@ -0,0 +1,26 @@ +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + req, _ := http.NewRequest("GET", url, nil) + + req.Header.Add("accept", "application/json") + req.Header.Add("x-foo", "Bar") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/https.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/https.go new file mode 100755 index 0000000000..40e77239dd --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/https.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + + url := "https://mockbin.com/har" + + req, _ := http.NewRequest("GET", url, nil) + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-data.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-data.go new file mode 100755 index 0000000000..3bc875abc3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-data.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + payload := strings.NewReader("-----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") + + req, _ := http.NewRequest("POST", url, payload) + + req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-file.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-file.go new file mode 100755 index 0000000000..931cd280b2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-file.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + payload := strings.NewReader("-----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") + + req, _ := http.NewRequest("POST", url, payload) + + req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-form-data.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-form-data.go new file mode 100755 index 0000000000..d587d473f3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/multipart-form-data.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n") + + req, _ := http.NewRequest("POST", url, payload) + + req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/query.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/query.go new file mode 100755 index 0000000000..e2e47aca64 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/query.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value" + + req, _ := http.NewRequest("GET", url, nil) + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/short.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/short.go new file mode 100755 index 0000000000..441f2a0620 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/short.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + req, _ := http.NewRequest("GET", url, nil) + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/go/native/text-plain.go b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/text-plain.go new file mode 100755 index 0000000000..ccf1c7a6b4 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/go/native/text-plain.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" + "strings" + "net/http" + "io/ioutil" +) + +func main() { + + url := "http://mockbin.com/har" + + payload := strings.NewReader("Hello World") + + req, _ := http.NewRequest("POST", url, payload) + + req.Header.Add("content-type", "text/plain") + + res, _ := http.DefaultClient.Do(req) + + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + fmt.Println(res) + fmt.Println(string(body)) + +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/application-form-encoded.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/application-form-encoded.java new file mode 100755 index 0000000000..0521f00747 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/application-form-encoded.java @@ -0,0 +1,11 @@ +OkHttpClient client = new OkHttpClient(); + +MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); +RequestBody body = RequestBody.create(mediaType, "foo=bar&hello=world"); +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .post(body) + .addHeader("content-type", "application/x-www-form-urlencoded") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/application-json.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/application-json.java new file mode 100755 index 0000000000..a344381dbb --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/application-json.java @@ -0,0 +1,11 @@ +OkHttpClient client = new OkHttpClient(); + +MediaType mediaType = MediaType.parse("application/json"); +RequestBody 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}"); +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .post(body) + .addHeader("content-type", "application/json") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/cookies.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/cookies.java new file mode 100755 index 0000000000..033501272b --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/cookies.java @@ -0,0 +1,9 @@ +OkHttpClient client = new OkHttpClient(); + +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .post(null) + .addHeader("cookie", "foo=bar; bar=baz") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/custom-method.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/custom-method.java new file mode 100755 index 0000000000..817d75ff0a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/custom-method.java @@ -0,0 +1,8 @@ +OkHttpClient client = new OkHttpClient(); + +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .method("PROPFIND", null) + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/full.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/full.java new file mode 100755 index 0000000000..8b8ee15b58 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/full.java @@ -0,0 +1,13 @@ +OkHttpClient client = new OkHttpClient(); + +MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded"); +RequestBody body = RequestBody.create(mediaType, "foo=bar"); +Request request = new Request.Builder() + .url("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") + .post(body) + .addHeader("cookie", "foo=bar; bar=baz") + .addHeader("accept", "application/json") + .addHeader("content-type", "application/x-www-form-urlencoded") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/headers.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/headers.java new file mode 100755 index 0000000000..081a33adb7 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/headers.java @@ -0,0 +1,10 @@ +OkHttpClient client = new OkHttpClient(); + +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .get() + .addHeader("accept", "application/json") + .addHeader("x-foo", "Bar") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/https.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/https.java new file mode 100755 index 0000000000..f9be6532f0 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/https.java @@ -0,0 +1,8 @@ +OkHttpClient client = new OkHttpClient(); + +Request request = new Request.Builder() + .url("https://mockbin.com/har") + .get() + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-data.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-data.java new file mode 100755 index 0000000000..9ad294f823 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-data.java @@ -0,0 +1,11 @@ +OkHttpClient client = new OkHttpClient(); + +MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001"); +RequestBody body = RequestBody.create(mediaType, "-----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"); +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .post(body) + .addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-file.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-file.java new file mode 100755 index 0000000000..6d771f1733 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-file.java @@ -0,0 +1,11 @@ +OkHttpClient client = new OkHttpClient(); + +MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001"); +RequestBody body = RequestBody.create(mediaType, "-----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"); +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .post(body) + .addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-form-data.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-form-data.java new file mode 100755 index 0000000000..ab1e1d2c41 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/multipart-form-data.java @@ -0,0 +1,11 @@ +OkHttpClient client = new OkHttpClient(); + +MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001"); +RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n"); +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .post(body) + .addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/query.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/query.java new file mode 100755 index 0000000000..e105dd4348 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/query.java @@ -0,0 +1,8 @@ +OkHttpClient client = new OkHttpClient(); + +Request request = new Request.Builder() + .url("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") + .get() + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/short.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/short.java new file mode 100755 index 0000000000..5bd44ca990 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/short.java @@ -0,0 +1,8 @@ +OkHttpClient client = new OkHttpClient(); + +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .get() + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/text-plain.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/text-plain.java new file mode 100755 index 0000000000..5501c9aab6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/okhttp/text-plain.java @@ -0,0 +1,11 @@ +OkHttpClient client = new OkHttpClient(); + +MediaType mediaType = MediaType.parse("text/plain"); +RequestBody body = RequestBody.create(mediaType, "Hello World"); +Request request = new Request.Builder() + .url("http://mockbin.com/har") + .post(body) + .addHeader("content-type", "text/plain") + .build(); + +Response response = client.newCall(request).execute(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/application-form-encoded.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/application-form-encoded.java new file mode 100755 index 0000000000..81508b8418 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/application-form-encoded.java @@ -0,0 +1,4 @@ +HttpResponse response = Unirest.post("http://mockbin.com/har") + .header("content-type", "application/x-www-form-urlencoded") + .body("foo=bar&hello=world") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/application-json.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/application-json.java new file mode 100755 index 0000000000..1fd5e3227e --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/application-json.java @@ -0,0 +1,4 @@ +HttpResponse response = Unirest.post("http://mockbin.com/har") + .header("content-type", "application/json") + .body("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/cookies.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/cookies.java new file mode 100755 index 0000000000..ceb408800f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/cookies.java @@ -0,0 +1,3 @@ +HttpResponse response = Unirest.post("http://mockbin.com/har") + .header("cookie", "foo=bar; bar=baz") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/custom-method.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/custom-method.java new file mode 100755 index 0000000000..6ca6d7f296 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/custom-method.java @@ -0,0 +1,2 @@ +HttpResponse response = Unirest.customMethod("PROPFIND","http://mockbin.com/har") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/full.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/full.java new file mode 100755 index 0000000000..f6014e56c4 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/full.java @@ -0,0 +1,6 @@ +HttpResponse response = Unirest.post("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") + .header("cookie", "foo=bar; bar=baz") + .header("accept", "application/json") + .header("content-type", "application/x-www-form-urlencoded") + .body("foo=bar") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/headers.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/headers.java new file mode 100755 index 0000000000..142cf4e75c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/headers.java @@ -0,0 +1,4 @@ +HttpResponse response = Unirest.get("http://mockbin.com/har") + .header("accept", "application/json") + .header("x-foo", "Bar") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/https.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/https.java new file mode 100755 index 0000000000..6e8269128d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/https.java @@ -0,0 +1,2 @@ +HttpResponse response = Unirest.get("https://mockbin.com/har") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-data.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-data.java new file mode 100755 index 0000000000..f5266e32d2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-data.java @@ -0,0 +1,4 @@ +HttpResponse response = Unirest.post("http://mockbin.com/har") + .header("content-type", "multipart/form-data; boundary=---011000010111000001101001") + .body("-----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") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-file.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-file.java new file mode 100755 index 0000000000..4b9cc83bf1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-file.java @@ -0,0 +1,4 @@ +HttpResponse response = Unirest.post("http://mockbin.com/har") + .header("content-type", "multipart/form-data; boundary=---011000010111000001101001") + .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") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-form-data.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-form-data.java new file mode 100755 index 0000000000..38ce547493 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/multipart-form-data.java @@ -0,0 +1,4 @@ +HttpResponse response = Unirest.post("http://mockbin.com/har") + .header("content-type", "multipart/form-data; boundary=---011000010111000001101001") + .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/query.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/query.java new file mode 100755 index 0000000000..cd34242193 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/query.java @@ -0,0 +1,2 @@ +HttpResponse response = Unirest.get("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/short.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/short.java new file mode 100755 index 0000000000..994b244e43 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/short.java @@ -0,0 +1,2 @@ +HttpResponse response = Unirest.get("http://mockbin.com/har") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/text-plain.java b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/text-plain.java new file mode 100755 index 0000000000..b68fb04d51 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/java/unirest/text-plain.java @@ -0,0 +1,4 @@ +HttpResponse response = Unirest.post("http://mockbin.com/har") + .header("content-type", "text/plain") + .body("Hello World") + .asString(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/application-form-encoded.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/application-form-encoded.js new file mode 100755 index 0000000000..dc296cc3e5 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/application-form-encoded.js @@ -0,0 +1,17 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "POST", + "headers": { + "content-type": "application/x-www-form-urlencoded" + }, + "data": { + "foo": "bar", + "hello": "world" + } +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/application-json.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/application-json.js new file mode 100755 index 0000000000..0b53728b32 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/application-json.js @@ -0,0 +1,15 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "POST", + "headers": { + "content-type": "application/json" + }, + "processData": false, + "data": "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/cookies.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/cookies.js new file mode 100755 index 0000000000..f65a8d048a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/cookies.js @@ -0,0 +1,13 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "POST", + "headers": { + "cookie": "foo=bar; bar=baz" + } +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/custom-method.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/custom-method.js new file mode 100755 index 0000000000..ba4185299a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/custom-method.js @@ -0,0 +1,11 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "PROPFIND", + "headers": {} +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/full.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/full.js new file mode 100755 index 0000000000..50f7cf609c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/full.js @@ -0,0 +1,18 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value", + "method": "POST", + "headers": { + "cookie": "foo=bar; bar=baz", + "accept": "application/json", + "content-type": "application/x-www-form-urlencoded" + }, + "data": { + "foo": "bar" + } +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/headers.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/headers.js new file mode 100755 index 0000000000..030e7f6ff3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/headers.js @@ -0,0 +1,14 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "GET", + "headers": { + "accept": "application/json", + "x-foo": "Bar" + } +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/https.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/https.js new file mode 100755 index 0000000000..418bfba7f6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/https.js @@ -0,0 +1,11 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "https://mockbin.com/har", + "method": "GET", + "headers": {} +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-data.js new file mode 100755 index 0000000000..8dea93d999 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-data.js @@ -0,0 +1,18 @@ +var form = new FormData(); +form.append("foo", "Hello World"); + +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "POST", + "headers": {}, + "processData": false, + "contentType": false, + "mimeType": "multipart/form-data", + "data": form +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-file.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-file.js new file mode 100755 index 0000000000..12006dd895 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-file.js @@ -0,0 +1,18 @@ +var form = new FormData(); +form.append("foo", "test/fixtures/files/hello.txt"); + +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "POST", + "headers": {}, + "processData": false, + "contentType": false, + "mimeType": "multipart/form-data", + "data": form +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-form-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-form-data.js new file mode 100755 index 0000000000..584b8d9ec1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/multipart-form-data.js @@ -0,0 +1,18 @@ +var form = new FormData(); +form.append("foo", "bar"); + +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "POST", + "headers": {}, + "processData": false, + "contentType": false, + "mimeType": "multipart/form-data", + "data": form +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/query.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/query.js new file mode 100755 index 0000000000..15a0663e4b --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/query.js @@ -0,0 +1,11 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value", + "method": "GET", + "headers": {} +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/short.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/short.js new file mode 100755 index 0000000000..45e3bdd074 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/short.js @@ -0,0 +1,11 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "GET", + "headers": {} +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/text-plain.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/text-plain.js new file mode 100755 index 0000000000..58debb2de5 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/jquery/text-plain.js @@ -0,0 +1,14 @@ +var settings = { + "async": true, + "crossDomain": true, + "url": "http://mockbin.com/har", + "method": "POST", + "headers": { + "content-type": "text/plain" + }, + "data": "Hello World" +} + +$.ajax(settings).done(function (response) { + console.log(response); +}); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/application-form-encoded.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/application-form-encoded.js new file mode 100755 index 0000000000..90cfc66a65 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/application-form-encoded.js @@ -0,0 +1,15 @@ +var data = "foo=bar&hello=world"; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("POST", "http://mockbin.com/har"); +xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/application-json.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/application-json.js new file mode 100755 index 0000000000..98508d8083 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/application-json.js @@ -0,0 +1,34 @@ +var data = JSON.stringify({ + "number": 1, + "string": "f\"oo", + "arr": [ + 1, + 2, + 3 + ], + "nested": { + "a": "b" + }, + "arr_mix": [ + 1, + "a", + { + "arr_mix_nested": {} + } + ], + "boolean": false +}); + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("POST", "http://mockbin.com/har"); +xhr.setRequestHeader("content-type", "application/json"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/cookies.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/cookies.js new file mode 100755 index 0000000000..d110546eab --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/cookies.js @@ -0,0 +1,15 @@ +var data = null; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("POST", "http://mockbin.com/har"); +xhr.setRequestHeader("cookie", "foo=bar; bar=baz"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/custom-method.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/custom-method.js new file mode 100755 index 0000000000..6da6675c37 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/custom-method.js @@ -0,0 +1,14 @@ +var data = null; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("PROPFIND", "http://mockbin.com/har"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/full.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/full.js new file mode 100755 index 0000000000..55547738fc --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/full.js @@ -0,0 +1,17 @@ +var data = "foo=bar"; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("POST", "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"); +xhr.setRequestHeader("cookie", "foo=bar; bar=baz"); +xhr.setRequestHeader("accept", "application/json"); +xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/headers.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/headers.js new file mode 100755 index 0000000000..27e9347bc8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/headers.js @@ -0,0 +1,16 @@ +var data = null; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("GET", "http://mockbin.com/har"); +xhr.setRequestHeader("accept", "application/json"); +xhr.setRequestHeader("x-foo", "Bar"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/https.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/https.js new file mode 100755 index 0000000000..6f2e8f34f0 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/https.js @@ -0,0 +1,14 @@ +var data = null; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("GET", "https://mockbin.com/har"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-data.js new file mode 100755 index 0000000000..2b7f425799 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-data.js @@ -0,0 +1,15 @@ +var data = new FormData(); +data.append("foo", "Hello World"); + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("POST", "http://mockbin.com/har"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-file.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-file.js new file mode 100755 index 0000000000..a5326f2a31 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-file.js @@ -0,0 +1,15 @@ +var data = new FormData(); +data.append("foo", "test/fixtures/files/hello.txt"); + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("POST", "http://mockbin.com/har"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-form-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-form-data.js new file mode 100755 index 0000000000..574bafff52 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/multipart-form-data.js @@ -0,0 +1,15 @@ +var data = new FormData(); +data.append("foo", "bar"); + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("POST", "http://mockbin.com/har"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/query.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/query.js new file mode 100755 index 0000000000..b9cfa0d238 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/query.js @@ -0,0 +1,14 @@ +var data = null; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("GET", "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/short.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/short.js new file mode 100755 index 0000000000..af35e76752 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/short.js @@ -0,0 +1,14 @@ +var data = null; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("GET", "http://mockbin.com/har"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/text-plain.js b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/text-plain.js new file mode 100755 index 0000000000..6b6ca51715 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/javascript/xhr/text-plain.js @@ -0,0 +1,15 @@ +var data = "Hello World"; + +var xhr = new XMLHttpRequest(); +xhr.withCredentials = true; + +xhr.addEventListener("readystatechange", function () { + if (this.readyState === this.DONE) { + console.log(this.responseText); + } +}); + +xhr.open("POST", "http://mockbin.com/har"); +xhr.setRequestHeader("content-type", "text/plain"); + +xhr.send(data); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/application-form-encoded.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/application-form-encoded.js new file mode 100755 index 0000000000..8989be7cf3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/application-form-encoded.js @@ -0,0 +1,28 @@ +var qs = require("querystring"); +var http = require("http"); + +var options = { + "method": "POST", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": { + "content-type": "application/x-www-form-urlencoded" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.write(qs.stringify({ foo: 'bar', hello: 'world' })); +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/application-json.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/application-json.js new file mode 100755 index 0000000000..5d972636d8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/application-json.js @@ -0,0 +1,32 @@ +var http = require("http"); + +var options = { + "method": "POST", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": { + "content-type": "application/json" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.write(JSON.stringify({ number: 1, + string: 'f"oo', + arr: [ 1, 2, 3 ], + nested: { a: 'b' }, + arr_mix: [ 1, 'a', { arr_mix_nested: {} } ], + boolean: false })); +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/cookies.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/cookies.js new file mode 100755 index 0000000000..39e75389d0 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/cookies.js @@ -0,0 +1,26 @@ +var http = require("http"); + +var options = { + "method": "POST", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": { + "cookie": "foo=bar; bar=baz" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/custom-method.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/custom-method.js new file mode 100755 index 0000000000..f87f77499e --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/custom-method.js @@ -0,0 +1,24 @@ +var http = require("http"); + +var options = { + "method": "PROPFIND", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": {} +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/full.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/full.js new file mode 100755 index 0000000000..f094004ec6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/full.js @@ -0,0 +1,30 @@ +var qs = require("querystring"); +var http = require("http"); + +var options = { + "method": "POST", + "hostname": "mockbin.com", + "port": null, + "path": "/har?foo=bar&foo=baz&baz=abc&key=value", + "headers": { + "cookie": "foo=bar; bar=baz", + "accept": "application/json", + "content-type": "application/x-www-form-urlencoded" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.write(qs.stringify({ foo: 'bar' })); +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/headers.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/headers.js new file mode 100755 index 0000000000..21d094b48e --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/headers.js @@ -0,0 +1,27 @@ +var http = require("http"); + +var options = { + "method": "GET", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": { + "accept": "application/json", + "x-foo": "Bar" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/https.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/https.js new file mode 100755 index 0000000000..5dd0a44b66 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/https.js @@ -0,0 +1,24 @@ +var http = require("https"); + +var options = { + "method": "GET", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": {} +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-data.js new file mode 100755 index 0000000000..61d527c1f0 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-data.js @@ -0,0 +1,27 @@ +var http = require("http"); + +var options = { + "method": "POST", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": { + "content-type": "multipart/form-data; boundary=---011000010111000001101001" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.write("-----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"); +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-file.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-file.js new file mode 100755 index 0000000000..17023a88d1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-file.js @@ -0,0 +1,27 @@ +var http = require("http"); + +var options = { + "method": "POST", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": { + "content-type": "multipart/form-data; boundary=---011000010111000001101001" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.write("-----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"); +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-form-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-form-data.js new file mode 100755 index 0000000000..55244c4440 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/multipart-form-data.js @@ -0,0 +1,27 @@ +var http = require("http"); + +var options = { + "method": "POST", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": { + "content-type": "multipart/form-data; boundary=---011000010111000001101001" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.write("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n"); +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/query.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/query.js new file mode 100755 index 0000000000..c706f8217f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/query.js @@ -0,0 +1,24 @@ +var http = require("http"); + +var options = { + "method": "GET", + "hostname": "mockbin.com", + "port": null, + "path": "/har?foo=bar&foo=baz&baz=abc&key=value", + "headers": {} +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/short.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/short.js new file mode 100755 index 0000000000..1c25ff7012 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/short.js @@ -0,0 +1,24 @@ +var http = require("http"); + +var options = { + "method": "GET", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": {} +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/native/text-plain.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/text-plain.js new file mode 100755 index 0000000000..f733d8149a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/native/text-plain.js @@ -0,0 +1,27 @@ +var http = require("http"); + +var options = { + "method": "POST", + "hostname": "mockbin.com", + "port": null, + "path": "/har", + "headers": { + "content-type": "text/plain" + } +}; + +var req = http.request(options, function (res) { + var chunks = []; + + res.on("data", function (chunk) { + chunks.push(chunk); + }); + + res.on("end", function () { + var body = Buffer.concat(chunks); + console.log(body.toString()); + }); +}); + +req.write("Hello World"); +req.end(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/application-form-encoded.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/application-form-encoded.js new file mode 100755 index 0000000000..d3fcebd663 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/application-form-encoded.js @@ -0,0 +1,13 @@ +var request = require("request"); + +var options = { method: 'POST', + url: 'http://mockbin.com/har', + headers: { 'content-type': 'application/x-www-form-urlencoded' }, + form: { foo: 'bar', hello: 'world' } }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/application-json.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/application-json.js new file mode 100755 index 0000000000..ac63778287 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/application-json.js @@ -0,0 +1,20 @@ +var request = require("request"); + +var options = { method: 'POST', + url: 'http://mockbin.com/har', + headers: { 'content-type': 'application/json' }, + body: + { number: 1, + string: 'f"oo', + arr: [ 1, 2, 3 ], + nested: { a: 'b' }, + arr_mix: [ 1, 'a', { arr_mix_nested: {} } ], + boolean: false }, + json: true }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/cookies.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/cookies.js new file mode 100755 index 0000000000..65a3b2f5c8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/cookies.js @@ -0,0 +1,14 @@ +var request = require("request"); + +var jar = request.jar(); +jar.setCookie(request.cookie("foo=bar"), "http://mockbin.com/har"); +jar.setCookie(request.cookie("bar=baz"), "http://mockbin.com/har"); + +var options = { method: 'POST', url: 'http://mockbin.com/har', jar: 'JAR' }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/custom-method.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/custom-method.js new file mode 100755 index 0000000000..951498c59a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/custom-method.js @@ -0,0 +1,10 @@ +var request = require("request"); + +var options = { method: 'PROPFIND', url: 'http://mockbin.com/har' }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/full.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/full.js new file mode 100755 index 0000000000..76b2ad68b3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/full.js @@ -0,0 +1,21 @@ +var request = require("request"); + +var jar = request.jar(); +jar.setCookie(request.cookie("foo=bar"), "http://mockbin.com/har"); +jar.setCookie(request.cookie("bar=baz"), "http://mockbin.com/har"); + +var options = { method: 'POST', + url: 'http://mockbin.com/har', + qs: { foo: [ 'bar', 'baz' ], baz: 'abc', key: 'value' }, + headers: + { 'content-type': 'application/x-www-form-urlencoded', + accept: 'application/json' }, + form: { foo: 'bar' }, + jar: 'JAR' }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/headers.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/headers.js new file mode 100755 index 0000000000..d3b8c88fb0 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/headers.js @@ -0,0 +1,12 @@ +var request = require("request"); + +var options = { method: 'GET', + url: 'http://mockbin.com/har', + headers: { 'x-foo': 'Bar', accept: 'application/json' } }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/https.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/https.js new file mode 100755 index 0000000000..bb29e04a22 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/https.js @@ -0,0 +1,10 @@ +var request = require("request"); + +var options = { method: 'GET', url: 'https://mockbin.com/har' }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-data.js new file mode 100755 index 0000000000..c7aee53ca1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-data.js @@ -0,0 +1,16 @@ +var request = require("request"); + +var options = { method: 'POST', + url: 'http://mockbin.com/har', + headers: { 'content-type': 'multipart/form-data; boundary=---011000010111000001101001' }, + formData: + { foo: + { value: 'Hello World', + options: { filename: 'hello.txt', contentType: 'text/plain' } } } }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-file.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-file.js new file mode 100755 index 0000000000..13793258b4 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-file.js @@ -0,0 +1,19 @@ +var fs = require("fs"); +var request = require("request"); + +var options = { method: 'POST', + url: 'http://mockbin.com/har', + headers: { 'content-type': 'multipart/form-data; boundary=---011000010111000001101001' }, + formData: + { foo: + { value: 'fs.createReadStream("test/fixtures/files/hello.txt")', + options: + { filename: 'test/fixtures/files/hello.txt', + contentType: 'text/plain' } } } }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-form-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-form-data.js new file mode 100755 index 0000000000..45a2306572 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/multipart-form-data.js @@ -0,0 +1,13 @@ +var request = require("request"); + +var options = { method: 'POST', + url: 'http://mockbin.com/har', + headers: { 'content-type': 'multipart/form-data; boundary=---011000010111000001101001' }, + formData: { foo: 'bar' } }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/query.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/query.js new file mode 100755 index 0000000000..73dc806d7d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/query.js @@ -0,0 +1,12 @@ +var request = require("request"); + +var options = { method: 'GET', + url: 'http://mockbin.com/har', + qs: { foo: [ 'bar', 'baz' ], baz: 'abc', key: 'value' } }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/short.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/short.js new file mode 100755 index 0000000000..0bb35585be --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/short.js @@ -0,0 +1,10 @@ +var request = require("request"); + +var options = { method: 'GET', url: 'http://mockbin.com/har' }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/request/text-plain.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/text-plain.js new file mode 100755 index 0000000000..359506daba --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/request/text-plain.js @@ -0,0 +1,13 @@ +var request = require("request"); + +var options = { method: 'POST', + url: 'http://mockbin.com/har', + headers: { 'content-type': 'text/plain' }, + body: 'Hello World' }; + +request(options, function (error, response, body) { + if (error) throw new Error(error); + + console.log(body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/application-form-encoded.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/application-form-encoded.js new file mode 100755 index 0000000000..5f410768b3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/application-form-encoded.js @@ -0,0 +1,19 @@ +var unirest = require("unirest"); + +var req = unirest("POST", "http://mockbin.com/har"); + +req.headers({ + "content-type": "application/x-www-form-urlencoded" +}); + +req.form({ + "foo": "bar", + "hello": "world" +}); + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/application-json.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/application-json.js new file mode 100755 index 0000000000..ba8d8202a6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/application-json.js @@ -0,0 +1,36 @@ +var unirest = require("unirest"); + +var req = unirest("POST", "http://mockbin.com/har"); + +req.headers({ + "content-type": "application/json" +}); + +req.type("json"); +req.send({ + "number": 1, + "string": "f\"oo", + "arr": [ + 1, + 2, + 3 + ], + "nested": { + "a": "b" + }, + "arr_mix": [ + 1, + "a", + { + "arr_mix_nested": {} + } + ], + "boolean": false +}); + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/cookies.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/cookies.js new file mode 100755 index 0000000000..6d8d62d415 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/cookies.js @@ -0,0 +1,16 @@ +var unirest = require("unirest"); + +var req = unirest("POST", "http://mockbin.com/har"); + +var CookieJar = unirest.jar(); +CookieJar.add("foo=bar","http://mockbin.com/har"); +CookieJar.add("bar=baz","http://mockbin.com/har"); +req.jar(CookieJar); + + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/custom-method.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/custom-method.js new file mode 100755 index 0000000000..3e5bb5fa59 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/custom-method.js @@ -0,0 +1,11 @@ +var unirest = require("unirest"); + +var req = unirest("PROPFIND", "http://mockbin.com/har"); + + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/full.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/full.js new file mode 100755 index 0000000000..1a92d1fac9 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/full.js @@ -0,0 +1,33 @@ +var unirest = require("unirest"); + +var req = unirest("POST", "http://mockbin.com/har"); + +var CookieJar = unirest.jar(); +CookieJar.add("foo=bar","http://mockbin.com/har"); +CookieJar.add("bar=baz","http://mockbin.com/har"); +req.jar(CookieJar); + +req.query({ + "foo": [ + "bar", + "baz" + ], + "baz": "abc", + "key": "value" +}); + +req.headers({ + "content-type": "application/x-www-form-urlencoded", + "accept": "application/json" +}); + +req.form({ + "foo": "bar" +}); + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/headers.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/headers.js new file mode 100755 index 0000000000..9d8be3811f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/headers.js @@ -0,0 +1,16 @@ +var unirest = require("unirest"); + +var req = unirest("GET", "http://mockbin.com/har"); + +req.headers({ + "x-foo": "Bar", + "accept": "application/json" +}); + + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/https.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/https.js new file mode 100755 index 0000000000..ec5faf3379 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/https.js @@ -0,0 +1,11 @@ +var unirest = require("unirest"); + +var req = unirest("GET", "https://mockbin.com/har"); + + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-data.js new file mode 100755 index 0000000000..bdf8da5153 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-data.js @@ -0,0 +1,21 @@ +var unirest = require("unirest"); + +var req = unirest("POST", "http://mockbin.com/har"); + +req.headers({ + "content-type": "multipart/form-data; boundary=---011000010111000001101001" +}); + +req.multipart([ + { + "body": "Hello World", + "content-type": "text/plain" + } +]); + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-file.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-file.js new file mode 100755 index 0000000000..c8efe878af --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-file.js @@ -0,0 +1,22 @@ +var fs = require("fs"); +var unirest = require("unirest"); + +var req = unirest("POST", "http://mockbin.com/har"); + +req.headers({ + "content-type": "multipart/form-data; boundary=---011000010111000001101001" +}); + +req.multipart([ + { + "body": fs.createReadStream("test/fixtures/files/hello.txt"), + "content-type": "text/plain" + } +]); + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-form-data.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-form-data.js new file mode 100755 index 0000000000..ea358a350f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/multipart-form-data.js @@ -0,0 +1,20 @@ +var unirest = require("unirest"); + +var req = unirest("POST", "http://mockbin.com/har"); + +req.headers({ + "content-type": "multipart/form-data; boundary=---011000010111000001101001" +}); + +req.multipart([ + { + "body": "bar" + } +]); + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/query.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/query.js new file mode 100755 index 0000000000..464e2f9414 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/query.js @@ -0,0 +1,20 @@ +var unirest = require("unirest"); + +var req = unirest("GET", "http://mockbin.com/har"); + +req.query({ + "foo": [ + "bar", + "baz" + ], + "baz": "abc", + "key": "value" +}); + + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/short.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/short.js new file mode 100755 index 0000000000..95a778b521 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/short.js @@ -0,0 +1,11 @@ +var unirest = require("unirest"); + +var req = unirest("GET", "http://mockbin.com/har"); + + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/text-plain.js b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/text-plain.js new file mode 100755 index 0000000000..bffa7ee03d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/node/unirest/text-plain.js @@ -0,0 +1,16 @@ +var unirest = require("unirest"); + +var req = unirest("POST", "http://mockbin.com/har"); + +req.headers({ + "content-type": "text/plain" +}); + + req.send("Hello World"); + +req.end(function (res) { + if (res.error) throw new Error(res.error); + + console.log(res.body); +}); + diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/application-form-encoded.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/application-form-encoded.m new file mode 100755 index 0000000000..7ebd26e193 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/application-form-encoded.m @@ -0,0 +1,25 @@ +#import + +NSDictionary *headers = @{ @"content-type": @"application/x-www-form-urlencoded" }; + +NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"foo=bar" dataUsingEncoding:NSUTF8StringEncoding]]; +[postData appendData:[@"&hello=world" dataUsingEncoding:NSUTF8StringEncoding]]; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"POST"]; +[request setAllHTTPHeaderFields:headers]; +[request setHTTPBody:postData]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/application-json.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/application-json.m new file mode 100755 index 0000000000..0249be0267 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/application-json.m @@ -0,0 +1,30 @@ +#import + +NSDictionary *headers = @{ @"content-type": @"application/json" }; +NSDictionary *parameters = @{ @"number": @1, + @"string": @"f\"oo", + @"arr": @[ @1, @2, @3 ], + @"nested": @{ @"a": @"b" }, + @"arr_mix": @[ @1, @"a", @{ @"arr_mix_nested": @{ } } ], + @"boolean": @NO }; + +NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil]; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"POST"]; +[request setAllHTTPHeaderFields:headers]; +[request setHTTPBody:postData]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/cookies.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/cookies.m new file mode 100755 index 0000000000..36e10f1314 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/cookies.m @@ -0,0 +1,21 @@ +#import + +NSDictionary *headers = @{ @"cookie": @"foo=bar; bar=baz" }; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"POST"]; +[request setAllHTTPHeaderFields:headers]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/custom-method.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/custom-method.m new file mode 100755 index 0000000000..10e9e67522 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/custom-method.m @@ -0,0 +1,18 @@ +#import + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"PROPFIND"]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/full.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/full.m new file mode 100755 index 0000000000..52216b8ebc --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/full.m @@ -0,0 +1,26 @@ +#import + +NSDictionary *headers = @{ @"cookie": @"foo=bar; bar=baz", + @"accept": @"application/json", + @"content-type": @"application/x-www-form-urlencoded" }; + +NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"foo=bar" dataUsingEncoding:NSUTF8StringEncoding]]; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"POST"]; +[request setAllHTTPHeaderFields:headers]; +[request setHTTPBody:postData]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/headers.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/headers.m new file mode 100755 index 0000000000..1d226ff5b9 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/headers.m @@ -0,0 +1,22 @@ +#import + +NSDictionary *headers = @{ @"accept": @"application/json", + @"x-foo": @"Bar" }; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"GET"]; +[request setAllHTTPHeaderFields:headers]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/https.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/https.m new file mode 100755 index 0000000000..b5ef41ea92 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/https.m @@ -0,0 +1,18 @@ +#import + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"GET"]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-data.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-data.m new file mode 100755 index 0000000000..8b8d0de523 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-data.m @@ -0,0 +1,43 @@ +#import + +NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" }; +NSArray *parameters = @[ @{ @"name": @"foo", @"value": @"Hello World", @"fileName": @"hello.txt", @"contentType": @"text/plain" } ]; +NSString *boundary = @"---011000010111000001101001"; + +NSError *error; +NSMutableString *body = [NSMutableString string]; +for (NSDictionary *param in parameters) { + [body appendFormat:@"--%@\r\n", boundary]; + if (param[@"fileName"]) { + [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]]; + [body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]]; + [body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]]; + if (error) { + NSLog(@"%@", error); + } + } else { + [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]]; + [body appendFormat:@"%@", param[@"value"]]; + } +} +[body appendFormat:@"\r\n--%@--\r\n", boundary]; +NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding]; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"POST"]; +[request setAllHTTPHeaderFields:headers]; +[request setHTTPBody:postData]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-file.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-file.m new file mode 100755 index 0000000000..0b68070e2e --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-file.m @@ -0,0 +1,43 @@ +#import + +NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" }; +NSArray *parameters = @[ @{ @"name": @"foo", @"fileName": @"test/fixtures/files/hello.txt", @"contentType": @"text/plain" } ]; +NSString *boundary = @"---011000010111000001101001"; + +NSError *error; +NSMutableString *body = [NSMutableString string]; +for (NSDictionary *param in parameters) { + [body appendFormat:@"--%@\r\n", boundary]; + if (param[@"fileName"]) { + [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]]; + [body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]]; + [body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]]; + if (error) { + NSLog(@"%@", error); + } + } else { + [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]]; + [body appendFormat:@"%@", param[@"value"]]; + } +} +[body appendFormat:@"\r\n--%@--\r\n", boundary]; +NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding]; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"POST"]; +[request setAllHTTPHeaderFields:headers]; +[request setHTTPBody:postData]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-form-data.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-form-data.m new file mode 100755 index 0000000000..3c4648d029 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/multipart-form-data.m @@ -0,0 +1,43 @@ +#import + +NSDictionary *headers = @{ @"content-type": @"multipart/form-data; boundary=---011000010111000001101001" }; +NSArray *parameters = @[ @{ @"name": @"foo", @"value": @"bar" } ]; +NSString *boundary = @"---011000010111000001101001"; + +NSError *error; +NSMutableString *body = [NSMutableString string]; +for (NSDictionary *param in parameters) { + [body appendFormat:@"--%@\r\n", boundary]; + if (param[@"fileName"]) { + [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]]; + [body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]]; + [body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]]; + if (error) { + NSLog(@"%@", error); + } + } else { + [body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]]; + [body appendFormat:@"%@", param[@"value"]]; + } +} +[body appendFormat:@"\r\n--%@--\r\n", boundary]; +NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding]; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"POST"]; +[request setAllHTTPHeaderFields:headers]; +[request setHTTPBody:postData]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/query.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/query.m new file mode 100755 index 0000000000..81cadfb312 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/query.m @@ -0,0 +1,18 @@ +#import + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"GET"]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/short.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/short.m new file mode 100755 index 0000000000..f3309b2673 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/short.m @@ -0,0 +1,18 @@ +#import + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"GET"]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/text-plain.m b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/text-plain.m new file mode 100755 index 0000000000..7532a994a5 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/objc/nsurlsession/text-plain.m @@ -0,0 +1,24 @@ +#import + +NSDictionary *headers = @{ @"content-type": @"text/plain" }; + +NSData *postData = [[NSData alloc] initWithData:[@"Hello World" dataUsingEncoding:NSUTF8StringEncoding]]; + +NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] + cachePolicy:NSURLRequestUseProtocolCachePolicy + timeoutInterval:10.0]; +[request setHTTPMethod:@"POST"]; +[request setAllHTTPHeaderFields:headers]; +[request setHTTPBody:postData]; + +NSURLSession *session = [NSURLSession sharedSession]; +NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request + completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (error) { + NSLog(@"%@", error); + } else { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; + NSLog(@"%@", httpResponse); + } + }]; +[dataTask resume]; diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/application-form-encoded.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/application-form-encoded.ml new file mode 100755 index 0000000000..8480d692e7 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/application-form-encoded.ml @@ -0,0 +1,11 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in +let headers = Header.add (Header.init ()) "content-type" "application/x-www-form-urlencoded" in +let body = Cohttp_lwt_body.of_string "foo=bar&hello=world" in + +Client.call ~headers ~body `POST uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/application-json.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/application-json.ml new file mode 100755 index 0000000000..dda6e550d8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/application-json.ml @@ -0,0 +1,11 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in +let headers = Header.add (Header.init ()) "content-type" "application/json" in +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 + +Client.call ~headers ~body `POST uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/cookies.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/cookies.ml new file mode 100755 index 0000000000..fdf6dccf3b --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/cookies.ml @@ -0,0 +1,10 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in +let headers = Header.add (Header.init ()) "cookie" "foo=bar; bar=baz" in + +Client.call ~headers `POST uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/custom-method.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/custom-method.ml new file mode 100755 index 0000000000..fac0d12631 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/custom-method.ml @@ -0,0 +1,9 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in + +Client.call (Code.method_of_string "PROPFIND") uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/full.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/full.ml new file mode 100755 index 0000000000..c4b1dc04af --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/full.ml @@ -0,0 +1,15 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value" in +let headers = Header.add_list (Header.init ()) [ + ("cookie", "foo=bar; bar=baz"); + ("accept", "application/json"); + ("content-type", "application/x-www-form-urlencoded"); +] in +let body = Cohttp_lwt_body.of_string "foo=bar" in + +Client.call ~headers ~body `POST uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/headers.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/headers.ml new file mode 100755 index 0000000000..6755d5a226 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/headers.ml @@ -0,0 +1,13 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in +let headers = Header.add_list (Header.init ()) [ + ("accept", "application/json"); + ("x-foo", "Bar"); +] in + +Client.call ~headers `GET uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/https.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/https.ml new file mode 100755 index 0000000000..bb68b33b6f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/https.ml @@ -0,0 +1,9 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "https://mockbin.com/har" in + +Client.call `GET uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-data.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-data.ml new file mode 100755 index 0000000000..3d5b3c0622 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-data.ml @@ -0,0 +1,11 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in +let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in +let body = Cohttp_lwt_body.of_string "-----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" in + +Client.call ~headers ~body `POST uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-file.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-file.ml new file mode 100755 index 0000000000..96f8794eda --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-file.ml @@ -0,0 +1,11 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in +let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in +let body = Cohttp_lwt_body.of_string "-----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" in + +Client.call ~headers ~body `POST uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-form-data.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-form-data.ml new file mode 100755 index 0000000000..488c3e41b6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/multipart-form-data.ml @@ -0,0 +1,11 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in +let headers = Header.add (Header.init ()) "content-type" "multipart/form-data; boundary=---011000010111000001101001" in +let body = Cohttp_lwt_body.of_string "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" in + +Client.call ~headers ~body `POST uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/query.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/query.ml new file mode 100755 index 0000000000..8634f1ab1a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/query.ml @@ -0,0 +1,9 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value" in + +Client.call `GET uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/short.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/short.ml new file mode 100755 index 0000000000..189bc3f536 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/short.ml @@ -0,0 +1,9 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in + +Client.call `GET uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/text-plain.ml b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/text-plain.ml new file mode 100755 index 0000000000..28148e744a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ocaml/cohttp/text-plain.ml @@ -0,0 +1,11 @@ +open Cohttp_lwt_unix +open Cohttp +open Lwt + +let uri = Uri.of_string "http://mockbin.com/har" in +let headers = Header.add (Header.init ()) "content-type" "text/plain" in +let body = Cohttp_lwt_body.of_string "Hello World" in + +Client.call ~headers ~body `POST uri +>>= fun (res, body_stream) -> + (* Do stuff with the result *) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/application-form-encoded.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/application-form-encoded.php new file mode 100755 index 0000000000..ca76dc0afc --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/application-form-encoded.php @@ -0,0 +1,28 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => "foo=bar&hello=world", + CURLOPT_HTTPHEADER => array( + "content-type: application/x-www-form-urlencoded" + ), +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/application-json.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/application-json.php new file mode 100755 index 0000000000..595bcd167c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/application-json.php @@ -0,0 +1,28 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}", + CURLOPT_HTTPHEADER => array( + "content-type: application/json" + ), +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/cookies.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/cookies.php new file mode 100755 index 0000000000..1f6ab0c634 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/cookies.php @@ -0,0 +1,25 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_COOKIE => "foo=bar; bar=baz", +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/custom-method.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/custom-method.php new file mode 100755 index 0000000000..b12fac4455 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/custom-method.php @@ -0,0 +1,24 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "PROPFIND", +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/full.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/full.php new file mode 100755 index 0000000000..4208fd4841 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/full.php @@ -0,0 +1,30 @@ + "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => "foo=bar", + CURLOPT_COOKIE => "foo=bar; bar=baz", + CURLOPT_HTTPHEADER => array( + "accept: application/json", + "content-type: application/x-www-form-urlencoded" + ), +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/headers.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/headers.php new file mode 100755 index 0000000000..1e080520d8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/headers.php @@ -0,0 +1,28 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_HTTPHEADER => array( + "accept: application/json", + "x-foo: Bar" + ), +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/https.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/https.php new file mode 100755 index 0000000000..01b00b21da --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/https.php @@ -0,0 +1,24 @@ + "https://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-data.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-data.php new file mode 100755 index 0000000000..944a4c374c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-data.php @@ -0,0 +1,28 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => "-----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", + CURLOPT_HTTPHEADER => array( + "content-type: multipart/form-data; boundary=---011000010111000001101001" + ), +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-file.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-file.php new file mode 100755 index 0000000000..160b277055 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-file.php @@ -0,0 +1,28 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => "-----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", + CURLOPT_HTTPHEADER => array( + "content-type: multipart/form-data; boundary=---011000010111000001101001" + ), +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-form-data.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-form-data.php new file mode 100755 index 0000000000..f815f6c56d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/multipart-form-data.php @@ -0,0 +1,28 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n", + CURLOPT_HTTPHEADER => array( + "content-type: multipart/form-data; boundary=---011000010111000001101001" + ), +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/query.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/query.php new file mode 100755 index 0000000000..d85fc7815f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/query.php @@ -0,0 +1,24 @@ + "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/short.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/short.php new file mode 100755 index 0000000000..c67fb150fd --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/short.php @@ -0,0 +1,24 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/text-plain.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/text-plain.php new file mode 100755 index 0000000000..6306b92132 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/curl/text-plain.php @@ -0,0 +1,28 @@ + "http://mockbin.com/har", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => "Hello World", + CURLOPT_HTTPHEADER => array( + "content-type: text/plain" + ), +)); + +$response = curl_exec($curl); +$err = curl_error($curl); + +curl_close($curl); + +if ($err) { + echo "cURL Error #:" . $err; +} else { + echo $response; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/application-form-encoded.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/application-form-encoded.php new file mode 100755 index 0000000000..32d4112bd5 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/application-form-encoded.php @@ -0,0 +1,23 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_POST); + +$request->setHeaders(array( + 'content-type' => 'application/x-www-form-urlencoded' +)); + +$request->setContentType('application/x-www-form-urlencoded'); +$request->setPostFields(array( + 'foo' => 'bar', + 'hello' => 'world' +)); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/application-json.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/application-json.php new file mode 100755 index 0000000000..2abde643db --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/application-json.php @@ -0,0 +1,19 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_POST); + +$request->setHeaders(array( + 'content-type' => 'application/json' +)); + +$request->setBody('{"number":1,"string":"f\\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}'); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/cookies.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/cookies.php new file mode 100755 index 0000000000..1dfcf609ba --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/cookies.php @@ -0,0 +1,18 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_POST); + +$request->setCookies(array( + 'bar' => 'baz', + 'foo' => 'bar' +)); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/custom-method.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/custom-method.php new file mode 100755 index 0000000000..ba4f9293f8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/custom-method.php @@ -0,0 +1,13 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_PROPFIND); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/full.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/full.php new file mode 100755 index 0000000000..712f1e0eca --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/full.php @@ -0,0 +1,37 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_POST); + +$request->setQueryData(array( + 'foo' => array( + 'bar', + 'baz' + ), + 'baz' => 'abc', + 'key' => 'value' +)); + +$request->setHeaders(array( + 'content-type' => 'application/x-www-form-urlencoded', + 'accept' => 'application/json' +)); + +$request->setCookies(array( + 'bar' => 'baz', + 'foo' => 'bar' +)); + +$request->setContentType('application/x-www-form-urlencoded'); +$request->setPostFields(array( + 'foo' => 'bar' +)); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/headers.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/headers.php new file mode 100755 index 0000000000..819e46a4df --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/headers.php @@ -0,0 +1,18 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_GET); + +$request->setHeaders(array( + 'x-foo' => 'Bar', + 'accept' => 'application/json' +)); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/https.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/https.php new file mode 100755 index 0000000000..dadd0653b5 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/https.php @@ -0,0 +1,13 @@ +setUrl('https://mockbin.com/har'); +$request->setMethod(HTTP_METH_GET); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-data.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-data.php new file mode 100755 index 0000000000..06a28658ed --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-data.php @@ -0,0 +1,25 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_POST); + +$request->setHeaders(array( + 'content-type' => 'multipart/form-data; boundary=---011000010111000001101001' +)); + +$request->setBody('-----011000010111000001101001 +Content-Disposition: form-data; name="foo"; filename="hello.txt" +Content-Type: text/plain + +Hello World +-----011000010111000001101001-- +'); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-file.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-file.php new file mode 100755 index 0000000000..b2b16581a1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-file.php @@ -0,0 +1,25 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_POST); + +$request->setHeaders(array( + 'content-type' => 'multipart/form-data; boundary=---011000010111000001101001' +)); + +$request->setBody('-----011000010111000001101001 +Content-Disposition: form-data; name="foo"; filename="hello.txt" +Content-Type: text/plain + + +-----011000010111000001101001-- +'); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-form-data.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-form-data.php new file mode 100755 index 0000000000..55f536e9c3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/multipart-form-data.php @@ -0,0 +1,24 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_POST); + +$request->setHeaders(array( + 'content-type' => 'multipart/form-data; boundary=---011000010111000001101001' +)); + +$request->setBody('-----011000010111000001101001 +Content-Disposition: form-data; name="foo" + +bar +-----011000010111000001101001-- +'); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/query.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/query.php new file mode 100755 index 0000000000..ec8a949b5e --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/query.php @@ -0,0 +1,22 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_GET); + +$request->setQueryData(array( + 'foo' => array( + 'bar', + 'baz' + ), + 'baz' => 'abc', + 'key' => 'value' +)); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/short.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/short.php new file mode 100755 index 0000000000..3a7fa9a3c8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/short.php @@ -0,0 +1,13 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_GET); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/text-plain.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/text-plain.php new file mode 100755 index 0000000000..1e89386823 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http1/text-plain.php @@ -0,0 +1,19 @@ +setUrl('http://mockbin.com/har'); +$request->setMethod(HTTP_METH_POST); + +$request->setHeaders(array( + 'content-type' => 'text/plain' +)); + +$request->setBody('Hello World'); + +try { + $response = $request->send(); + + echo $response->getBody(); +} catch (HttpException $ex) { + echo $ex; +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/application-form-encoded.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/application-form-encoded.php new file mode 100755 index 0000000000..573ecbcbba --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/application-form-encoded.php @@ -0,0 +1,23 @@ +append(new http\QueryString(array( + 'foo' => 'bar', + 'hello' => 'world' +))); + +$request->setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('POST'); +$request->setBody($body); + +$request->setHeaders(array( + 'content-type' => 'application/x-www-form-urlencoded' +)); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/application-json.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/application-json.php new file mode 100755 index 0000000000..f4305c7732 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/application-json.php @@ -0,0 +1,20 @@ +append('{"number":1,"string":"f\\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}'); + +$request->setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('POST'); +$request->setBody($body); + +$request->setHeaders(array( + 'content-type' => 'application/json' +)); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/cookies.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/cookies.php new file mode 100755 index 0000000000..0502c6d662 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/cookies.php @@ -0,0 +1,17 @@ +setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('POST'); + +$client->setCookies(array( + 'bar' => 'baz', + 'foo' => 'bar' +)); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/custom-method.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/custom-method.php new file mode 100755 index 0000000000..6d48972972 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/custom-method.php @@ -0,0 +1,11 @@ +setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('PROPFIND'); +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/full.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/full.php new file mode 100755 index 0000000000..0a9a5a42ce --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/full.php @@ -0,0 +1,38 @@ +append(new http\QueryString(array( + 'foo' => 'bar' +))); + +$request->setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('POST'); +$request->setBody($body); + +$request->setQuery(new http\QueryString(array( + 'foo' => array( + 'bar', + 'baz' + ), + 'baz' => 'abc', + 'key' => 'value' +))); + +$request->setHeaders(array( + 'content-type' => 'application/x-www-form-urlencoded', + 'accept' => 'application/json' +)); + + +$client->setCookies(array( + 'bar' => 'baz', + 'foo' => 'bar' +)); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/headers.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/headers.php new file mode 100755 index 0000000000..66ab896184 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/headers.php @@ -0,0 +1,16 @@ +setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('GET'); +$request->setHeaders(array( + 'x-foo' => 'Bar', + 'accept' => 'application/json' +)); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/https.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/https.php new file mode 100755 index 0000000000..12a233eae9 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/https.php @@ -0,0 +1,11 @@ +setRequestUrl('https://mockbin.com/har'); +$request->setRequestMethod('GET'); +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-data.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-data.php new file mode 100755 index 0000000000..8ec5acf358 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-data.php @@ -0,0 +1,23 @@ +addForm(NULL, array( + array( + 'name' => 'foo', + 'type' => 'text/plain', + 'file' => 'hello.txt', + 'data' => 'Hello World' + ) +)); + +$request->setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('POST'); +$request->setBody($body); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-file.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-file.php new file mode 100755 index 0000000000..2fbb7db52f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-file.php @@ -0,0 +1,23 @@ +addForm(NULL, array( + array( + 'name' => 'foo', + 'type' => 'text/plain', + 'file' => 'test/fixtures/files/hello.txt', + 'data' => null + ) +)); + +$request->setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('POST'); +$request->setBody($body); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-form-data.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-form-data.php new file mode 100755 index 0000000000..ba2799d533 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/multipart-form-data.php @@ -0,0 +1,18 @@ +addForm(array( + 'foo' => 'bar' +), NULL); + +$request->setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('POST'); +$request->setBody($body); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/query.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/query.php new file mode 100755 index 0000000000..effd119a5c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/query.php @@ -0,0 +1,20 @@ +setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('GET'); +$request->setQuery(new http\QueryString(array( + 'foo' => array( + 'bar', + 'baz' + ), + 'baz' => 'abc', + 'key' => 'value' +))); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/short.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/short.php new file mode 100755 index 0000000000..1f4dba9a71 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/short.php @@ -0,0 +1,11 @@ +setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('GET'); +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/text-plain.php b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/text-plain.php new file mode 100755 index 0000000000..099e9c5a35 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/php/http2/text-plain.php @@ -0,0 +1,20 @@ +append('Hello World'); + +$request->setRequestUrl('http://mockbin.com/har'); +$request->setRequestMethod('POST'); +$request->setBody($body); + +$request->setHeaders(array( + 'content-type' => 'text/plain' +)); + +$client->enqueue($request)->send(); +$response = $client->getResponse(); + +echo $response->getBody(); diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/application-form-encoded.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/application-form-encoded.py new file mode 100755 index 0000000000..e7857cbff8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/application-form-encoded.py @@ -0,0 +1,14 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +payload = "foo=bar&hello=world" + +headers = { 'content-type': "application/x-www-form-urlencoded" } + +conn.request("POST", "/har", payload, headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/application-json.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/application-json.py new file mode 100755 index 0000000000..ce36a23d86 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/application-json.py @@ -0,0 +1,14 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +payload = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" + +headers = { 'content-type': "application/json" } + +conn.request("POST", "/har", payload, headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/cookies.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/cookies.py new file mode 100755 index 0000000000..46530ca7ab --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/cookies.py @@ -0,0 +1,12 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +headers = { 'cookie': "foo=bar; bar=baz" } + +conn.request("POST", "/har", headers=headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/custom-method.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/custom-method.py new file mode 100755 index 0000000000..0f510e377a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/custom-method.py @@ -0,0 +1,10 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +conn.request("PROPFIND", "/har") + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/full.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/full.py new file mode 100755 index 0000000000..6329ea9845 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/full.py @@ -0,0 +1,18 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +payload = "foo=bar" + +headers = { + 'cookie': "foo=bar; bar=baz", + 'accept': "application/json", + 'content-type': "application/x-www-form-urlencoded" + } + +conn.request("POST", "/har?foo=bar&foo=baz&baz=abc&key=value", payload, headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/headers.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/headers.py new file mode 100755 index 0000000000..fc2004476a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/headers.py @@ -0,0 +1,15 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +headers = { + 'accept': "application/json", + 'x-foo': "Bar" + } + +conn.request("GET", "/har", headers=headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/https.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/https.py new file mode 100755 index 0000000000..f9df79d357 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/https.py @@ -0,0 +1,10 @@ +import http.client + +conn = http.client.HTTPSConnection("mockbin.com") + +conn.request("GET", "/har") + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-data.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-data.py new file mode 100755 index 0000000000..7ed5b404e3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-data.py @@ -0,0 +1,14 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +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" + +headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" } + +conn.request("POST", "/har", payload, headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-file.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-file.py new file mode 100755 index 0000000000..681ec08c2b --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-file.py @@ -0,0 +1,14 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +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" + +headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" } + +conn.request("POST", "/har", payload, headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-form-data.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-form-data.py new file mode 100755 index 0000000000..42bb175463 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/multipart-form-data.py @@ -0,0 +1,14 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" + +headers = { 'content-type': "multipart/form-data; boundary=---011000010111000001101001" } + +conn.request("POST", "/har", payload, headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/query.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/query.py new file mode 100755 index 0000000000..d882e3b422 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/query.py @@ -0,0 +1,10 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +conn.request("GET", "/har?foo=bar&foo=baz&baz=abc&key=value") + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/short.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/short.py new file mode 100755 index 0000000000..e8e657f805 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/short.py @@ -0,0 +1,10 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +conn.request("GET", "/har") + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/text-plain.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/text-plain.py new file mode 100755 index 0000000000..f00466b981 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/python3/text-plain.py @@ -0,0 +1,14 @@ +import http.client + +conn = http.client.HTTPConnection("mockbin.com") + +payload = "Hello World" + +headers = { 'content-type': "text/plain" } + +conn.request("POST", "/har", payload, headers) + +res = conn.getresponse() +data = res.read() + +print(data.decode("utf-8")) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/application-form-encoded.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/application-form-encoded.py new file mode 100755 index 0000000000..54556d0f10 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/application-form-encoded.py @@ -0,0 +1,10 @@ +import requests + +url = "http://mockbin.com/har" + +payload = "foo=bar&hello=world" +headers = {'content-type': 'application/x-www-form-urlencoded'} + +response = requests.request("POST", url, data=payload, headers=headers) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/application-json.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/application-json.py new file mode 100755 index 0000000000..a60dcd2159 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/application-json.py @@ -0,0 +1,10 @@ +import requests + +url = "http://mockbin.com/har" + +payload = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" +headers = {'content-type': 'application/json'} + +response = requests.request("POST", url, data=payload, headers=headers) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/cookies.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/cookies.py new file mode 100755 index 0000000000..96977a5095 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/cookies.py @@ -0,0 +1,9 @@ +import requests + +url = "http://mockbin.com/har" + +headers = {'cookie': 'foo=bar; bar=baz'} + +response = requests.request("POST", url, headers=headers) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/custom-method.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/custom-method.py new file mode 100755 index 0000000000..8a848a56da --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/custom-method.py @@ -0,0 +1,7 @@ +import requests + +url = "http://mockbin.com/har" + +response = requests.request("PROPFIND", url) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/full.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/full.py new file mode 100755 index 0000000000..621d12a22e --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/full.py @@ -0,0 +1,16 @@ +import requests + +url = "http://mockbin.com/har" + +querystring = {"foo":["bar","baz"],"baz":"abc","key":"value"} + +payload = "foo=bar" +headers = { + 'cookie': "foo=bar; bar=baz", + 'accept': "application/json", + 'content-type': "application/x-www-form-urlencoded" + } + +response = requests.request("POST", url, data=payload, headers=headers, params=querystring) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/headers.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/headers.py new file mode 100755 index 0000000000..847323fb68 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/headers.py @@ -0,0 +1,12 @@ +import requests + +url = "http://mockbin.com/har" + +headers = { + 'accept': "application/json", + 'x-foo': "Bar" + } + +response = requests.request("GET", url, headers=headers) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/https.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/https.py new file mode 100755 index 0000000000..af4660bfbb --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/https.py @@ -0,0 +1,7 @@ +import requests + +url = "https://mockbin.com/har" + +response = requests.request("GET", url) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-data.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-data.py new file mode 100755 index 0000000000..4b9cc5c810 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-data.py @@ -0,0 +1,10 @@ +import requests + +url = "http://mockbin.com/har" + +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" +headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'} + +response = requests.request("POST", url, data=payload, headers=headers) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-file.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-file.py new file mode 100755 index 0000000000..5c3188b845 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-file.py @@ -0,0 +1,10 @@ +import requests + +url = "http://mockbin.com/har" + +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" +headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'} + +response = requests.request("POST", url, data=payload, headers=headers) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-form-data.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-form-data.py new file mode 100755 index 0000000000..77bbb34385 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/multipart-form-data.py @@ -0,0 +1,10 @@ +import requests + +url = "http://mockbin.com/har" + +payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" +headers = {'content-type': 'multipart/form-data; boundary=---011000010111000001101001'} + +response = requests.request("POST", url, data=payload, headers=headers) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/query.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/query.py new file mode 100755 index 0000000000..8ba0632381 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/query.py @@ -0,0 +1,9 @@ +import requests + +url = "http://mockbin.com/har" + +querystring = {"foo":["bar","baz"],"baz":"abc","key":"value"} + +response = requests.request("GET", url, params=querystring) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/short.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/short.py new file mode 100755 index 0000000000..58f057e8b5 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/short.py @@ -0,0 +1,7 @@ +import requests + +url = "http://mockbin.com/har" + +response = requests.request("GET", url) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/text-plain.py b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/text-plain.py new file mode 100755 index 0000000000..ba42964e3b --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/python/requests/text-plain.py @@ -0,0 +1,10 @@ +import requests + +url = "http://mockbin.com/har" + +payload = "Hello World" +headers = {'content-type': 'text/plain'} + +response = requests.request("POST", url, data=payload, headers=headers) + +print(response.text) diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/application-form-encoded.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/application-form-encoded.rb new file mode 100755 index 0000000000..b22b26b529 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/application-form-encoded.rb @@ -0,0 +1,13 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Post.new(url) +request["content-type"] = 'application/x-www-form-urlencoded' +request.body = "foo=bar&hello=world" + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/application-json.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/application-json.rb new file mode 100755 index 0000000000..78c310fa8c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/application-json.rb @@ -0,0 +1,13 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Post.new(url) +request["content-type"] = 'application/json' +request.body = "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/cookies.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/cookies.rb new file mode 100755 index 0000000000..3283fafcaf --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/cookies.rb @@ -0,0 +1,12 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Post.new(url) +request["cookie"] = 'foo=bar; bar=baz' + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/custom-method.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/custom-method.rb new file mode 100755 index 0000000000..d3d4566e77 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/custom-method.rb @@ -0,0 +1,17 @@ +require 'uri' +require 'net/http' + +class Net::HTTP::Propfind < Net::HTTPRequest + METHOD = 'PROPFIND' + REQUEST_HAS_BODY = 'false' + RESPONSE_HAS_BODY = true +end + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Propfind.new(url) + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/full.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/full.rb new file mode 100755 index 0000000000..992c58642c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/full.rb @@ -0,0 +1,15 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Post.new(url) +request["cookie"] = 'foo=bar; bar=baz' +request["accept"] = 'application/json' +request["content-type"] = 'application/x-www-form-urlencoded' +request.body = "foo=bar" + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/headers.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/headers.rb new file mode 100755 index 0000000000..f2a4dba9a7 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/headers.rb @@ -0,0 +1,13 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Get.new(url) +request["accept"] = 'application/json' +request["x-foo"] = 'Bar' + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/https.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/https.rb new file mode 100755 index 0000000000..51fbc61660 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/https.rb @@ -0,0 +1,13 @@ +require 'uri' +require 'net/http' + +url = URI("https://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) +http.use_ssl = true +http.verify_mode = OpenSSL::SSL::VERIFY_NONE + +request = Net::HTTP::Get.new(url) + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-data.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-data.rb new file mode 100755 index 0000000000..4b5613fde1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-data.rb @@ -0,0 +1,13 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Post.new(url) +request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001' +request.body = "-----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" + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-file.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-file.rb new file mode 100755 index 0000000000..bbf6c88454 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-file.rb @@ -0,0 +1,13 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Post.new(url) +request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001' +request.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" + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-form-data.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-form-data.rb new file mode 100755 index 0000000000..60d18faf39 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/multipart-form-data.rb @@ -0,0 +1,13 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Post.new(url) +request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001' +request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"foo\"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n" + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/query.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/query.rb new file mode 100755 index 0000000000..ef6881c286 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/query.rb @@ -0,0 +1,11 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Get.new(url) + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/short.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/short.rb new file mode 100755 index 0000000000..7761eb9988 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/short.rb @@ -0,0 +1,11 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Get.new(url) + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/text-plain.rb b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/text-plain.rb new file mode 100755 index 0000000000..813c15ac1c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/ruby/native/text-plain.rb @@ -0,0 +1,13 @@ +require 'uri' +require 'net/http' + +url = URI("http://mockbin.com/har") + +http = Net::HTTP.new(url.host, url.port) + +request = Net::HTTP::Post.new(url) +request["content-type"] = 'text/plain' +request.body = "Hello World" + +response = http.request(request) +puts response.read_body diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/application-form-encoded.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/application-form-encoded.sh new file mode 100755 index 0000000000..5c670fe269 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/application-form-encoded.sh @@ -0,0 +1,4 @@ +curl --request POST \ + --url http://mockbin.com/har \ + --header 'content-type: application/x-www-form-urlencoded' \ + --data 'foo=bar&hello=world' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/application-json.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/application-json.sh new file mode 100755 index 0000000000..f7b19eb9f7 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/application-json.sh @@ -0,0 +1,4 @@ +curl --request POST \ + --url http://mockbin.com/har \ + --header 'content-type: application/json' \ + --data '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/cookies.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/cookies.sh new file mode 100755 index 0000000000..74c6eb12a2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/cookies.sh @@ -0,0 +1,3 @@ +curl --request POST \ + --url http://mockbin.com/har \ + --cookie 'foo=bar; bar=baz' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/custom-method.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/custom-method.sh new file mode 100755 index 0000000000..e6cef28d83 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/custom-method.sh @@ -0,0 +1,2 @@ +curl --request PROPFIND \ + --url http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/full.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/full.sh new file mode 100755 index 0000000000..9d9c396ddb --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/full.sh @@ -0,0 +1,6 @@ +curl --request POST \ + --url 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' \ + --header 'accept: application/json' \ + --header 'content-type: application/x-www-form-urlencoded' \ + --cookie 'foo=bar; bar=baz' \ + --data foo=bar diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/headers.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/headers.sh new file mode 100755 index 0000000000..c415136816 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/headers.sh @@ -0,0 +1,4 @@ +curl --request GET \ + --url http://mockbin.com/har \ + --header 'accept: application/json' \ + --header 'x-foo: Bar' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/http1.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/http1.sh new file mode 100755 index 0000000000..2dbff472fa --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/http1.sh @@ -0,0 +1,3 @@ +curl --request GET \ + --url "http://mockbin.com/request" \ + --http1.0 diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/https.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/https.sh new file mode 100755 index 0000000000..8acb41f991 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/https.sh @@ -0,0 +1,2 @@ +curl --request GET \ + --url https://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-data.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-data.sh new file mode 100755 index 0000000000..8dee5514c7 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-data.sh @@ -0,0 +1,4 @@ +curl --request POST \ + --url http://mockbin.com/har \ + --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ + --form 'foo=Hello World' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-file.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-file.sh new file mode 100755 index 0000000000..e054807c69 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-file.sh @@ -0,0 +1,4 @@ +curl --request POST \ + --url http://mockbin.com/har \ + --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ + --form foo=@test/fixtures/files/hello.txt diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-form-data.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-form-data.sh new file mode 100755 index 0000000000..d7b10e7ee5 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/multipart-form-data.sh @@ -0,0 +1,4 @@ +curl --request POST \ + --url http://mockbin.com/har \ + --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ + --form foo=bar diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/query.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/query.sh new file mode 100755 index 0000000000..488bd4a18e --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/query.sh @@ -0,0 +1,2 @@ +curl --request GET \ + --url 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/short.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/short.sh new file mode 100755 index 0000000000..ffe0460d82 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/short.sh @@ -0,0 +1,2 @@ +curl --request GET \ + --url http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/text-plain.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/text-plain.sh new file mode 100755 index 0000000000..511b8f24f3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/curl/text-plain.sh @@ -0,0 +1,4 @@ +curl --request POST \ + --url http://mockbin.com/har \ + --header 'content-type: text/plain' \ + --data 'Hello World' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/application-form-encoded.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/application-form-encoded.sh new file mode 100755 index 0000000000..e7bb5a3201 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/application-form-encoded.sh @@ -0,0 +1,4 @@ +http --form POST http://mockbin.com/har \ + content-type:application/x-www-form-urlencoded \ + foo=bar \ + hello=world diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/application-json.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/application-json.sh new file mode 100755 index 0000000000..073a2583c0 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/application-json.sh @@ -0,0 +1,3 @@ +echo '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' | \ + http POST http://mockbin.com/har \ + content-type:application/json diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/cookies.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/cookies.sh new file mode 100755 index 0000000000..791a3f58ac --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/cookies.sh @@ -0,0 +1,2 @@ +http POST http://mockbin.com/har \ + cookie:'foo=bar; bar=baz' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/custom-method.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/custom-method.sh new file mode 100755 index 0000000000..296e12b745 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/custom-method.sh @@ -0,0 +1 @@ +http PROPFIND http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/full.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/full.sh new file mode 100755 index 0000000000..ede01f4205 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/full.sh @@ -0,0 +1,5 @@ +http --form POST 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' \ + accept:application/json \ + content-type:application/x-www-form-urlencoded \ + cookie:'foo=bar; bar=baz' \ + foo=bar diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/headers.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/headers.sh new file mode 100755 index 0000000000..427ae78400 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/headers.sh @@ -0,0 +1,3 @@ +http GET http://mockbin.com/har \ + accept:application/json \ + x-foo:Bar diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/https.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/https.sh new file mode 100755 index 0000000000..97035e11fe --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/https.sh @@ -0,0 +1 @@ +http GET https://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-data.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-data.sh new file mode 100755 index 0000000000..64b17a1f43 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-data.sh @@ -0,0 +1,9 @@ +echo '-----011000010111000001101001 +Content-Disposition: form-data; name="foo"; filename="hello.txt" +Content-Type: text/plain + +Hello World +-----011000010111000001101001-- +' | \ + http POST http://mockbin.com/har \ + content-type:'multipart/form-data; boundary=---011000010111000001101001' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-file.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-file.sh new file mode 100755 index 0000000000..25b7ede3e6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-file.sh @@ -0,0 +1,9 @@ +echo '-----011000010111000001101001 +Content-Disposition: form-data; name="foo"; filename="hello.txt" +Content-Type: text/plain + + +-----011000010111000001101001-- +' | \ + http POST http://mockbin.com/har \ + content-type:'multipart/form-data; boundary=---011000010111000001101001' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-form-data.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-form-data.sh new file mode 100755 index 0000000000..a6d1700942 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/multipart-form-data.sh @@ -0,0 +1,8 @@ +echo '-----011000010111000001101001 +Content-Disposition: form-data; name="foo" + +bar +-----011000010111000001101001-- +' | \ + http POST http://mockbin.com/har \ + content-type:'multipart/form-data; boundary=---011000010111000001101001' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/query.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/query.sh new file mode 100755 index 0000000000..a38d1af26a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/query.sh @@ -0,0 +1 @@ +http GET 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/short.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/short.sh new file mode 100755 index 0000000000..bb18e9d362 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/short.sh @@ -0,0 +1 @@ +http GET http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/text-plain.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/text-plain.sh new file mode 100755 index 0000000000..ac5657d349 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/httpie/text-plain.sh @@ -0,0 +1,3 @@ +echo 'Hello World' | \ + http POST http://mockbin.com/har \ + content-type:text/plain diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/application-form-encoded.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/application-form-encoded.sh new file mode 100755 index 0000000000..a7f1ab1069 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/application-form-encoded.sh @@ -0,0 +1,6 @@ +wget --quiet \ + --method POST \ + --header 'content-type: application/x-www-form-urlencoded' \ + --body-data 'foo=bar&hello=world' \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/application-json.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/application-json.sh new file mode 100755 index 0000000000..c89593c15b --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/application-json.sh @@ -0,0 +1,6 @@ +wget --quiet \ + --method POST \ + --header 'content-type: application/json' \ + --body-data '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}' \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/cookies.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/cookies.sh new file mode 100755 index 0000000000..797c6bacab --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/cookies.sh @@ -0,0 +1,5 @@ +wget --quiet \ + --method POST \ + --header 'cookie: foo=bar; bar=baz' \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/custom-method.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/custom-method.sh new file mode 100755 index 0000000000..3faea5fe18 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/custom-method.sh @@ -0,0 +1,4 @@ +wget --quiet \ + --method PROPFIND \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/full.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/full.sh new file mode 100755 index 0000000000..e15037a97d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/full.sh @@ -0,0 +1,8 @@ +wget --quiet \ + --method POST \ + --header 'cookie: foo=bar; bar=baz' \ + --header 'accept: application/json' \ + --header 'content-type: application/x-www-form-urlencoded' \ + --body-data foo=bar \ + --output-document \ + - 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/headers.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/headers.sh new file mode 100755 index 0000000000..e39f0904d2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/headers.sh @@ -0,0 +1,6 @@ +wget --quiet \ + --method GET \ + --header 'accept: application/json' \ + --header 'x-foo: Bar' \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/https.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/https.sh new file mode 100755 index 0000000000..590a3f02a6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/https.sh @@ -0,0 +1,4 @@ +wget --quiet \ + --method GET \ + --output-document \ + - https://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-data.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-data.sh new file mode 100755 index 0000000000..77cf09f86d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-data.sh @@ -0,0 +1,6 @@ +wget --quiet \ + --method POST \ + --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ + --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' \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-file.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-file.sh new file mode 100755 index 0000000000..cc997764fd --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-file.sh @@ -0,0 +1,6 @@ +wget --quiet \ + --method POST \ + --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ + --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' \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-form-data.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-form-data.sh new file mode 100755 index 0000000000..8ccf44a746 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/multipart-form-data.sh @@ -0,0 +1,6 @@ +wget --quiet \ + --method POST \ + --header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \ + --body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="foo"\r\n\r\nbar\r\n-----011000010111000001101001--\r\n' \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/query.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/query.sh new file mode 100755 index 0000000000..4b1097e18d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/query.sh @@ -0,0 +1,4 @@ +wget --quiet \ + --method GET \ + --output-document \ + - 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/short.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/short.sh new file mode 100755 index 0000000000..e2101d85fb --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/short.sh @@ -0,0 +1,4 @@ +wget --quiet \ + --method GET \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/text-plain.sh b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/text-plain.sh new file mode 100755 index 0000000000..754ac9fd0a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/shell/wget/text-plain.sh @@ -0,0 +1,6 @@ +wget --quiet \ + --method POST \ + --header 'content-type: text/plain' \ + --body-data 'Hello World' \ + --output-document \ + - http://mockbin.com/har diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/application-form-encoded.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/application-form-encoded.swift new file mode 100755 index 0000000000..d60979ddd1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/application-form-encoded.swift @@ -0,0 +1,25 @@ +import Foundation + +let headers = ["content-type": "application/x-www-form-urlencoded"] + +let postData = NSMutableData(data: "foo=bar".data(using: String.Encoding.utf8)!) +postData.append("&hello=world".data(using: String.Encoding.utf8)!) + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "POST" +request.allHTTPHeaderFields = headers +request.httpBody = postData as Data + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/application-json.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/application-json.swift new file mode 100755 index 0000000000..93825f49b2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/application-json.swift @@ -0,0 +1,32 @@ +import Foundation + +let headers = ["content-type": "application/json"] +let parameters = [ + "number": 1, + "string": "f\"oo", + "arr": [1, 2, 3], + "nested": ["a": "b"], + "arr_mix": [1, "a", ["arr_mix_nested": []]], + "boolean": false +] as [String : Any] + +let postData = JSONSerialization.data(withJSONObject: parameters, options: []) + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "POST" +request.allHTTPHeaderFields = headers +request.httpBody = postData as Data + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/cookies.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/cookies.swift new file mode 100755 index 0000000000..3f1202d463 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/cookies.swift @@ -0,0 +1,21 @@ +import Foundation + +let headers = ["cookie": "foo=bar; bar=baz"] + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "POST" +request.allHTTPHeaderFields = headers + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/custom-method.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/custom-method.swift new file mode 100755 index 0000000000..597a5f8ac3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/custom-method.swift @@ -0,0 +1,18 @@ +import Foundation + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "PROPFIND" + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/full.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/full.swift new file mode 100755 index 0000000000..1d4784ec3a --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/full.swift @@ -0,0 +1,28 @@ +import Foundation + +let headers = [ + "cookie": "foo=bar; bar=baz", + "accept": "application/json", + "content-type": "application/x-www-form-urlencoded" +] + +let postData = NSMutableData(data: "foo=bar".data(using: String.Encoding.utf8)!) + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "POST" +request.allHTTPHeaderFields = headers +request.httpBody = postData as Data + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/headers.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/headers.swift new file mode 100755 index 0000000000..8902e1ace1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/headers.swift @@ -0,0 +1,24 @@ +import Foundation + +let headers = [ + "accept": "application/json", + "x-foo": "Bar" +] + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "GET" +request.allHTTPHeaderFields = headers + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/https.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/https.swift new file mode 100755 index 0000000000..8a4313cb4c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/https.swift @@ -0,0 +1,18 @@ +import Foundation + +let request = NSMutableURLRequest(url: NSURL(string: "https://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "GET" + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-data.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-data.swift new file mode 100755 index 0000000000..0bcf1a3d66 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-data.swift @@ -0,0 +1,52 @@ +import Foundation + +let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"] +let parameters = [ + [ + "name": "foo", + "value": "Hello World", + "fileName": "hello.txt", + "contentType": "text/plain" + ] +] + +let boundary = "---011000010111000001101001" + +var body = "" +var error: NSError? = nil +for param in parameters { + let paramName = param["name"]! + body += "--\(boundary)\r\n" + body += "Content-Disposition:form-data; name=\"\(paramName)\"" + if let filename = param["fileName"] { + let contentType = param["content-type"]! + let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) + if (error != nil) { + print(error) + } + body += "; filename=\"\(filename)\"\r\n" + body += "Content-Type: \(contentType)\r\n\r\n" + body += fileContent + } else if let paramValue = param["value"] { + body += "\r\n\r\n\(paramValue)" + } +} + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "POST" +request.allHTTPHeaderFields = headers +request.httpBody = postData as Data + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-file.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-file.swift new file mode 100755 index 0000000000..2944612160 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-file.swift @@ -0,0 +1,51 @@ +import Foundation + +let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"] +let parameters = [ + [ + "name": "foo", + "fileName": "test/fixtures/files/hello.txt", + "contentType": "text/plain" + ] +] + +let boundary = "---011000010111000001101001" + +var body = "" +var error: NSError? = nil +for param in parameters { + let paramName = param["name"]! + body += "--\(boundary)\r\n" + body += "Content-Disposition:form-data; name=\"\(paramName)\"" + if let filename = param["fileName"] { + let contentType = param["content-type"]! + let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) + if (error != nil) { + print(error) + } + body += "; filename=\"\(filename)\"\r\n" + body += "Content-Type: \(contentType)\r\n\r\n" + body += fileContent + } else if let paramValue = param["value"] { + body += "\r\n\r\n\(paramValue)" + } +} + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "POST" +request.allHTTPHeaderFields = headers +request.httpBody = postData as Data + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-form-data.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-form-data.swift new file mode 100755 index 0000000000..bafceef17d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/multipart-form-data.swift @@ -0,0 +1,50 @@ +import Foundation + +let headers = ["content-type": "multipart/form-data; boundary=---011000010111000001101001"] +let parameters = [ + [ + "name": "foo", + "value": "bar" + ] +] + +let boundary = "---011000010111000001101001" + +var body = "" +var error: NSError? = nil +for param in parameters { + let paramName = param["name"]! + body += "--\(boundary)\r\n" + body += "Content-Disposition:form-data; name=\"\(paramName)\"" + if let filename = param["fileName"] { + let contentType = param["content-type"]! + let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) + if (error != nil) { + print(error) + } + body += "; filename=\"\(filename)\"\r\n" + body += "Content-Type: \(contentType)\r\n\r\n" + body += fileContent + } else if let paramValue = param["value"] { + body += "\r\n\r\n\(paramValue)" + } +} + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "POST" +request.allHTTPHeaderFields = headers +request.httpBody = postData as Data + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/query.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/query.swift new file mode 100755 index 0000000000..8325525e23 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/query.swift @@ -0,0 +1,18 @@ +import Foundation + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "GET" + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/short.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/short.swift new file mode 100755 index 0000000000..1f4cd26a81 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/short.swift @@ -0,0 +1,18 @@ +import Foundation + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "GET" + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/text-plain.swift b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/text-plain.swift new file mode 100755 index 0000000000..910b4ac2c8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/output/swift/nsurlsession/text-plain.swift @@ -0,0 +1,24 @@ +import Foundation + +let headers = ["content-type": "text/plain"] + +let postData = NSData(data: "Hello World".data(using: String.Encoding.utf8)!) + +let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, + cachePolicy: .useProtocolCachePolicy, + timeoutInterval: 10.0) +request.httpMethod = "POST" +request.allHTTPHeaderFields = headers +request.httpBody = postData as Data + +let session = URLSession.shared +let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in + if (error != nil) { + print(error) + } else { + let httpResponse = response as? HTTPURLResponse + print(httpResponse) + } +}) + +dataTask.resume() diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/application-form-encoded.json b/packages/insomnia-httpsnippet/test/fixtures/requests/application-form-encoded.json new file mode 100755 index 0000000000..8dae7d7941 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/application-form-encoded.json @@ -0,0 +1,23 @@ +{ + "method": "POST", + "url": "http://mockbin.com/har", + "headers": [ + { + "name": "content-type", + "value": "application/x-www-form-urlencoded" + } + ], + "postData": { + "mimeType": "application/x-www-form-urlencoded", + "params": [ + { + "name": "foo", + "value": "bar" + }, + { + "name": "hello", + "value": "world" + } + ] + } +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/application-json.json b/packages/insomnia-httpsnippet/test/fixtures/requests/application-json.json new file mode 100755 index 0000000000..3b62f0d798 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/application-json.json @@ -0,0 +1,14 @@ +{ + "method": "POST", + "url": "http://mockbin.com/har", + "headers": [ + { + "name": "content-type", + "value": "application/json" + } + ], + "postData": { + "mimeType": "application/json", + "text": "{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}" + } +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/cookies.json b/packages/insomnia-httpsnippet/test/fixtures/requests/cookies.json new file mode 100755 index 0000000000..248907cf65 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/cookies.json @@ -0,0 +1,14 @@ +{ + "method": "POST", + "url": "http://mockbin.com/har", + "cookies": [ + { + "name": "foo", + "value": "bar" + }, + { + "name": "bar", + "value": "baz" + } + ] +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/custom-method.json b/packages/insomnia-httpsnippet/test/fixtures/requests/custom-method.json new file mode 100755 index 0000000000..346d7145a2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/custom-method.json @@ -0,0 +1,4 @@ +{ + "method": "PROPFIND", + "url": "http://mockbin.com/har" +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/full.json b/packages/insomnia-httpsnippet/test/fixtures/requests/full.json new file mode 100755 index 0000000000..640839a1f8 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/full.json @@ -0,0 +1,48 @@ +{ + "method": "POST", + "url": "http://mockbin.com/har?key=value", + "httpVersion": "HTTP/1.1", + "queryString": [ + { + "name": "foo", + "value": "bar" + }, + { + "name": "foo", + "value": "baz" + }, + { + "name": "baz", + "value": "abc" + } + ], + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "content-type", + "value": "application/x-www-form-urlencoded" + } + ], + "cookies": [ + { + "name": "foo", + "value": "bar" + }, + { + "name": "bar", + "value": "baz" + } + ], + "postData": { + "mimeType": "application/x-www-form-urlencoded", + "params": [ + { + "name": "foo", + "value": "bar" + } + ] + } +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/headers.json b/packages/insomnia-httpsnippet/test/fixtures/requests/headers.json new file mode 100755 index 0000000000..6f41b38208 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/headers.json @@ -0,0 +1,14 @@ +{ + "method": "GET", + "url": "http://mockbin.com/har", + "headers": [ + { + "name": "accept", + "value": "application/json" + }, + { + "name": "x-foo", + "value": "Bar" + } + ] +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/https.json b/packages/insomnia-httpsnippet/test/fixtures/requests/https.json new file mode 100755 index 0000000000..339a88e6e2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/https.json @@ -0,0 +1,4 @@ +{ + "method": "GET", + "url": "https://mockbin.com/har" +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/index.js b/packages/insomnia-httpsnippet/test/fixtures/requests/index.js new file mode 100755 index 0000000000..0d8e0250ca --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/index.js @@ -0,0 +1,3 @@ +'use strict'; + +module.exports = require('require-directory')(module); diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-data.json b/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-data.json new file mode 100755 index 0000000000..fb9098fdb6 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-data.json @@ -0,0 +1,21 @@ +{ + "method": "POST", + "url": "http://mockbin.com/har", + "headers": [ + { + "name": "content-type", + "value": "multipart/form-data" + } + ], + "postData": { + "mimeType": "multipart/form-data", + "params": [ + { + "name": "foo", + "value": "Hello World", + "fileName": "hello.txt", + "contentType": "text/plain" + } + ] + } +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-file.json b/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-file.json new file mode 100755 index 0000000000..8623c1d3c1 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-file.json @@ -0,0 +1,20 @@ +{ + "method": "POST", + "url": "http://mockbin.com/har", + "headers": [ + { + "name": "content-type", + "value": "multipart/form-data" + } + ], + "postData": { + "mimeType": "multipart/form-data", + "params": [ + { + "name": "foo", + "fileName": "test/fixtures/files/hello.txt", + "contentType": "text/plain" + } + ] + } +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-form-data.json b/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-form-data.json new file mode 100755 index 0000000000..4db5eeea6f --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/multipart-form-data.json @@ -0,0 +1,19 @@ +{ + "method": "POST", + "url": "http://mockbin.com/har", + "headers": [ + { + "name": "content-type", + "value": "multipart/form-data" + } + ], + "postData": { + "mimeType": "multipart/form-data", + "params": [ + { + "name": "foo", + "value": "bar" + } + ] + } +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/query.json b/packages/insomnia-httpsnippet/test/fixtures/requests/query.json new file mode 100755 index 0000000000..5d2e614526 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/query.json @@ -0,0 +1,19 @@ +{ + "method": "GET", + "url": "http://mockbin.com/har?key=value", + "httpVersion": "HTTP/1.1", + "queryString": [ + { + "name": "foo", + "value": "bar" + }, + { + "name": "foo", + "value": "baz" + }, + { + "name": "baz", + "value": "abc" + } + ] +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/short.json b/packages/insomnia-httpsnippet/test/fixtures/requests/short.json new file mode 100755 index 0000000000..a4d8f00a11 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/short.json @@ -0,0 +1,4 @@ +{ + "method": "GET", + "url": "http://mockbin.com/har" +} diff --git a/packages/insomnia-httpsnippet/test/fixtures/requests/text-plain.json b/packages/insomnia-httpsnippet/test/fixtures/requests/text-plain.json new file mode 100755 index 0000000000..6f6f3072c3 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/fixtures/requests/text-plain.json @@ -0,0 +1,14 @@ +{ + "method": "POST", + "url": "http://mockbin.com/har", + "headers": [ + { + "name": "content-type", + "value": "text/plain" + } + ], + "postData": { + "mimeType": "text/plain", + "text": "Hello World" + } +} diff --git a/packages/insomnia-httpsnippet/test/index.js b/packages/insomnia-httpsnippet/test/index.js new file mode 100755 index 0000000000..62a8371648 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/index.js @@ -0,0 +1,193 @@ +/* global describe, it */ + +'use strict' + +var fixtures = require('./fixtures') +var HTTPSnippet = require('../src') + +var should = require('should') + +describe('HTTPSnippet', function () { + it('should return false if no matching target', function (done) { + var snippet = new HTTPSnippet(fixtures.requests.short) + + snippet.convert(null).should.eql(false) + + done() + }) + + it('should fail validation', function (done) { + var snippet; + + /* eslint-disable no-extra-parens */ + (function () { + snippet = new HTTPSnippet({yolo: 'foo'}) + }).should.throw(Error) + + should.not.exist(snippet) + + done() + }) + + it('should parse HAR file with multiple entries', function (done) { + var snippet = new HTTPSnippet(fixtures.har) + + snippet.should.have.property('requests').and.be.an.Array + snippet.requests.length.should.equal(2) + + var results = snippet.convert('shell') + + results.should.be.an.Array + results.length.should.equal(2) + + done() + }) + + it('should convert multipart/mixed to multipart/form-data', function (done) { + var req = new HTTPSnippet(fixtures.mimetypes['multipart/mixed']).requests[0] + + req.postData.mimeType.should.eql('multipart/form-data') + + done() + }) + + it('should convert multipart/related to multipart/form-data', function (done) { + var req = new HTTPSnippet(fixtures.mimetypes['multipart/related']).requests[0] + + req.postData.mimeType.should.eql('multipart/form-data') + + done() + }) + + it('should convert multipart/alternative to multipart/form-data', function (done) { + var req = new HTTPSnippet(fixtures.mimetypes['multipart/alternative']).requests[0] + + req.postData.mimeType.should.eql('multipart/form-data') + + done() + }) + + it('should convert text/json to application/json', function (done) { + var req = new HTTPSnippet(fixtures.mimetypes['text/json']).requests[0] + + req.postData.mimeType.should.eql('application/json') + + done() + }) + + it('should convert text/x-json to application/json', function (done) { + var req = new HTTPSnippet(fixtures.mimetypes['text/x-json']).requests[0] + + req.postData.mimeType.should.eql('application/json') + + done() + }) + + it('should convert application/x-json to application/json', function (done) { + var req = new HTTPSnippet(fixtures.mimetypes['application/x-json']).requests[0] + + req.postData.mimeType.should.eql('application/json') + + done() + }) + + it('should gracefully fallback if not able to parse JSON', function (done) { + var req = new HTTPSnippet(fixtures.mimetypes['invalid-json']).requests[0] + + req.postData.mimeType.should.eql('text/plain') + + done() + }) + + it('should set postData.text = empty string when postData.params === undefined in application/x-www-form-urlencoded', function (done) { + var req = new HTTPSnippet(fixtures.mimetypes['application/x-www-form-urlencoded']).requests[0] + + req.postData.text.should.eql('') + + done() + }) + + it('should add "uriObj" to source object', function (done) { + var req = new HTTPSnippet(fixtures.requests.query).requests[0] + + req.uriObj.should.be.an.Object + req.uriObj.should.eql({ + auth: null, + hash: null, + host: 'mockbin.com', + hostname: 'mockbin.com', + href: 'http://mockbin.com/har?key=value', + path: '/har?foo=bar&foo=baz&baz=abc&key=value', + pathname: '/har', + port: null, + protocol: 'http:', + query: { + baz: 'abc', + key: 'value', + foo: [ + 'bar', + 'baz' + ] + }, + search: 'foo=bar&foo=baz&baz=abc&key=value', + slashes: true + }) + + done() + }) + + it('should add "queryObj" to source object', function (done) { + var req = new HTTPSnippet(fixtures.requests.query).requests[0] + + req.queryObj.should.be.an.Object + req.queryObj.should.eql({ + baz: 'abc', + key: 'value', + foo: [ + 'bar', + 'baz' + ] + }) + + done() + }) + + it('should add "headersObj" to source object', function (done) { + var req = new HTTPSnippet(fixtures.requests.headers).requests[0] + + req.headersObj.should.be.an.Object + req.headersObj.should.eql({ + 'accept': 'application/json', + 'x-foo': 'Bar' + }) + + done() + }) + + it('should modify orignal url to strip query string', function (done) { + var req = new HTTPSnippet(fixtures.requests.query).requests[0] + + req.url.should.be.a.String + req.url.should.eql('http://mockbin.com/har') + + done() + }) + + it('should add "fullUrl" to source object', function (done) { + var req = new HTTPSnippet(fixtures.requests.query).requests[0] + + req.fullUrl.should.be.a.String + req.fullUrl.should.eql('http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value') + + done() + }) + + it('should fix "path" property of "uriObj" to match queryString', function (done) { + var req = new HTTPSnippet(fixtures.requests.query).requests[0] + + req.uriObj.path.should.be.a.String + req.uriObj.path.should.eql('/har?foo=bar&foo=baz&baz=abc&key=value') + + done() + }) +}) diff --git a/packages/insomnia-httpsnippet/test/reducer.js b/packages/insomnia-httpsnippet/test/reducer.js new file mode 100755 index 0000000000..2bbbbedd86 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/reducer.js @@ -0,0 +1,38 @@ +/* global describe, it */ + +'use strict' + +var reducer = require('../src/helpers/reducer') + +require('should') + +describe('Reducer', function () { + it('should convert array object pair to key-value object', function (done) { + var query = [ + {name: 'key', value: 'value'}, + {name: 'foo', value: 'bar'} + ] + + var obj = query.reduce(reducer, {}) + + obj.should.be.an.Object + obj.should.eql({key: 'value', foo: 'bar'}) + + done() + }) + + it('should convert multi-dimensional arrays to key=[array] object', function (done) { + var query = [ + {name: 'key', value: 'value'}, + {name: 'foo', value: 'bar1'}, + {name: 'foo', value: 'bar2'} + ] + + var obj = query.reduce(reducer, {}) + + obj.should.be.an.Object + obj.should.eql({key: 'value', foo: ['bar1', 'bar2']}) + + done() + }) +}) diff --git a/packages/insomnia-httpsnippet/test/requests.js b/packages/insomnia-httpsnippet/test/requests.js new file mode 100755 index 0000000000..ae3abb9302 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/requests.js @@ -0,0 +1,68 @@ +/* global describe, it */ + +'use strict' + +var fixtures = require('./fixtures') +var HTTPSnippet = require('../src') +var targets = require('../src/targets') +var shell = require('child_process') +var util = require('util') + +require('should') + +var base = './test/fixtures/output/' +var requests = [ 'application-form-encoded', + 'application-json', + 'cookies', + 'custom-method', + 'headers', + 'https', + 'multipart-data', + 'multipart-form-data', + 'short' +] + +// test all the things! +fixtures.cli.forEach(function (cli) { + describe(targets[cli.target].info.title + ' Request Validation', function () { + cli.clients.forEach(function (client) { + requests.forEach(function (request) { + it(client + ' request should match mock for ' + request, function (done) { + var stdout = '' + var fixture = cli.target + '/' + client + '/' + request + HTTPSnippet.extname(cli.target) + var command = util.format(cli.run, base + fixture) + + var ls = shell.exec(command) + + ls.stdout.on('data', function (data) { + stdout += data + }) + + ls.on('exit', function (code) { + try { + var har = JSON.parse(stdout) + } catch (err) { + err.should.be.null + } + + // make an exception for multipart/form-data + if (fixtures.requests[request].headers) { + fixtures.requests[request].headers.forEach(function (header, index) { + if (header.name === 'content-type' && header.value === 'multipart/form-data') { + delete fixtures.requests[request].headers[index] + } + }) + } + + har.should.have.property('log') + har.log.should.have.property('entries').and.be.Array + har.log.entries[0].should.have.property('request') + har.log.entries[0].request.should.containDeep(fixtures.requests[request]) + + done() + }) + }) + }) + }) + }) +}) diff --git a/packages/insomnia-httpsnippet/test/targets.js b/packages/insomnia-httpsnippet/test/targets.js new file mode 100755 index 0000000000..be1aa0dde2 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets.js @@ -0,0 +1,102 @@ +/* global describe, it */ + +'use strict' + +var fixtures = require('./fixtures') +var fs = require('fs') +var glob = require('glob') +var HTTPSnippet = require('../src') +var path = require('path') +var should = require('should') +var targets = require('../src/targets') + +var base = './test/fixtures/output/' + +// read all output files +var output = glob.sync('**/*', {cwd: base, nodir: true}).reduce(function (obj, name) { + obj[name] = fs.readFileSync(base + name) + return obj +}, {}) + +var clearInfo = function (key) { + return !~['info', 'index'].indexOf(key) +} + +var itShouldHaveTests = function (target, client) { + it(target + ' should have tests', function (done) { + fs.readdir(path.join(__dirname, 'targets', target), function (err, files) { + should.not.exist(err) + files.length.should.be.above(0) + files.should.containEql(client + '.js') + done() + }) + }) +} + +var itShouldHaveInfo = function (name, obj) { + it(name + ' should have info method', function () { + obj.should.have.property('info').and.be.an.Object + obj.info.key.should.equal(name).and.be.a.String + obj.info.title.should.be.a.String + }) +} + +var itShouldHaveRequestTestOutputFixture = function (request, target, path) { + var fixture = target + '/' + path + request + HTTPSnippet.extname(target) + + it('should have output test for ' + request, function () { + Object.keys(output).indexOf(fixture).should.be.greaterThan(-1, 'Missing ' + fixture + ' fixture file for target: ' + target + '. Snippet tests will be skipped.') + }) +} + +var itShouldGenerateOutput = function (request, path, target, client) { + var fixture = path + request + HTTPSnippet.extname(target) + + it('should generate ' + request + ' snippet', function () { + if (Object.keys(output).indexOf(fixture) === -1) { + this.skip() + } + var instance = new HTTPSnippet(fixtures.requests[request]) + var result = instance.convert(target, client) + '\n' + + result.should.be.a.String + result.should.equal(output[fixture].toString()) + }) +} + +describe('Available Targets', function () { + var targets = HTTPSnippet.availableTargets() + + targets.forEach(function (target) { + it('available-targets.json should include ' + target.title, function () { + fixtures['available-targets'].should.containEql(target) + }) + }) +}) + +// test all the things! +Object.keys(targets).forEach(function (target) { + describe(targets[target].info.title, function () { + itShouldHaveInfo(target, targets[target]) + + Object.keys(targets[target]).filter(clearInfo).forEach(function (client) { + describe(client, function () { + itShouldHaveInfo(client, targets[target][client]) + + itShouldHaveTests(target, client) + + var test = require(path.join(__dirname, 'targets', target, client)) + + test(HTTPSnippet, fixtures) + + describe('snippets', function () { + Object.keys(fixtures.requests).filter(clearInfo).forEach(function (request) { + itShouldHaveRequestTestOutputFixture(request, target, client + '/') + + itShouldGenerateOutput(request, target + '/' + client + '/', target, client) + }) + }) + }) + }) + }) +}) diff --git a/packages/insomnia-httpsnippet/test/targets/c/libcurl.js b/packages/insomnia-httpsnippet/test/targets/c/libcurl.js new file mode 100755 index 0000000000..9ad8c1790d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/c/libcurl.js @@ -0,0 +1,5 @@ +'use strict' + +require('should') + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/csharp/restsharp.js b/packages/insomnia-httpsnippet/test/targets/csharp/restsharp.js new file mode 100755 index 0000000000..9ad8c1790d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/csharp/restsharp.js @@ -0,0 +1,5 @@ +'use strict' + +require('should') + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/go/native.js b/packages/insomnia-httpsnippet/test/targets/go/native.js new file mode 100755 index 0000000000..a2afafcf54 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/go/native.js @@ -0,0 +1,40 @@ +/* global it */ + +'use strict' + +require('should') + +module.exports = function (HTTPSnippet, fixtures) { + it('should support false boilerplate option', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('go', 'native', { + showBoilerplate: false + }) + + result.should.be.a.String + result.should.eql('url := \"http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value\"\n\npayload := strings.NewReader(\"foo=bar\")\n\nreq, _ := http.NewRequest(\"POST\", url, payload)\n\nreq.Header.Add(\"cookie\", \"foo=bar; bar=baz\")\nreq.Header.Add(\"accept\", \"application/json\")\nreq.Header.Add(\"content-type\", \"application/x-www-form-urlencoded\")\n\nres, _ := http.DefaultClient.Do(req)\n\ndefer res.Body.Close()\nbody, _ := ioutil.ReadAll(res.Body)\n\nfmt.Println(res)\nfmt.Println(string(body))') + }) + it('should support checkErrors option', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('go', 'native', { + checkErrors: true + }) + + result.should.be.a.String + result.should.eql('package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value\"\n\n\tpayload := strings.NewReader(\"foo=bar\")\n\n\treq, err := http.NewRequest(\"POST\", url, payload)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treq.Header.Add(\"cookie\", \"foo=bar; bar=baz\")\n\treq.Header.Add(\"accept\", \"application/json\")\n\treq.Header.Add(\"content-type\", \"application/x-www-form-urlencoded\")\n\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tdefer res.Body.Close()\n\tbody, err := ioutil.ReadAll(res.Body)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}') + }) + it('should support printBody option', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('go', 'native', { + printBody: false + }) + + result.should.be.a.String + result.should.eql('package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n)\n\nfunc main() {\n\n\turl := \"http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value\"\n\n\tpayload := strings.NewReader(\"foo=bar\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"cookie\", \"foo=bar; bar=baz\")\n\treq.Header.Add(\"accept\", \"application/json\")\n\treq.Header.Add(\"content-type\", \"application/x-www-form-urlencoded\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tfmt.Println(res)\n\n}') + }) + it('should support timeout option', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('go', 'native', { + timeout: 30 + }) + + result.should.be.a.String + result.should.eql('package main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\tclient := http.Client{\n\t\tTimeout: time.Duration(30 * time.Second),\n\t}\n\n\turl := \"http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value\"\n\n\tpayload := strings.NewReader(\"foo=bar\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"cookie\", \"foo=bar; bar=baz\")\n\treq.Header.Add(\"accept\", \"application/json\")\n\treq.Header.Add(\"content-type\", \"application/x-www-form-urlencoded\")\n\n\tres, _ := client.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}') + }) +} diff --git a/packages/insomnia-httpsnippet/test/targets/java/okhttp.js b/packages/insomnia-httpsnippet/test/targets/java/okhttp.js new file mode 100755 index 0000000000..9ad8c1790d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/java/okhttp.js @@ -0,0 +1,5 @@ +'use strict' + +require('should') + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/java/unirest.js b/packages/insomnia-httpsnippet/test/targets/java/unirest.js new file mode 100755 index 0000000000..9ad8c1790d --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/java/unirest.js @@ -0,0 +1,5 @@ +'use strict' + +require('should') + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/javascript/jquery.js b/packages/insomnia-httpsnippet/test/targets/javascript/jquery.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/javascript/jquery.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/javascript/xhr.js b/packages/insomnia-httpsnippet/test/targets/javascript/xhr.js new file mode 100755 index 0000000000..a4ff8528dd --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/javascript/xhr.js @@ -0,0 +1,16 @@ +/* global it */ + +'use strict' + +require('should') + +module.exports = function (HTTPSnippet, fixtures) { + it('should not use cors', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('javascript', 'xhr', { + cors: false + }) + + result.should.be.a.String + result.replace(/\n/g, '').should.eql('var data = null;var xhr = new XMLHttpRequest();xhr.addEventListener("readystatechange", function () { if (this.readyState === this.DONE) { console.log(this.responseText); }});xhr.open("GET", "http://mockbin.com/har");xhr.send(data);') + }) +} diff --git a/packages/insomnia-httpsnippet/test/targets/node/native.js b/packages/insomnia-httpsnippet/test/targets/node/native.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/node/native.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/node/request.js b/packages/insomnia-httpsnippet/test/targets/node/request.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/node/request.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/node/unirest.js b/packages/insomnia-httpsnippet/test/targets/node/unirest.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/node/unirest.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/objc/nsurlsession.js b/packages/insomnia-httpsnippet/test/targets/objc/nsurlsession.js new file mode 100755 index 0000000000..011e0149ea --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/objc/nsurlsession.js @@ -0,0 +1,32 @@ +/* global it */ + +'use strict' + +require('should') + +module.exports = function (HTTPSnippet, fixtures) { + it('should support an indent option', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('objc', { + indent: ' ' + }) + + result.should.be.a.String + result.replace(/\n/g, '').should.eql('#import NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];[request setHTTPMethod:@"GET"];NSURLSession *session = [NSURLSession sharedSession];NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"%@", error); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSLog(@"%@", httpResponse); } }];[dataTask resume];') + }) + it('should support a timeout option', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('objc', { + timeout: 5 + }) + + result.should.be.a.String + result.replace(/\n/g, '').should.eql('#import NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:5.0];[request setHTTPMethod:@"GET"];NSURLSession *session = [NSURLSession sharedSession];NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"%@", error); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSLog(@"%@", httpResponse); } }];[dataTask resume];') + }) + it('should support pretty option', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('objc', { + pretty: false + }) + + result.should.be.a.String + result.replace(/\n/g, '').should.eql('#import NSDictionary *headers = @{ @"cookie": @"foo=bar; bar=baz", @"accept": @"application/json", @"content-type": @"application/x-www-form-urlencoded" };NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"foo=bar" dataUsingEncoding:NSUTF8StringEncoding]];NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];[request setHTTPMethod:@"POST"];[request setAllHTTPHeaderFields:headers];[request setHTTPBody:postData];NSURLSession *session = [NSURLSession sharedSession];NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { if (error) { NSLog(@"%@", error); } else { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response; NSLog(@"%@", httpResponse); } }];[dataTask resume];') + }) +} diff --git a/packages/insomnia-httpsnippet/test/targets/ocaml/cohttp.js b/packages/insomnia-httpsnippet/test/targets/ocaml/cohttp.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/ocaml/cohttp.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/php/curl.js b/packages/insomnia-httpsnippet/test/targets/php/curl.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/php/curl.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/php/http1.js b/packages/insomnia-httpsnippet/test/targets/php/http1.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/php/http1.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/php/http2.js b/packages/insomnia-httpsnippet/test/targets/php/http2.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/php/http2.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/python/python3.js b/packages/insomnia-httpsnippet/test/targets/python/python3.js new file mode 100755 index 0000000000..ce4678eb9c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/python/python3.js @@ -0,0 +1,6 @@ +'use strict' + +require('should') + +module.exports = function (snippet, fixtures) { +} diff --git a/packages/insomnia-httpsnippet/test/targets/python/requests.js b/packages/insomnia-httpsnippet/test/targets/python/requests.js new file mode 100755 index 0000000000..ce4678eb9c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/python/requests.js @@ -0,0 +1,6 @@ +'use strict' + +require('should') + +module.exports = function (snippet, fixtures) { +} diff --git a/packages/insomnia-httpsnippet/test/targets/ruby/native.js b/packages/insomnia-httpsnippet/test/targets/ruby/native.js new file mode 100755 index 0000000000..b77cc77e7c --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/ruby/native.js @@ -0,0 +1,3 @@ +'use strict' + +module.exports = function (snippet, fixtures) {} diff --git a/packages/insomnia-httpsnippet/test/targets/shell/curl.js b/packages/insomnia-httpsnippet/test/targets/shell/curl.js new file mode 100755 index 0000000000..2206a6e3da --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/shell/curl.js @@ -0,0 +1,46 @@ +/* global it */ + +'use strict' + +require('should') + +module.exports = function (HTTPSnippet, fixtures) { + it('should use short options', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', { + short: true, + indent: false + }) + + result.should.be.a.String + result.should.eql("curl -X POST 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' -H 'accept: application/json' -H 'content-type: application/x-www-form-urlencoded' -b 'foo=bar; bar=baz' -d foo=bar") + }) + + it('should use binary option', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', { + short: true, + indent: false, + binary: true + }) + + result.should.be.a.String + result.should.eql("curl -X POST 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' -H 'accept: application/json' -H 'content-type: application/x-www-form-urlencoded' -b 'foo=bar; bar=baz' --data-binary foo=bar") + }) + + it('should use --http1.0 for HTTP/1.0', function () { + var result = new HTTPSnippet(fixtures.curl.http1).convert('shell', 'curl', { + indent: false + }) + + result.should.be.a.String + result.should.eql('curl --request GET --url http://mockbin.com/request --http1.0') + }) + + it('should use custom indentation', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', { + indent: '@' + }) + + result.should.be.a.String + result.replace(/\\\n/g, '').should.eql("curl --request POST @--url 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' @--header 'accept: application/json' @--header 'content-type: application/x-www-form-urlencoded' @--cookie 'foo=bar; bar=baz' @--data foo=bar") + }) +} diff --git a/packages/insomnia-httpsnippet/test/targets/shell/httpie.js b/packages/insomnia-httpsnippet/test/targets/shell/httpie.js new file mode 100755 index 0000000000..8a07a86553 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/shell/httpie.js @@ -0,0 +1,94 @@ +/* global it */ + +'use strict' + +require('should') + +module.exports = function (HTTPSnippet, fixtures) { + it('should ask for verbose output', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('shell', 'httpie', { + indent: false, + verbose: true + }) + + result.should.be.a.String + result.should.eql('http --verbose GET http://mockbin.com/har') + }) + + it('should use short flags', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('shell', 'httpie', { + body: true, + cert: 'foo', + headers: true, + indent: false, + pretty: 'x', + print: 'x', + short: true, + style: 'x', + timeout: 1, + verbose: true, + verify: 'x' + }) + + result.should.be.a.String + result.should.eql('http -h -b -v -p=x --verify=x --cert=foo --pretty=x --style=x --timeout=1 GET http://mockbin.com/har') + }) + + it('should use long flags', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('shell', 'httpie', { + body: true, + cert: 'foo', + headers: true, + indent: false, + pretty: 'x', + print: 'x', + style: 'x', + timeout: 1, + verbose: true, + verify: 'x' + }) + + result.should.be.a.String + result.should.eql('http --headers --body --verbose --print=x --verify=x --cert=foo --pretty=x --style=x --timeout=1 GET http://mockbin.com/har') + }) + + it('should use custom indentation', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'httpie', { + indent: '@' + }) + + result.should.be.a.String + result.replace(/\\\n/g, '').should.eql("http --form POST 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' @accept:application/json @content-type:application/x-www-form-urlencoded @cookie:'foo=bar; bar=baz' @foo=bar") + }) + + it('should use queryString parameters', function () { + var result = new HTTPSnippet(fixtures.requests.query).convert('shell', 'httpie', { + indent: false, + queryParams: true + }) + + result.should.be.a.String + result.replace(/\\\n/g, '').should.eql('http GET http://mockbin.com/har foo==bar foo==baz baz==abc key==value') + }) + + it('should build parameterized output of query string', function () { + var result = new HTTPSnippet(fixtures.requests.query).convert('shell', 'httpie', { + indent: false, + queryParams: true + }) + + result.should.be.a.String + result.replace(/\\\n/g, '').should.eql('http GET http://mockbin.com/har foo==bar foo==baz baz==abc key==value') + }) + + it('should build parameterized output of post data', function () { + var result = new HTTPSnippet(fixtures.requests['application-form-encoded']).convert('shell', 'httpie', { + short: true, + indent: false, + queryParams: true + }) + + result.should.be.a.String + result.replace(/\\\n/g, '').should.eql('http -f POST http://mockbin.com/har content-type:application/x-www-form-urlencoded foo=bar hello=world') + }) +} diff --git a/packages/insomnia-httpsnippet/test/targets/shell/wget.js b/packages/insomnia-httpsnippet/test/targets/shell/wget.js new file mode 100755 index 0000000000..3b3386a281 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/shell/wget.js @@ -0,0 +1,48 @@ +/* global it */ + +'use strict' + +require('should') + +module.exports = function (HTTPSnippet, fixtures) { + it('should use short options', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'wget', { + short: true, + indent: false + }) + + result.should.be.a.String + result.should.eql("wget -q --method POST --header 'cookie: foo=bar; bar=baz' --header 'accept: application/json' --header 'content-type: application/x-www-form-urlencoded' --body-data foo=bar -O - 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value'") + }) + + it('should ask for -v output', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('shell', 'wget', { + short: true, + indent: false, + verbose: true + }) + + result.should.be.a.String + result.should.eql('wget -v --method GET -O - http://mockbin.com/har') + }) + + it('should ask for --verbose output', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('shell', 'wget', { + short: false, + indent: false, + verbose: true + }) + + result.should.be.a.String + result.should.eql('wget --verbose --method GET --output-document - http://mockbin.com/har') + }) + + it('should use custom indentation', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'wget', { + indent: '@' + }) + + result.should.be.a.String + result.replace(/\\\n/g, '').should.eql("wget --quiet @--method POST @--header 'cookie: foo=bar; bar=baz' @--header 'accept: application/json' @--header 'content-type: application/x-www-form-urlencoded' @--body-data foo=bar @--output-document @- 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value'") + }) +} diff --git a/packages/insomnia-httpsnippet/test/targets/swift/nsurlsession.js b/packages/insomnia-httpsnippet/test/targets/swift/nsurlsession.js new file mode 100755 index 0000000000..5aefd4ea52 --- /dev/null +++ b/packages/insomnia-httpsnippet/test/targets/swift/nsurlsession.js @@ -0,0 +1,32 @@ +/* global it */ + +'use strict' + +require('should') + +module.exports = function (HTTPSnippet, fixtures) { + it('should support an indent option', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('swift', { + indent: ' ' + }) + + result.should.be.a.String + result.replace(/\n/g, '').should.eql('import Foundationlet request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)request.httpMethod = "GET"let session = URLSession.sharedlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) }})dataTask.resume()') + }) + it('should support a timeout option', function () { + var result = new HTTPSnippet(fixtures.requests.short).convert('swift', { + timeout: 5 + }) + + result.should.be.a.String + result.replace(/\n/g, '').should.eql('import Foundationlet request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 5.0)request.httpMethod = "GET"let session = URLSession.sharedlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) }})dataTask.resume()') + }) + it('should support pretty option', function () { + var result = new HTTPSnippet(fixtures.requests.full).convert('swift', { + pretty: false + }) + + result.should.be.a.String + result.replace(/\n/g, '').should.eql('import Foundationlet headers = ["cookie": "foo=bar; bar=baz", "accept": "application/json", "content-type": "application/x-www-form-urlencoded"]let postData = NSMutableData(data: "foo=bar".data(using: String.Encoding.utf8)!)let request = NSMutableURLRequest(url: NSURL(string: "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0)request.httpMethod = "POST"request.allHTTPHeaderFields = headersrequest.httpBody = postData as Datalet session = URLSession.sharedlet dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) }})dataTask.resume()') + }) +}