fix: accepting cookies with request (required for sites like

nytimes.com)
This commit is contained in:
Adam Pash 2016-09-12 10:08:49 -04:00
parent 74694ba8e2
commit 8fe3bec6b6
3 changed files with 19 additions and 1 deletions

View File

@ -22,5 +22,12 @@ describe('Iris', function() {
// console.log(result) // console.log(result)
}) })
it('does the nyt', async function() {
const result = await Iris.parse('http://www.nytimes.com/2016/08/16/upshot/the-state-of-the-clinton-trump-race-is-it-over.html?_r=0')
// console.log(result)
})
}) })
}) })

View File

@ -21,9 +21,13 @@ export default async function fetchResource(url) {
const options = { const options = {
url: parsedUrl, url: parsedUrl,
headers: REQUEST_HEADERS, headers: { ...REQUEST_HEADERS },
timeout: FETCH_TIMEOUT, timeout: FETCH_TIMEOUT,
// Don't set encoding; this fixes issues
// w/gzipped responses
encoding: null, encoding: null,
// Accept cookies
jar: true,
} }
const { response, body } = await get(options) const { response, body } = await get(options)

View File

@ -16,6 +16,13 @@ describe('fetchResource(url)', function() {
assert.equal(typeof body, 'object') assert.equal(typeof body, 'object')
}) })
it('fetches nyt', async () => {
const url = 'http://www.nytimes.com/2016/08/16/upshot/the-state-of-the-clinton-trump-race-is-it-over.html?_r=0'
const { body, response } = await fetchResource(url)
assert.equal(typeof body, 'object')
})
}) })
describe('validateResponse(response)', () => { describe('validateResponse(response)', () => {