@adobe/fetch
Advanced tools
Comparing version 3.1.4 to 3.2.0
{ | ||
"name": "@adobe/fetch", | ||
"version": "3.1.4", | ||
"version": "3.2.0", | ||
"description": "Light-weight Fetch implementation transparently supporting both HTTP/1(.1) and HTTP/2", | ||
@@ -64,3 +64,3 @@ "main": "src/index.js", | ||
"chai-iterator": "3.0.2", | ||
"eslint": "8.23.1", | ||
"eslint": "8.25.0", | ||
"eslint-config-airbnb-base": "15.0.0", | ||
@@ -79,3 +79,3 @@ "eslint-plugin-header": "3.1.1", | ||
"semantic-release": "19.0.5", | ||
"sinon": "14.0.0", | ||
"sinon": "14.0.1", | ||
"stream-buffers": "3.0.2" | ||
@@ -82,0 +82,0 @@ }, |
@@ -40,2 +40,3 @@ <div align="center"> | ||
- [HTTP/1.1 Keep-Alive](#http11-keep-alive) | ||
- [Extract Set-Cookie Header](#extract-set-cookie-header) | ||
- [Self-signed Certificates](#self-signed-certificates) | ||
@@ -459,2 +460,14 @@ - [Set cache size limit](#set-cache-size-limit) | ||
### Extract Set-Cookie Header | ||
Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.plain()`. This is an `@adobe/fetch` only API. | ||
```javascript | ||
const { fetch } = require('@adobe/fetch'); | ||
const resp = await fetch('https://httpbin.org/cookies/set?a=1&b=2'); | ||
// returns an array of values, instead of a string of comma-separated values | ||
console.log(resp.headers.plain()['set-cookie']); | ||
``` | ||
### Self-signed Certificates | ||
@@ -461,0 +474,0 @@ |
@@ -82,7 +82,21 @@ /* | ||
init.forEach(([name, value]) => { | ||
this.append(name, value); | ||
if (Array.isArray(value)) { | ||
// special case for Set-Cookie header which can have an array of values | ||
value.forEach((val) => { | ||
this.append(name, val); | ||
}); | ||
} else { | ||
this.append(name, value); | ||
} | ||
}); | ||
} else /* istanbul ignore else */ if (isPlainObject(init)) { | ||
for (const [name, value] of Object.entries(init)) { | ||
this.append(name, value); | ||
if (Array.isArray(value)) { | ||
// special case for Set-Cookie header which can have an array of values | ||
value.forEach((val) => { | ||
this.append(name, val); | ||
}); | ||
} else { | ||
this.set(name, value); | ||
} | ||
} | ||
@@ -102,3 +116,9 @@ } | ||
const val = this[INTERNALS].map.get(normalizeName(name)); | ||
return val === undefined ? null : val; | ||
if (val === undefined) { | ||
return null; | ||
} else if (Array.isArray(val)) { | ||
return val.join(', '); | ||
} else { | ||
return val; | ||
} | ||
} | ||
@@ -110,3 +130,9 @@ | ||
const oldVal = this[INTERNALS].map.get(nm); | ||
this[INTERNALS].map.set(nm, oldVal ? `${oldVal}, ${val}` : val); | ||
if (Array.isArray(oldVal)) { | ||
oldVal.push(val); | ||
} else if (oldVal === undefined) { | ||
this[INTERNALS].map.set(nm, val); | ||
} else { | ||
this[INTERNALS].map.set(nm, [oldVal, val]); | ||
} | ||
} | ||
@@ -113,0 +139,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
142863
3305
581