Luke Childs
a67f157cff
Test stale cache entries that can't be revalidate are deleted from cache
8 years ago
Luke Childs
459cbbf958
swap no-cache for max-age=0
Makes intent more clear, the reponses should be cacheable but instantly stale to force revalidation
8 years ago
Luke Childs
b63a641245
Delete stale cache entries that can't be revalidated
8 years ago
Luke Childs
07a403c152
Revalidate stale cached responses that have Last-Modified/ETag headers.
8 years ago
Luke Childs
f56c508ab4
Test stale cache entries with ETag headers are revalidated
8 years ago
Luke Childs
b6b3401053
Test stale cache entries with Last-Modified headers are revalidated
8 years ago
Luke Childs
4e3a3dcf40
Rename /no-cache test endpoint to /no-store
8 years ago
Luke Childs
8ee8a4a249
More accurate test
Second response may not be directly after as all requests are async. It should be a larger number but not necessarily +1
8 years ago
Luke Childs
f6f915bae3
No point doing caching inside a function now it's only used once
8 years ago
Luke Childs
75a999545a
Include stream processing inside cache function
Response will always be a stream now
8 years ago
Luke Childs
6212f165ee
Move caching logic back into get()
8 years ago
Luke Childs
58ffa2bae8
Check the cache is actually being filled
Prevents weird errors passing tests e.g t.is(undefined, undefined) looks like two matching cache responses
8 years ago
Luke Childs
be4c431072
Make sure "/no-cache" test endpoint is completely unstorable
Without explicitly setting no-store the response can still be stored in the cache it's just instantly stale
8 years ago
Luke Childs
bd99d4dbee
requests => responses
8 years ago
Luke Childs
23d76e3fae
Don't redo what getStream already does
8 years ago
Luke Childs
159c3994a8
Use pipe instead of manually piping inside data
8 years ago
Luke Childs
d4cf24c421
Don't save buffer encoding, it's not needed
8 years ago
Luke Childs
dbb7f206e5
Cache stream responses
8 years ago
Luke Childs
838821d5a5
Rafactor caching into external function and only read stream once
8 years ago
Luke Childs
70d57d7211
Test stream responses are cached
8 years ago
Luke Childs
7d4365ec25
Check in binary test that data actually is binary
8 years ago
Luke Childs
b3f23ea9cd
Move test server endpoints out into test.before
cache endpoint was being needlessly duplicated
8 years ago
Luke Childs
f2026dc68b
Test cached response is re-encoded to current encoding option
8 years ago
Luke Childs
4e98913981
Test binary responses are cached
8 years ago
Luke Childs
a31c966e23
Store body data encoding so we can reliably convert to buffer
Otherwise all strings will be assumed to be UTF-8. They could potentially be base64, hex or any other encoding used in the original Got request
8 years ago
Luke Childs
f64dcc7f69
Move server endpoints inside test function for readability
8 years ago
Luke Childs
e4ae2c68b9
Don't serialize cache object to JSON
8 years ago
Luke Childs
39811aa860
Object destructuring on single line
8 years ago
Luke Childs
b8b341166d
Don't store stream in unnecessary variable
8 years ago
Luke Childs
903fbfaa84
Store status code and url in cache. Don't store headers.
No need to store headers as they're already stored in the cache policy and retrieved with policy.responseHeaders()
8 years ago
Luke Childs
b0490ca4a3
Simplify cache option check
8 years ago
Luke Childs
b65128e113
Move cache read logic into separate function
8 years ago
Luke Childs
b3201ea733
Use Map() as cache store in cache tests
8 years ago
Luke Childs
817de11b72
opts.cache API should match Map() API
8 years ago
Luke Childs
5ec945f527
Allow opts.cache.get to return value or Promise
8 years ago
Luke Childs
011ea0e50c
Include method in cache key
8 years ago
Luke Childs
0d6180a279
If we retrieve a stale cache entry, delete it immediately
8 years ago
Luke Childs
0f6f944b9e
Drop expired for http-cache-semantics
8 years ago
Luke Childs
28112935ca
Add basic cache tests
8 years ago
Luke Childs
49b6f00763
Return cached response immediately if not stale
8 years ago
Luke Childs
43023d5818
Optional response caching
8 years ago
Alexander Tesfamichael
21c5c78da7
Simplify URL argument test ( #296 )
8 years ago
Luke Childs
7b12b7582d
Don't throw HTTPError on 304 responses ( #252 )
8 years ago
Alexander Tesfamichael
a287f8ec8a
Add url to errors ( #286 )
8 years ago
Sindre Sorhus
a5f2730f48
Remove Node.js 4.4.4 from testing
Don't care about it.
8 years ago
Sindre Sorhus
62225224b8
Remove now moot workaround for flaky tests
Was only relevant for Node.js 0.10/0.12
8 years ago
Sindre Sorhus
1f1b6ffb6d
Bump dependencies and fix lint issues
8 years ago
Alexander Tesfamichael
a6907b4399
Use error constructor to check for ParseError ( #273 )
8 years ago
Alexander Tesfamichael
919703cd8e
Add protocol to stdError ( #277 )
* Add protocol property to error properties test
* Add protocol to stdError object
Adds the protocol to the stdError object got uses for all its errors.
Closes #249 .
8 years ago
Alexander Tesfamichael
39bf828251
Make (more) sure the error we get is the one we expect ( #267 )
8 years ago