githubot icon indicating copy to clipboard operation
githubot copied to clipboard

The http client githubot uses does not handle redirects

Open rophy opened this issue 9 years ago • 2 comments
trafficstars

Hi,

githubot supports GitHub Enterprise (through changing the base URL).

But when I try to use it in my GHE, the server responses with a 302 redirects, which fails githubot :

{ server: 'GitHub.com',
  date: 'Wed, 13 Jul 2016 07:05:20 GMT',
  'content-type': 'text/html',
  'content-length': '154',
  connection: 'close',
  location: 'https://github.ibm.com/sessions/_auth_request_bounce?return_to=https%3a%2f%2fapi.github.ibm.com%2frepos%2ftsaiyl%2fbluemix-catalog-scan%2fissues%3fassignee%3d%26labels%3dtodo_current' }

Digging in the problem, I found that this is because the http client (node-scoped-http-client) being used does not support 302: https://github.com/technoweenie/node-scoped-http-client/issues/7 In addition, the node-scoped-http-client is no longer being maintained (title of the github project says: Unmaintained. Free push/npm access to anyone interested.).

Is it possible to switch to another http client (e.g. https://github.com/request/request) so that GHE redirects can be handled?

rophy avatar Jul 13 '16 07:07 rophy

Thanks for the report! I don't really know how GHE works, but is that bouncing you to a login page? It seems like the path of /sessions/_auth_request_bounce isn't going to play nice with a noninteractive client.

That said, yes, I'd like to move to a supported HTTP client, and yes, request is probably a good choice. The good news is that the surface space of the http library is pretty limited in this package, and the tests all use nock so they shouldn't need to be touched. I would love a PR if you want to put one together. The best way to make the change is probably:

  1. Make sure the tests pass
  2. Replace the http library
  3. Make sure the tests pass
  4. Make sure you can use the updated package with your GHE installation

iangreenleaf avatar Jul 13 '16 15:07 iangreenleaf

Just to note, this also happens when github.com repositories are moved.

strugee avatar Oct 22 '16 19:10 strugee