Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP authentication fails with TypeError #11

Open
dirichs opened this issue Mar 1, 2017 · 0 comments
Open

HTTP authentication fails with TypeError #11

dirichs opened this issue Mar 1, 2017 · 0 comments

Comments

@dirichs
Copy link

dirichs commented Mar 1, 2017

Using hessian-proxy with node.js v6.10.0, I get a TypeError when trying to establish a connection secured by BASIC authentication:

TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
at fromObject (buffer.js:262:9)
at Function.Buffer.from (buffer.js:101:10)
at new ClientRequest (_http_client.js:112:27)
at Object.exports.request (http.js:31:10)
at Object.exports.request (https.js:199:15)
at Proxy.invoke (/project/node_modules/hessian-proxy/lib/proxy.js:58:38)
at Object. (/project/lib/hessian-adapter.js:10:8)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)

The problem is caused by the interpretation of options.auth in http.ClientRequest. It should be of the form "login:password", but instead Proxy.invoke supplies an object {"user":"login","pass":"password","sendImmediately":true}. This can be seen in proxy.js line 50-56:

    if (this.username) {
        options.auth = {
            user: this.username,
            pass: this.password,
            sendImmediately: true
        };
    }

Replacing these lines with

    if (this.username)
        options.auth = this.username + ":" + this.password;

resolves the issue.

Kind regards,
Martin Dirichs

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

No branches or pull requests

1 participant