Socket
Socket
Sign inDemoInstall

got

Package Overview
Dependencies
Maintainers
3
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got - npm Package Compare versions

Comparing version 4.1.1 to 4.2.0

license

31

index.js

@@ -20,2 +20,3 @@ 'use strict';

var isPlainObj = require('is-plain-obj');
var parseJson = require('parse-json');

@@ -94,4 +95,5 @@ function requestAsEventEmitter(opts) {

try {
data = JSON.parse(data);
data = parseJson(data);
} catch (e) {
e.fileName = urlLib.format(opts);
err = new got.ParseError(e, opts);

@@ -164,2 +166,8 @@ }

proxy.setReadable(res);
var statusCode = res.statusCode;
if (statusCode < 200 || statusCode > 299) {
proxy.emit('error', new got.HTTPError(statusCode, opts), null, res);
}
proxy.emit('response', res);

@@ -170,2 +178,4 @@ });

ee.on('error', proxy.emit.bind(proxy, 'error'));
return proxy;

@@ -227,2 +237,19 @@ }

// check for unix domain socket
if (opts.hostname === 'unix') {
// extract socket path and request path
var matches = /(.+)\:(.+)/.exec(opts.path);
if (matches) {
var socketPath = matches[1];
var path = matches[2];
// make http.request use unix domain socket
// instead of host:port combination
opts.socketPath = socketPath;
opts.path = path;
opts.host = null;
}
}
return opts;

@@ -241,3 +268,3 @@ }

asCallback(opts, cb);
return;
return null;
}

@@ -244,0 +271,0 @@

9

package.json
{
"name": "got",
"version": "4.1.1",
"version": "4.2.0",
"description": "Simplified HTTP/HTTPS requests",

@@ -23,3 +23,3 @@ "license": "MIT",

"scripts": {
"test": "tap test/test-*.js"
"test": "xo && tap test/test-*.js"
},

@@ -53,2 +53,3 @@ "files": [

"object-assign": "^3.0.0",
"parse-json": "^2.1.0",
"pinkie-promise": "^1.0.0",

@@ -64,4 +65,6 @@ "prepend-http": "^1.0.0",

"pem": "^1.4.4",
"tap": "^1.0.0"
"tap": "^1.0.0",
"tempfile": "^1.1.1",
"xo": "*"
}
}

@@ -43,3 +43,6 @@ <h1 align="center">

})
.catch(console.error);
.catch(function (err) {
console.error(err);
console.error(err.response && err.response.body);
});

@@ -86,3 +89,3 @@ // Stream mode

If `body` is a plain Object, it will be stringified and sent as `application/x-www-form-urlencoded`.
If `body` is a plain Object, it will be stringified with [`querystring.stringify`](https://nodejs.org/api/querystring.html#querystring_querystring_stringify_obj_sep_eq_options) and sent as `application/x-www-form-urlencoded`.

@@ -203,3 +206,25 @@ ###### encoding

### Unix Domain Sockets
Requests can also be sent via [unix domain sockets](http://serverfault.com/questions/124517/whats-the-difference-between-unix-socket-and-tcp-ip-socket). Use the following URL scheme: `PROTOCOL://unix:SOCKET:PATH`.
- `PROTOCOL` - `http` or `https` *(optional)*
- `SOCKET` - absolute path to a unix domain socket, e.g. `/var/run/docker.sock`
- `PATH` - request path, e.g. `/v2/keys`
Example:
```js
got('http://unix:/var/run/docker.sock:/containers/json');
// or without protocol (http by default)
got('unix:/var/run/docker.sock:/containers/json');
```
Use-cases:
- [Docker API](https://docs.docker.com/articles/basics/#bind-docker-to-another-host-port-or-a-unix-socket) (/var/run/docker.sock)
- [fleet API](https://coreos.com/fleet/docs/latest/deployment-and-configuration.html#api) (/var/run/fleet.sock)
## Tip

@@ -206,0 +231,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