Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add https module #354

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

jfmherokiller
Copy link

This commit adds a basic https module based off the http one allowing Javascript to make https requests in addition to http ones

@Gloorf
Copy link

Gloorf commented Oct 16, 2017

Is this supposed to work ? Trying the following simple code

var https = require('https');
https.require('https://google.fr');

Gives me the following error :

[23:35:57 WARN]: [scriptcraft] Plugin scriptcraft v3.2.1-2016-12-23 generated an exception while executing task 6532
jdk.nashorn.internal.runtime.ECMAException: TypeError: Can not create new object with constructor javax.net.ssl.HttpsURLConnection with the passed arguments; they do not match any of its method signatures.
        at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[nashorn.jar:?]
        at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213) ~[nashorn.jar:?]
        at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185) ~[nashorn.jar:?]
        at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172) ~[nashorn.jar:?]
        at jdk.nashorn.internal.runtime.linker.NashornStaticClassLinker.checkNullConstructor(NashornStaticClassLinker.java:108) ~[nashorn.jar:?]
        at jdk.nashorn.internal.runtime.linker.NashornStaticClassLinker.getGuardedInvocation(NashornStaticClassLinker.java:88) ~[nashorn.jar:?]
        at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176) ~[nashorn.jar:?]
        at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124) ~[nashorn.jar:?]
        at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154) ~[nashorn.jar:?]
        at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253) ~[nashorn.jar:?]
        at jdk.nashorn.internal.scripts.Script$Recompilation$1788$2941$\^eval\_.L:1#request#L:90(<eval>:108) ~[?:?]
        at jdk.nashorn.javaadapters.java.lang.Runnable.run(Unknown Source) ~[?:?]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:52) [spigot-1.12.1.jar:git-Spigot-da42974-8f47214]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_144]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_144]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_144]
>```

On a sidenote, HTTPS requests work for me w/ the HTTP module, if I use openJDK and not oracle JDK.

Signed-off-by: noah the goodra <peterpan0413@live.com>
@jfmherokiller
Copy link
Author

@Gloorf sorry i forgot to cast the string

@unixfox
Copy link

unixfox commented Apr 16, 2019

@jfmherokiller I still have the same error as @Gloorf with your latest commit:

[01:53:07 WARN]: [scriptcraft] Plugin scriptcraft v3.4.0-2019-01-20 generated an exception while executing task 26735
jdk.nashorn.internal.runtime.ECMAException: TypeError: Can not create new object with constructor javax.net.ssl.HttpsURLConnection with the passed arguments; they do not match any of its method signatures.
at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.NashornStaticClassLinker.checkNullConstructor(NashornStaticClassLinker.java:108) ~[nashorn.jar:?]
at jdk.nashorn.internal.runtime.linker.NashornStaticClassLinker.getGuardedInvocation(NashornStaticClassLinker.java:88) ~[nashorn.jar:?]
at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176) ~[nashorn.jar:?]
at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124) ~[nashorn.jar:?]
at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154) ~[nashorn.jar:?]
at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253) ~[nashorn.jar:?]
at jdk.nashorn.internal.scripts.Script$Recompilation$4154$2942$\^eval\_.L:1#request#L:91(<eval>:109) ~[?:?]
at jdk.nashorn.javaadapters.java.lang.Runnable.run(Unknown Source) ~[?:?]
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftTask.run(CraftTask.java:76) ~[server.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:52) [server.jar:git-Spigot-79a30d7-acbc348]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_191]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_191]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants