Socket
Socket
Sign inDemoInstall

httpsnippet

Package Overview
Dependencies
Maintainers
4
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpsnippet - npm Package Compare versions

Comparing version 1.19.1 to 1.20.0

src/targets/csharp/httpclient.js

5

package.json
{
"version": "1.19.1",
"version": "1.20.0",
"name": "httpsnippet",

@@ -19,2 +19,3 @@ "description": "HTTP Request snippet generator for *most* languages",

"httpie",
"httr",
"java",

@@ -85,3 +86,3 @@ "javascript",

"event-stream": "3.3.4",
"form-data": "^1.0.0-rc3",
"form-data": "3.0.0",
"fs-readfile-promise": "^2.0.1",

@@ -88,0 +89,0 @@ "fs-writefile-promise": "^1.0.3",

41

README.md

@@ -72,3 +72,3 @@ # HTTP Snippet [![version][npm-version]][npm-url] [![License][npm-license]][license-url]

*Required*
*Required*
Type: `object`

@@ -91,3 +91,3 @@

*Required*
*Required*
Type: `string`

@@ -124,3 +124,3 @@

*Required*
*Required*
Type: `string`

@@ -159,2 +159,35 @@

### addTarget(target)
#### target
*Required*
Type: `object`
Representation of a [conversion target](https://github.com/Kong/httpsnippet/wiki/Creating-Targets). Can use this to use targets that are not officially supported.
```js
const customLanguageTarget = require('httpsnippet-for-my-lang');
HTTPSnippet.addTarget(customLanguageTarget);
```
### addTargetClient(target, client)
### target
*Required*
Type: `string`
Name of [conversion target](https://github.com/Mashape/httpsnippet/wiki/Targets)
### client
*Required*
Type: `object`
Representation of a [conversion target client](https://github.com/Kong/httpsnippet/wiki/Creating-Targets). Can use this to use target clients that are not officially supported.
```js
const customClient = require('httpsnippet-for-my-node-http-client');
HTTPSnippet.addTargetClient('node', customClient);
```
## Documentation

@@ -203,3 +236,3 @@

[travis-url]: https://travis-ci.org/Kong/httpsnippet
[travis-image]: https://img.shields.io/travis/Kong/httpsnippet.svg?style=flat-square
[travis-image]: https://api.travis-ci.org/Kong/httpsnippet.svg?branch=master

@@ -206,0 +239,0 @@ [npm-url]: https://www.npmjs.com/package/httpsnippet

@@ -224,2 +224,28 @@ 'use strict'

module.exports.addTarget = function (target) {
if (!('info' in target)) {
throw new Error('The supplied custom target must contain an `info` object.')
} else if (!('key' in target.info) || !('title' in target.info) || !('extname' in target.info) || !('default' in target.info)) {
throw new Error('The supplied custom target must have an `info` object with a `key`, `title`, `extname`, and `default` property.')
} else if (targets.hasOwnProperty(target.info.key)) {
throw new Error('The supplied custom target already exists.')
} else if (Object.keys(target).length === 1) {
throw new Error('A custom target must have a client defined on it.')
}
targets[target.info.key] = target
}
module.exports.addTargetClient = function (target, client) {
if (!targets.hasOwnProperty(target)) {
throw new Error(`Sorry, but no ${target} target exists to add clients to.`)
} else if (!('info' in client)) {
throw new Error('The supplied custom target client must contain an `info` object.')
} else if (!('key' in client.info) || !('title' in client.info)) {
throw new Error('The supplied custom target client must have an `info` object with a `key` and `title` property.')
}
targets[target][client.info.key] = client
}
module.exports.availableTargets = function () {

@@ -226,0 +252,0 @@ return Object.keys(targets).map(function (key) {

@@ -11,3 +11,4 @@ 'use strict'

restsharp: require('./restsharp')
restsharp: require('./restsharp'),
httpclient: require('./httpclient')
}

@@ -17,2 +17,3 @@ 'use strict'

python: require('./python'),
r: require('./r'),
ruby: require('./ruby'),

@@ -19,0 +20,0 @@ shell: require('./shell'),

@@ -12,3 +12,5 @@ 'use strict'

okhttp: require('./okhttp'),
unirest: require('./unirest')
unirest: require('./unirest'),
asynchttp: require('./asynchttp')
}

@@ -72,3 +72,3 @@ /**

.push('.catch(err => {')
.push(1, 'console.log(err);')
.push(1, 'console.error(err);')
.push('});')

@@ -75,0 +75,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc