Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

got does not set res.url if gzip encoding response. #4359

Closed
jrgm opened this issue Nov 2, 2016 · 3 comments · Fixed by #4360
Closed

got does not set res.url if gzip encoding response. #4359

jrgm opened this issue Nov 2, 2016 · 3 comments · Fixed by #4360
Assignees

Comments

@jrgm
Copy link
Contributor

jrgm commented Nov 2, 2016

A bunch of tests fail in stage but not latest, and I've reduced it down to this (using [email protected], but happens in [email protected] which we use (I was hoping that a couple of relevant fixes in 6.6.0 might fix this, but no luck)).

// huh.js
var got = require('got')
var url = process.argv[2]
got(url)
  .then((res) => {
    console.log('res.url', res.url, typeof res.url, res.requestUrl)
  })

Output:

$ node huh.js https://accounts.stage.mozaws.net/complete_reset_password
res.url undefined undefined undefined

$ node huh.js https://latest.dev.lcip.org/complete_reset_password
res.url https://latest.dev.lcip.org/complete_reset_password string https://latest.dev.lcip.org/complete_reset_password
@jrgm
Copy link
Contributor Author

jrgm commented Nov 2, 2016

The problem is got handling gzip. The stage server will reply with Content-Encoding: gzip if Accept-Encoding: gzip, while latest will not.

Accept-Encoding: gzip, deflate is set by default by got, if Accept-Encoding is not set.

This version works:

var got = require('got')
var url = process.argv[2]
var requestOptions = {
  headers: {
    'accept-encoding': 'identity'
  }
}
got(url, requestOptions)
  .then((res) => {
    console.log('res.url', res.url, typeof res.url, res.requestUrl)
  })

Output:

$ node huh.js https://latest.dev.lcip.org/complete_reset_password
res.url https://latest.dev.lcip.org/complete_reset_password string https://latest.dev.lcip.org/complete_reset_password

$ node huh.js https://accounts.stage.mozaws.net/complete_reset_password
res.url https://accounts.stage.mozaws.net/complete_reset_password string https://accounts.stage.mozaws.net/complete_reset_password

@jrgm jrgm changed the title got don't get got does not set res.url if gzip encoding response. Nov 2, 2016
@jrgm jrgm added the upstream label Nov 2, 2016
@jrgm
Copy link
Contributor Author

jrgm commented Nov 2, 2016

Filed reduced testcase using http://google.com: sindresorhus/got#240

@vladikoff
Copy link
Contributor

👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants