forked from AlexisReverte/node-odoo
-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected]
for the project I'm working on.
Lib didn't work with HTTPS, so I added it.
Here is the diff that solved my problem:
diff --git a/node_modules/odoo/lib/index.js b/node_modules/odoo/lib/index.js
index c9eef07..87a70f0 100644
--- a/node_modules/odoo/lib/index.js
+++ b/node_modules/odoo/lib/index.js
@@ -3,6 +3,7 @@
var assert = require('assert');
var http = require('http'),
+ https = require('https'),
jayson = require('jayson');
var Odoo = function (config) {
@@ -33,13 +34,18 @@ Odoo.prototype.connect = function (cb) {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
- 'Content-Length': json.length
+ 'Content-Length': json.length,
+ 'host': this.host
}
};
var self = this;
- var req = http.request(options, function (res) {
+ let requestClient;
+ if (this.port === 443) requestClient = https;
+ else requestClient = http;
+
+ var req = requestClient.request(options, function (res) {
var response = '';
res.setEncoding('utf8');
@@ -188,7 +194,9 @@ Odoo.prototype._request = function (path, params, callback) {
}
};
- var client = jayson.client.http(options);
+ let client;
+ if (this.port === 443) client = jayson.client.https(options);
+ else client = jayson.client.http(options);
client.request('call', params, function (e, err, res) {
if (e || err) {
This issue body was partially generated by patch-package.
Metadata
Metadata
Assignees
Labels
No labels