},
"module": {
"always": ["buffer", "console", "events", "fs", "module", "timers"],
- "include": ["assert", "dns", "http", "net", "stream", "testdriver", "https"],
+ "include": ["assert", "dns", "http", "net", "stream", "testdriver"],
"exclude": {
"all": [],
- "linux": ["adc", "ble", "dgram", "gpio", "i2c", "pwm", "spi", "uart", "https"],
- "nuttx": ["adc", "dgram", "gpio", "i2c", "pwm", "stm32f4dis", "uart", "https"],
- "darwin": ["https"],
- "tizen": ["adc", "ble", "dgram", "gpio", "i2c", "pwm", "spi", "uart"],
- "tizenrt": ["gpio", "pwm", "https"]
+ "linux": ["adc", "ble", "dgram", "gpio", "i2c", "pwm", "spi", "uart"],
+ "nuttx": ["adc", "dgram", "gpio", "i2c", "pwm", "stm32f4dis", "uart"],
+ "darwin": [],
+ "tizen": ["adc", "ble", "dgram", "gpio", "i2c", "pwm", "spi", "uart", "https"],
+ "tizenrt": ["gpio", "pwm"]
}
}
}
# Https
-IoT.js provides HTTPS to support HTTPS clients enabling users to send HTTPS request easily.
+IoT.js provides HTTPS to support HTTPS clients enabling users to send HTTPS requests easily.
### https.request(options[, callback])
* `options` {Object}
- * `host` {string} A domain name or IP address of the server to issue the request to. Defaults to 'localhost'.
+ * `host` {string} A domain name or IP address of the server to issue the request to. **Deafult:** 'localhost'.
* `hostname` {string} Alias for host.
- * `port` {number} Port of remote server. Defaults to 80.
- * `method` {string} A string specifying the HTTPS request method. Defaults to 'GET'.
- * `path` {string} Request path. Defaults to '/'. Should include query string if any. E.G. '/index.html?page=12'. An exception is thrown when the request path contains illegal characters. Currently, only spaces are rejected but that may change in the future.
+ * `port` {number} Port of remote server. **Deafult:** 80.
+ * `method` {string} A string specifying the HTTPS request method. **Deafult:** 'GET'.
+ * `path` {string} Request path. **Deafult:** '/'. Should include query string if any. E.G. '/index.html?page=12'. An exception is thrown when the request path contains illegal characters. Currently, only spaces are rejected but that may change in the future.
* `headers` {Object} An object containing request headers.
* `auth` {string} Optional Basic Authentication in the form `username:password`. Used to compute HTTPS Basic Authentication header.
* `ca` {string} Optional file path to CA certificate. Allows to override system trusted CA certificates.
* `cert` {string} Optional file path to client authentication certificate in PEM format.
- * `key1` {string} Optional file path to private keys for client cert in PEM format.
+ * `key` {string} Optional file path to private keys for client cert in PEM format.
* `callback` {Function}
* `response` {https.IncomingMessage}
* Returns: {https.ClientRequest}
### https.get(options[, callback])
* `options` {Object}
+ * `host` {string} A domain name or IP address of the server to issue the request to. **Deafult:** 'localhost'.
+ * `hostname` {string} Alias for host.
+ * `port` {number} Port of remote server. **Deafult:** 80.
+ * `method` {string} A string specifying the HTTPS request method. **Deafult:** 'GET'.
+ * `path` {string} Request path. **Deafult:** '/'. Should include query string if any. E.G. '/index.html?page=12'. An exception is thrown when the request path contains illegal characters. Currently, only spaces are rejected but that may change in the future.
+ * `headers` {Object} An object containing request headers.
+ * `auth` {string} Optional Basic Authentication in the form `username:password`. Used to compute HTTPS Basic Authentication header.
+ * `ca` {string} Optional file path to CA certificate. Allows to override system trusted CA certificates.
+ * `cert` {string} Optional file path to client authentication certificate in PEM format.
+ * `key` {string} Optional file path to private keys for client cert in PEM format.
* `callback` {Function}
* `response` {https.IncomingMessage}
* Returns: {https.ClientRequest}
https.ClientRequest inherits [`Stream.writable`](IoT.js-API-Stream.md). See it's documentation to write data to an outgoing HTTP request. Notable methods are `'writable.write()'` (to send data as request body), `'writable.end()'` (to signal an end and flush remaining request body), and the event `'finish'`.
-### request.aborted
-If the request has been aborted, this contains the time at which the request was aborted in milliseconds since epoch as `Number`.
-
### Event: 'close'
This event is fired when the underlying socket is closed.
### request.abort()
Will abort the outgoing request, dropping any data to be sent/received and destroying the underlying socket.
+### request.aborted
+If the request has been aborted, this contains the time at which the request was aborted in milliseconds since epoch as `Number`.
+
### request.setTimeout(ms, cb)
* `ms` {number}
* `cb` {Function}
E(F, FS, Fs, fs) \
E(F, GPIO, Gpio, gpio) \
E(F, HTTPPARSER, Httpparser, httpparser) \
+ E(F, HTTPS, Https, https) \
E(F, I2C, I2c, i2c) \
E(F, PROCESS, Process, process) \
E(F, PWM, Pwm, pwm) \
E(F, TCP, Tcp, tcp) \
E(F, TIMER, Timer, timer) \
E(F, UART, Uart, uart) \
- E(F, UDP, Udp, udp) \
- E(F, HTTPS, Https, https)
+ E(F, UDP, Udp, udp)
#define ENUMDEF_MODULE_LIST(upper, Camel, lower) MODULE_##upper,
var isMethodGood = false;
for (var key in methods) {
if (methods.hasOwnProperty(key)) {
- if(this.method == methods[key]) {
+ if (this.method === methods[key]) {
isMethodGood = true;
+ break;
}
}
}
- if(!isMethodGood) {
+ if (!isMethodGood) {
var err = new Error('Incorrect options.method.')
this.emit('error', err);
return;
}
output = output +
- _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
- _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
+ _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
+ _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
}
return output;
}
var incoming = this;
var parser = incoming.parser;
if (parser) {
- // unref all links to parser, make parser GCed
+ // Unref all links to parser, make parser GCed
parser.finish();
parser = null;
incoming.parser = null;
} else if (!incoming.started) {
incoming.emit('close');
clientRequest.emit('close');
- // socket closed before response starts.
+ // Socket closed before response starts.
var err = new Error('Could Not Start Connection');
clientRequest.onError(err);
} else {
}
if (parser) {
- // unref all links to parser, make parser GCed
+ // Unref all links to parser, make parser GCed
parser.finish();
parser = null;
incoming.parser = null;
if (ret instanceof Error) {
parser.finish();
- // unref all links to parser, make parser GCed
+ // Unref all links to parser, make parser GCed
parser = null;
clientRequest.onError(ret);
return false;
else if (strcmp(method, STRING_TRACE) == 0)
_this->method = HTTPS_TRACE;
else {
- // Will never reach here cuz checked in JS
+ IOTJS_ASSERT(0);
}
// TLS certs stuff
if (_this->poll_data != NULL)
iotjs_https_poll_close_all(_this->poll_data);
-
if (_this->to_destroy_read_onwrite) {
const iotjs_jargs_t* jarg = iotjs_jargs_get_empty();
const iotjs_jval_t* jthis = &(_this->jthis_native);
return real_size - 1;
iotjs_jargs_t jarg = iotjs_jargs_create(1);
iotjs_jval_t jresult_arr = iotjs_jval_create_byte_array(real_size, contents);
- // iotjs_string_t jresult_string =
- // iotjs_string_create_with_size(contents, real_size);
- // iotjs_jargs_append_string(&jarg, &jresult_string);
- // Use the jresult_arr Byte Array in production, but in testing use
- // string. Uncomment out above line in testing.
iotjs_jargs_append_jval(&jarg, &jresult_arr);
bool result =
iotjs_https_jcallback(https_data, IOTJS_MAGIC_STRING_ONDATA, &jarg, true);
iotjs_jval_destroy(&jresult_arr);
- // iotjs_string_destroy(&jresult_string);
iotjs_jargs_destroy(&jarg);
if (!result) {
-/* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
+/* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{ "name": "test_fs_open_read_sync_3.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },
{ "name": "test_gpio_input.js", "skip": ["all"], "reason": "needs hardware" },
{ "name": "test_gpio_output.js", "skip": ["all"], "reason": "need user input"},
- { "name": "test_https_get.js", "timeout": 40 },
- { "name": "test_https_request_response.js", "timeout": 40 },
- { "name": "test_https_timeout.js", "timeout": 40 },
+ { "name": "test_https_get.js", "timeout": 40, "skip": ["all"], "reason": "Only tizen support https, and on tizen we test manually" },
+ { "name": "test_https_request_response.js", "timeout": 40, "skip": ["all"], "reason": "Only tizen support https, and on tizen we test manually" },
+ { "name": "test_https_timeout.js", "timeout": 40, "skip": ["all"], "reason": "Only tizen support https, and on tizen we test manually" },
{ "name": "test_i2c.js", "skip": ["all"], "reason": "need to setup test environment" },
{ "name": "test_iotjs_promise.js", "skip": ["all"], "reason": "es2015 is off by default" },
{ "name": "test_module_cache.js", "skip": ["nuttx"], "reason": "not implemented for nuttx" },