-
Notifications
You must be signed in to change notification settings - Fork 248
Closed
Description
I found a commit message 'allow read to be called outside of callback' for modules/network/socket/lwip/modSocket.c.
It seems that the message means Request.prototype.read can be called outside of its callback.
But I got the following error message when I tried.
/PATH/TO/main.js (19) # Break: (host): cannot coerce undefined to object!
Could you please provide me an example for calling Request.prototype.read outside of request's callback if it can be?
The code and manifest I tried is following:
main.js
import {Request} from "http"
import SecureSocket from "securesocket";
import Timer from 'timer';
const request = new Request({
host: 'translate.google.com',
port: 443,
method: 'GET',
Socket: SecureSocket,
secure: {protocolVersion: 0x303}
});
request.callback = function(message, value, etc) {
trace(`${message}:${value||''}\n`);
};
Timer.repeat((id) => {
if (request.state < 4) return;
// call Request.prototype.read outsize of a callback of the request
trace(`${request.read(String)}\n`);
}, 1);
manifest.json
{
"include": [
"$(MODDABLE)/examples/manifest_base.json",
"$(MODDABLE)/examples/manifest_net.json",
"$(MODDABLE)/modules/crypt/tls.json",
],
"resources": {
"*": [
"$(MODULES)/crypt/data/ca23",
]
},
"modules": {
"*": [
"./main",
"$(MODULES)/network/http/*",
]
},
"preload": [
"http",
],
}
Best Regards,
Metadata
Metadata
Assignees
Labels
No labels