var resBody = '';
res.on("data", function (chunk) {
- console.log('----Received response from server ----');
+ console.log('Received response from server');
resBody += chunk.toString();
console.log(resBody);
});
res.on("end", function () {
- console.log('----Request Ended. Final data sent by the server----');
+ console.log('Request Ended. Final data sent by the server - ');
console.log(resBody);
- console.log('----Waiting for next Interval----\n');
+ console.log('Waiting for next Interval\n');
});
});
return parser;
};
-// ------------- HTTP PARSER CALLBACKS -------------
+// HTTP PARSER CALLBACKS
// This is called when http header is fragmented and
// HTTPParser sends it to JS in separate pieces.
function parserOnHeaders(headers, url) {
parser.incoming.statusMessage = info.status_msg;
parser.incoming.started = true;
- // For client side, if response to 'HEAD' request, we will skip parsing body
+ // If response is to 'HEAD' request, skip parsing body
if (parser.incoming.statusCode == 100) {
return false;
}
}
}
-//------------ LIBCURL PARSER CALLBACKS -----------------
+// LIBCURL PARSER CALLBACKS
// Called by libcurl when Request is Done. Finish parser and unref
function cbOnEnd() {
var incoming = this;
void iotjs_https_destroy(iotjs_https_t* https_data);
IOTJS_DEFINE_NATIVE_HANDLE_INFO(https);
-//-------------Constructor------------
+// CONSTRUCTOR
iotjs_https_t* iotjs_https_create(const char* URL, const char* method,
const char* ca, const char* cert,
const char* key, const iotjs_jval_t* jthis) {
IOTJS_RELEASE(https_data);
}
-//----------------Utility Functions------------------
+// UTILITY FUNCTIONS
void iotjs_https_check_done(iotjs_https_t* https_data) {
IOTJS_VALIDATED_STRUCT_METHOD(iotjs_https_t, https_data);
char* done_url;
0);
}
-// ------------Functions almost directly called by JS----------
+// FUNCTIONS ALMOST DIRECTLY CALLED BY JS
// Add a header to outgoing request
void iotjs_https_add_header(iotjs_https_t* https_data,
const char* char_header) {
}
-//--------------CURL Callbacks------------------
+// LIBCURL CALLBACKS
// Read callback is actually to write data to outgoing request
size_t iotjs_https_curl_read_callback(void* contents, size_t size, size_t nmemb,
void* userp) {
}
-//--------------LibTUV Callbacks------------------
+// LIBTUV CALLBACKS
// Callback called on closing handles during cleanup
void iotjs_https_uv_close_callback(uv_handle_t* handle) {
iotjs_https_t* https_data = (iotjs_https_t*)handle->data;
}
}
-//--------------https_poll Functions------------------
+// HTTPS_POLL FUNCTIONS
iotjs_https_poll_t* iotjs_https_poll_create(uv_loop_t* loop,
curl_socket_t sockfd,
iotjs_https_t* https_data) {
IOTJS_RELEASE(poll_data);
}
-// ------------JHANDLERS----------------
-
+// JHANDLERS
JHANDLER_FUNCTION(createRequest) {
DJHANDLER_CHECK_THIS(object);
DJHANDLER_CHECK_ARGS(1, object);