Added a Unit test case for this too at ./test/run_pass/test_https_expect.js.
This case fails before this commit, passes after.
Change-Id: I3f5cc94c31cd890fa028bc9737b6534e2f19f2f4
Signed-off-by: Akhil Kedia <akhil.kedia@samsung.com>
parser.incoming.started = true;
// For client side, if response to 'HEAD' request, we will skip parsing body
+ if (parser.incoming.statusCode == 100) {
+ return false;
+ }
return parser.incoming.clientRequest.headersComplete();
}
var incoming = parser.incoming;
if (incoming) {
- incoming.completed = true;
- // no more data from incoming, stream will emit 'end' event
- incoming.push(null);
+ if (incoming.statusCode == 100) {
+ incoming.headers = {};
+ incoming.statusCode = null;
+ incoming.statusMessage = null;
+ incoming.started = false;
+ } else {
+ incoming.completed = true;
+ // no more data from incoming, stream will emit 'end' event
+ incoming.push(null);
+ }
}
}
--- /dev/null
+/* 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var assert = require('assert');
+var https = require('https');
+
+var isRequest1Finished = false;
+// 1. POST req
+var data = JSON.stringify({ data: { temp: 50, onFire: false },
+ sdid: '170e5221612b4bc38dce53fd4395174a',
+ type: 'message' });
+
+var options = {
+ "method": "POST",
+ "hostname": "api.artik.cloud",
+ "path": "/v1.1/messages",
+ "headers": {
+ "content-type": "application/json",
+ "content-length": data.length,
+ "authorization": "Bearer 1718113118564ad495ad03f04116f379"
+ }
+};
+
+var getResponseHandler = function (res) {
+ var res_body = '';
+
+ assert.equal(200, res.statusCode);
+
+ var endHandler = function(){
+ var response = JSON.parse(res_body);
+ assert.assert(response['data'], 'Recieved incorrect response from server');
+ isRequest1Finished = true;
+ };
+ res.on('end', endHandler);
+
+ res.on('data', function(chunk){
+ res_body += chunk.toString();
+ });
+};
+
+var req = https.request(options, getResponseHandler);
+req.write(data);
+req.end();
+
+process.on('exit', function() {
+ assert.equal(isRequest1Finished, true);
+});
{ "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, "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_https_expect.js", "timeout": 40, "skip": ["all"], "reason": "Implemented only for Tizen" },
+ { "name": "test_https_get.js", "timeout": 40, "skip": ["all"], "reason": "Implemented only for Tizen" },
+ { "name": "test_https_request_response.js", "timeout": 40, "skip": ["all"], "reason": "Implemented only for Tizen" },
+ { "name": "test_https_timeout.js", "timeout": 40, "skip": ["all"], "reason": "Implemented only for Tizen" },
{ "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" },