5

I have a very simple duktape plugin running embedded in another program. Simple stuff works, but I am not sure how to make HTTP requests. Is it even possible to make HTTP Request from within a Duktape VM?

toddgeist
  • 902
  • 9
  • 21

4 Answers4

5

No you can't. The hosting application must provide it to Duktape. Duktape provides a JavaScript runtime but does not provide function you also find in browsers when using JavaScript.

aggsol
  • 2,343
  • 1
  • 32
  • 49
  • 1
    this is the correct answer, but I want to mention that @creationix has added curl bindings to dukluv, which is a related project. This should be portable to duktape https://github.com/creationix/dukcurl – toddgeist Jan 06 '15 at 15:19
2

In order to make http requests within your duktape program, you must bind a native function (in C if your program is in C) that will make the request and inject back the answer

Lordrem
  • 133
  • 7
0

It would be nice to implement XMLHttpRequest in duktape. That would open the door to many useful use cases and bring it one step closer to using popular js libraries. Are there any plans for that?

alknows
  • 1,972
  • 3
  • 22
  • 26
0

You can implement socket interface in c, then register to duktape.

buaa.byl
  • 1
  • 1