danwrong / restler

REST client library for node.js
MIT License
1.99k stars 391 forks source link

Adding the ability to add a custom https agent. #163

Open rashthedude opened 10 years ago

rashthedude commented 10 years ago

We have a requirement such that we need to make non standard HTTPS calls. We need to alter the https agent and pass information on where to read the cert, ca and cert files are not provided by the connection.

An example use case is as follows

options = {
        hostname: parsed.hostname,
        port: parsed.port,
        path: parsed.path,
        method: 'POST',
        key: fs.readFileSync('/var/www/apps/custom/current/config/certs/custom.key'),
        cert: fs.readFileSync('/var/www/apps/custom/current/config/certs/custom.crt')
        ca: fs.readFileSync('/var/www/apps/custom/current/config/certs/customca.crt')
 }
agent = new https.Agent(options)

restler.post(@mtUrl, {data: params, agent: agent}).on 'success', function(data, resp) {
  // bla bla
})

The pull request is super simple so would be excellent if you could merge it in.

stowns commented 10 years ago

+1

easternbloc commented 10 years ago

This would fix #81

easternbloc commented 10 years ago

Can you add a test?

sesposito commented 10 years ago

This would be great

rashthedude commented 10 years ago

I will add necessary tests.

sesposito commented 10 years ago

Any progress?

rashthedude commented 10 years ago

Sorry, but due to work commitments have I not been able to write the necessary tests. Should hopefully have them ready for the weekend.

sesposito commented 10 years ago

Maybe I can help you with the tests? I'd just need to have an example or something, because I've never done tests for node

capablemonkey commented 10 years ago

+1

easternbloc commented 10 years ago

@capablemonkey Happy to merge if you fancy adding some tests :)

omichowdhury commented 9 years ago

@easternbloc I've been struggling to figure out a way to test this change to be honest. Had a look through the current tests and I didn't see a way of testing an option. Testing setting an agent itself from the response also seems impossible. Any ideas?