Browse Source

Swap string/object header examples round

pull/7/head
Luke Childs 8 years ago
parent
commit
83eddd806d
  1. 44
      README.md

44
README.md

@ -17,17 +17,16 @@ npm install --save expired
```js ```js
const expired = require('expired'); const expired = require('expired');
const headers = { const headers = `
'access-control-allow-origin': '*', Access-Control-Allow-Origin: *
'age': '0', Age: 0
'cache-control': 'public, max-age=300', Cache-Control: public, max-age=300
'content-encoding': 'gzip', Content-Encoding: gzip
'content-type': 'application/json;charset=utf-8', Content-Type: application/json;charset=utf-8
'date': 'Fri, 23 Dec 2016 05:50:31 GMT', Date: Fri, 23 Dec 2016 05:50:31 GMT
'last-modified': 'Fri, 23 Dec 2016 05:23:23 GMT', Last-Modified: Fri, 23 Dec 2016 05:23:23 GMT
'vary': 'Accept-Encoding, User-Agent', Vary: Accept-Encoding, User-Agent
'via': '1.1 varnish-v4' Via: 1.1 varnish-v4`;
};
expired(headers) expired(headers)
// false // false
@ -52,21 +51,22 @@ delay(600000).then(() => {
}); });
``` ```
You can also pass headers in as raw text: Response headers are parsed into an object by many HTTP modules. `expired` will also accept a parsed header object:
```js ```js
const expired = require('expired'); const expired = require('expired');
const headers = ` const headers = {
Access-Control-Allow-Origin: * 'access-control-allow-origin': '*',
Age: 0 'age': '0',
Cache-Control: public, max-age=300 'cache-control': 'public, max-age=300',
Content-Encoding: gzip 'content-encoding': 'gzip',
Content-Type: application/json;charset=utf-8 'content-type': 'application/json;charset=utf-8',
Date: Fri, 23 Dec 2016 05:50:31 GMT 'date': 'Fri, 23 Dec 2016 05:50:31 GMT',
Last-Modified: Fri, 23 Dec 2016 05:23:23 GMT 'last-modified': 'Fri, 23 Dec 2016 05:23:23 GMT',
Vary: Accept-Encoding, User-Agent 'vary': 'Accept-Encoding, User-Agent',
Via: 1.1 varnish-v4`; 'via': '1.1 varnish-v4'
};
expired(headers) expired(headers)
// false // false

Loading…
Cancel
Save